LED

I started a project for my school and i need to programs 2 led in a mechanics.
The first led need to light up when the energy come from the first source.(battery)
The second led need to light up when the energy come from the second source.(turn the crank)
I do that can u help me :slight_smile:

int battery;
int crank;

void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
}

void loop() {
while (battery) {
battery = 0 + 1;
switch (battery) {
case 0:
digitalWrite(13, LOW);
break;
}
switch (battery) {
case 1:
digitalWrite(13, HIGH);
break;
}
}
while (crank) {
crank = 0 + 1;
switch (crank) {
case 0:
digitalWrite(12, LOW);
break;
}
switch (crank) {
case 1:
digitalWrite(12, HIGH);
break;
}
}

}

How do you know (ie how do you tell the sketch) which source is active?

Your code doesn’t do anything, but I guess you knew that.

Please remember to use code tags when posting code.

where do you read the battery and/or crank inputs?

why not just test for both and conditional set the LEDs

battery = digitalRead (batteryPin);

if (battery)  {
    digitalWrite (BatteryLED, HIGH);
    digitalWrite (CrannkLED, LOW);
}
else {
   ... similar
}