Zacknov
Zacknov

Reputation: 21

How to use Seven segment in UnoArduSim

I'm a beginner studying programming and am using UnoArduSim (an Arduino Simulation). I'm still confused by how to use the Seven Segment module because there are only 2 addresses namely the address to the pin and cs *.

How do you use it and how is the program syntax?

image of the arduino simulator

Upvotes: 0

Views: 2515

Answers (1)

Piglet
Piglet

Reputation: 28974

In the menu bar of that program there is something called "Help". Why don't you click it?

7-Segment LED Digit ('7SEG') You can connect this 7-Segment Digit LED display to a chosen set of four consecutive 'Uno' pins that give the hexadecimal code for the desired displayed digit, ('0' through 'F'), and turn this digit on or off using the CS* pin (active-LOW for ON). This device includes a built-in decoder which uses the active-HIGH levels on the four consecutive '1of4' pins to determine the requested hexadecimal digit to be displayed . Te level on the lowest pin number (the one displayed in the '1of4' edit box) represents the least-significant bit of the 4-bit hexadecimal code. The colour of the LED segments ('R', 'Y', 'G', or 'B') is a hidden option that can be only be chosen by editing the IODevices.txt file you can create using Save from the Configure | 'I/O' Devices dialog-box.

Please read manuals.

Edit:

As you don't seem to understand the description, here's a simple example that displays digits 0 to 9. The digit is incremented every second.

enter image description here

/*  This is a default program--
    Use File->Load Prog to load a different program
*/   

void setup()
{
    for (int i  = 3; i <= 8; i++)
        pinMode(i, OUTPUT);

}

void loop()
{
    // display a new digit every second
    for (int digit = 0; digit <= 9; digit++)
    {
        for (int pin = 4; pin <= 7; pin++)
            digitalWrite(pin, (bool)(digit & (1 << pin - 4)));
        delay(1000);
    }
}       

Upvotes: 1

Related Questions