quick multi condition question
i'm artist, not programmer. i'm trying basic in code possible.
playing around pinball code. want 3 switches light 3 separate leds. when 3 leds lit, want lights go out, , ready turned on again next time hit them.
right each of lights light when hit switch assigned them. when 3 lit, not turn off again. doing wrong?
playing around pinball code. want 3 switches light 3 separate leds. when 3 leds lit, want lights go out, , ready turned on again next time hit them.
right each of lights light when hit switch assigned them. when 3 lit, not turn off again. doing wrong?
code: [select]
// 3 target scrore function. when target hit lights , provides points.
// when 3 targets lit flash , provide jackpot
// when jackpot provided lights turn off.
int led_d1 = 11;
int led_d2 = 12;
int led_d3 = 13;
int switch_d1 = 1;
int switch_d2 = 2;
int switch_d3 = 3;
void setup() {
// put setup code here, run once:
pinmode(led_d1,output);
pinmode(led_d2,output);
pinmode(led_d3,output);
pinmode(switch_d1,input);
pinmode(switch_d2,input);
pinmode(switch_d3,input);
}
void loop() {
// put main code here, run repeatedly:
//drop target switch 1
if (digitalread(switch_d1) == low)
{
digitalwrite(led_d1,high);
}
//drop target switch 2
if (digitalread(switch_d2) == low)
{
digitalwrite(led_d2,high);
}
//drop target switch 3
if (digitalread(switch_d3) == low)
{
digitalwrite(led_d3,high);
}
//if 3 lit up, award bonus , reset lights low//
if (led_d1 == high && led_d2 == high && led_d3 == high)
{
(led_d1 && led_d2 && led_d3 == low);
}
}
Arduino Forum > Using Arduino > Programming Questions > quick multi condition question
arduino
Comments
Post a Comment