Quantcast
Channel: fritzing forum - Latest posts
Viewing all articles
Browse latest Browse all 29614

Schematic to breadboard layout

$
0
0

Assuming bit 1 is the red led and bit 2 is the green led and a 1 turns on the led, then this should do what you want.

void setup()
{
leds = 0; /* set the leds initially all off */
pinMode(latchPin, OUTPUT);
...

if (digitalRead(modebtn) == HIGH && toggle8 == 1){
toggle8 = 0;
if(mode == 0){
mode = 1;
midi.write(0x90);
midi.write(0x17);
midi.write((byte)0x00);
bitClear(leds,2); /* turn off green led */
bitSet(leds, 1); /* turn on red led */
updateShiftRegister();
}
else if(mode == 1){
mode = 0;
midi.write(0x90);
midi.write(0x30);
midi.write((byte)0x00);
bitClear(leds,1) /* turn off the red led */
bitSet(leds, 2); /* turn on the green led */
updateShiftRegister();
}

The variable leds will keep the current state of the leds until the program changes it and calls updateShiftRegister() to change the value so you don't need the loops or the delays. Pressing the pushbottons will change the state of the leds.

Do I have to wire the blue leg? Because I don't need it? Thanks

No if you don't use it you don't need to connect it.

Peter


Viewing all articles
Browse latest Browse all 29614

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>