Back to Parent

int tilt1Pin = D3;
int tilt2Pin = D4;

int redPin = A0;    // RED pin of the LED to PWM pin **A0**
int greenPin = D0;  // GREEN pin of the LED to PWM pin **D0**
int bluePin = D1;   // BLUE pin of the LED to PWM pin **D1**
int redValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int greenValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int blueValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255


void setup()
{
  pinMode( redPin, OUTPUT);
  pinMode( greenPin, OUTPUT);
  pinMode( bluePin, OUTPUT);
  pinMode( tilt2Pin, INPUT);
  pinMode( tilt1Pin, INPUT);


  digitalWrite( redPin, HIGH);
  digitalWrite( greenPin, HIGH);
  digitalWrite( bluePin, HIGH);


}



void loop()
{
  int val1 = digitalRead(tilt1Pin); // read from the sensor
  int val2 = digitalRead(tilt2Pin);

  digitalWrite( bluePin, HIGH);
  digitalWrite( redPin, HIGH);
  digitalWrite( greenPin, HIGH);

  if (val1 == HIGH && val2 == HIGH)   { digitalWrite( bluePin, LOW);
  color == 'B';

  }else if (val1 == LOW && val2 == HIGH)   {digitalWrite( greenPin, LOW);
  color == 'G';

  }else if (val1 == HIGH && val2 == LOW)   {digitalWrite( redPin, LOW);
  color == 'R';

  }else {digitalWrite( redPin, HIGH);
  color == 'O'; }


}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0