#include <Arduino.h>
#include <Servo.h>
/*Nakul Verma, Student # 12345
Code for Exercise 2, Problem 1 Blink all the LEDs
Assume that all the LEDs are blinked on and off at the same time
Component list is as follows:
Pushbutton circuits that generate a logic high are connected to digital pins:
2 - Button A
12 - Button B
8 - Button C
7 - Button D
LEDS cicuits are on the following digital pins:
5 - Orange LED
6 - Blue LED
10 - Green LED
9 - Red LED
Servo control line is on digital pin 11
*/
Servo twisty; //declare servo as variable twisty
void setup() {
// put your setup code here, to run once:
//designate the LED pins as OUTPUTS
pinMode(5,OUTPUT); //Orange LED
pinMode(6,OUTPUT); //Blue LED
pinMode(9,OUTPUT); //Red LED
pinMode(10,OUTPUT); //Green LED
//designate pushbutton pins as INPUTS
pinMode(2,INPUT); //Button A
pinMode(7,INPUT); //Button D
pinMode(8,INPUT); //Button C
pinMode(12,INPUT); //Button B
//attach pin 11 as the servo control line
twisty.attach(11);
//Initialize Serial Monitor at 9600 bps
Serial.begin(9600);
}
void loop() {
//start by turning off all the LEDs and keep them off for 350 ms
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
delay(350); //350 ms off time delay
//turn all the LEDs on for 450 ms
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
delay(450); //450 ms on time delay
}