0

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

Tarick Welling
  • 3,119
  • 3
  • 19
  • 44
Zacknov
  • 21
  • 8

1 Answers1

1

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);
    }
}       
Piglet
  • 27,501
  • 3
  • 20
  • 43
  • Thank you very much. I have read the manual, but still confused. Are there any tutorials and simple program code examples for running seven segments on UnoArduSim ? – Zacknov Oct 27 '19 at 13:13
  • it's just a simulator. any arduino tutorial will do. you only need to know how to set digital outputs – Piglet Oct 27 '19 at 22:40
  • In Arduino uses 7 ports, while in UnoArduSIM only 2 ports for seven segments. I have not gotten a code sample that uses 2 ports on Arduino for the seven segment. – Zacknov Oct 29 '19 at 13:51
  • @Zacknov please read my answer or the manual! 1of4 names the first of four consecutive outputs. let's say pins 4 to 7. to display a 7 you set 4 high, 5 high, 6 high, 7 low. – Piglet Oct 29 '19 at 16:29
  • @Zacknov of course it works. the question is, do you understand it... – Piglet Oct 30 '19 at 12:51
  • Could you please explain in detail to me about the syntax : digitalWrite(pin, (bool)(digit & (1 << pin - 4))); – Zacknov Nov 03 '19 at 11:12
  • @Zacknov it set sets the output value of the respective pin according to the digit to be displayed. I cannot teach you basic C++ through this post. – Piglet Nov 04 '19 at 07:15
  • This might be about Left shift and Right shift operations. Thank you very much, I will study C / C ++ again. – Zacknov Nov 05 '19 at 08:04
  • yes you have to find out if the bits of your number are 1 or 0 so you can set your outputs accordingly. – Piglet Nov 05 '19 at 08:36
  • can this program be implemented in Arduino? how is the circuit – Zacknov Nov 23 '19 at 10:37
  • @Zacknov of course that's why this is an Arduino Simulator... just search the web for "7 segment arduino" is it really so difficult? – Piglet Nov 23 '19 at 19:35
  • I mean, arduino with unoardusim (arduino simulator) is not the same. 7 segments on Arduino devices are not the same as 7 segments on Unoardusim devices. Because the Arduino device uses 7 pins, while Unoardusim only has 1 pin. Correct that? – Zacknov Nov 24 '19 at 15:58
  • unoardusim uses 4 pins. you just define those 4 pins by entering the first of four pins number... you can use a BCD to 7 segment decoder IC and do exactly the same – Piglet Nov 25 '19 at 06:50