We want to measure temperature and light level.

Please bring

  • Laptop
  • Arduino & cables
  • Plus the kit of bits, particularly the tiny bits (which include a light-dependent resistor and a temperature dependent resistor.)

 
int led = 13;
int button = 8;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(button, INPUT_PULLUP);            // to define how pins 5 an7 will be used
pinMode(A2, INPUT_PULLUP);
Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
Serial.println(analogRead(A2));
digitalWrite(led, LOW);         // WE added.  Led on pin 5 will wink opposite to inbuilt Led on 13
delay(500);               // wait
int butPressed = digitalRead(button);
Serial.print(“Button is currently “);
Serial.println(butPressed);
if ( butPressed == LOW)
{
digitalWrite(led, HIGH);         // WE added.   Led5 keeps winking ONLY on button press
// otherwise it never gets turned on again, stays LOW
}

delay(500);               // wait
}