Hi, I am a beginner and I need your help. I want to display binary number (for example the 000001 will show the last led on and the rest are off) and increment the number every second. I want to do this while I am connecting 6 Leds to the analog pins A0 to A5. I have already built the circuit. Now, I am left with the coding part. how can I fix the code below so that I am able to do so ( I am using this code because I want to make use of direct port manipulation.
Why 26? 6 bits can represent a number between 0 and 63.
What does that mean?
The analog input pins on an Uno (A0-A5) are digital pins with the special function of analog input. Use them like you would use any digital pins. You can use pin numbers 14-19 instead of A0-A5.
Every kind of numerical data, as well as text, is store as binary in the memory. Integers, floats, ASCII... al stored binary. Your writing "binary" makes no sense to us, only tells You don't really know the word You use.
Don't ever make connections to any circuit being on power. That has blown up many circuits.
Describe the "big picture", what the project is supposed to do. Drop the idea telling how it will be done.
You can make a "mask" to read (evaluate) one bit at a time. Start with a value of 1 (which is also one in binary).
Then use bitwise andwith your counting variable, and it will either be zero or not-zero depending on the binary value of bit-zero, and you can turn the associated LED on or off.
Next, bit-shift left the mask and bitwise and again to check the value of bit 1, and update that LED.
...etc.
26?
With 6-bits you can count to 63 decimal.
111111 binary = 63 decimal.
(You can convert with the Windows Calculator in Programmer Mode.)
Hi, I am a beginner and I need your help. I want to display binary number (for example the 000001 will show the last led on and the rest are off) and increment the number every second. I want to do this while I am connecting 6 Leds to the analog pins A0 to A5. I have already built the circuit. Now, I am left with the coding part. how can I fix the code below so that I am able to do so ( I am using this code because I want to make use of direct port manipulation.
Also I have a question regarding this forum, if I put my problem and people tried to help but then I edited the problem how would I let them know that I edited ? do I have to post it again ? or reply to everyone letting him/her know ?
Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting can result in a suspension from the forum.
In the future, please take some time to pick the forum category that best suits the subject of your question and then only post once to that forum category. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.
Hi, @alkaothm
What model Arduino are you using?
A circuit diagram showing the I/O pins and how you have wired the LEDs would be helpful.
Not a Fritzy image but a hand drawn picture would be great.