CC Lab: Homework Week Two

Thursday, September 7th 2017

The Code

int ledPinBlue = 9; // Blue LED connected to digital pin 9~ int ledPinRed = 10; // Red LED connected to digital pin 10~

void setup() { pinMode(ledPinBlue, OUTPUT); pinMode(ledPinRed, OUTPUT);

Serial.begin(9600); }

void loop() { int sensorValue = analogRead(A0); Serial.println(sensorValue); int fadeValue = map(sensorValue, 0, 1023, 0, 255); analogWrite(ledPinBlue, fadeValue); delay(500); analogWrite(ledPinRed, fadeValue); }