The first week of the Physical Computing Workshop. First up, blinking an Led. Then making two different led’s blink.
Flashing 8 led’s, one after the other.
Flashing 8 led’s, forward then back!
Code:
| /* Jonathan MunroWk1 – Task 3 – Flashing 8Leds, one after the other for one second each and wait another second before flashing the next. */void setup() { // initialize the ouput pins pinMode(12, OUTPUT); } void loop() { |
| //Jonathan Munro // Wk1 – Task 3c//Turn on the lights in a random pattern, the code works, but with interesting results. Some of the Leds are left on, whist //others come on as well, I wasn’t expecting this, although it does make perfect sense.//LED Pin Variables, Using an array, The range will be from 0-7 rather than 1-8 int ledPins[] = {12,11,10,9,8,7,6,5}; void setup() for(int i = 0; i < 8; i++){ // a Loop which will repete 8 Times } void loop() // Repeat the code } void oneAfterAnotherLoop(){ //Turn Each LED on one after another //Turn Each LED off one after another digitalWrite(ledPins[random(i)], LOW); //Turns off LED’s in the array randomly } |
