31.07.2015 Views

A-Teachers-Guide-to-the-Intel-Galileo-Final

A-Teachers-Guide-to-the-Intel-Galileo-Final

A-Teachers-Guide-to-the-Intel-Galileo-Final

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

A TEACHER’S GUIDE TO THE INTEL® GALILEO | 30int switchPin = 3;int switchPinState = 0;int lastSwitchPinState = 0;int switchPinStateBeforeLightingLed7 = 0;int delayBetweenLEDs = 100;// <strong>the</strong> setup routine runs once when you press reset:void setup() {// initialize <strong>the</strong> digital pins corresponding <strong>to</strong> <strong>the</strong> LEDs as outputs.pinMode(ledPin12, OUTPUT);pinMode(ledPin11, OUTPUT);pinMode(ledPin10, OUTPUT);pinMode(ledPin9, OUTPUT);pinMode(ledPin8, OUTPUT);pinMode(ledPin7, OUTPUT);pinMode(redLED, OUTPUT);pinMode(greenLED, OUTPUT);// initialise <strong>the</strong> switch digital pin as an inputpinMode(switchPin, INPUT);}// <strong>the</strong> loop routine runs over and over again forever:void loop() {// start <strong>the</strong> LEDs offdigitalWrite(redLED,LOW);digitalWrite(greenLED,LOW);digitalWrite(ledPin12,HIGH);delay(delayBetweenLEDs);digitalWrite(ledPin12,LOW);digitalWrite(ledPin11,HIGH);delay(delayBetweenLEDs);digitalWrite(ledPin11,LOW);digitalWrite(ledPin10,HIGH);delay(delayBetweenLEDs);digitalWrite(ledPin10,LOW);digitalWrite(ledPin9,HIGH);delay(delayBetweenLEDs);digitalWrite(ledPin9,LOW);digitalWrite(ledPin8,HIGH);delay(delayBetweenLEDs);digitalWrite(ledPin8,LOW);switchPinStateBeforeLightingLed7 = digitalRead(switchPin);digitalWrite(ledPin7,HIGH);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!