Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Arduino Binary Counter 0-255
- int ledPin[] ={5, 3, 4, 7, 10, 11, 12, 13};
- int maxCount = 256;
- int timer = 500;
- void setup()
- {
- for(int i= 0; i < 9; i++)
- {
- pinMode(ledPin[i], OUTPUT);
- }
- }
- void loop()
- {
- for(int counter = 0; counter < maxCount; counter++)
- {
- displayBinary(counter);
- delay(timer);
- }
- }
- void displayBinary(byte numToShow)
- {
- for(int i= 0; i < 8; i++)
- {
- if(bitRead(numToShow, i)==1)
- {
- digitalWrite(ledPin[i], HIGH);
- }
- else
- {
- digitalWrite(ledPin[i], LOW);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement