/*
Nathan Lodder 300 420 912
ENGR 1190 Final
All LED's are attached to the 5V pin on their positive leg so that by default the have current running through them and will shine while the 5V pin on the other side is on logic 'low',
driving <5V into the circuit creating an electrical potential.
Amber LED attached to pin 5
Blue LED attached to pin 6
Red LED attached to pin 9
Green LED attached to pin 10
Pushbuttons that when pressed generate a logic 'high' or '1', assigned as inputs to the following pins
button A (green) is connected to pin 2
button B (red) is connected to pin 12
button C (blue) is connected to pin 8
button D (yellow) is connected to pin 7
Servo input line is attached to pin 11
*/
#include <Servo.h>
//assigning servo1 the qualities of a Servo device
Servo servo1;
//Initiate an integer variable 'servo' and assigning it a value of '11' so that i can type servo instead of 11 every time I refer to the servo pin, this is for ease while coding
int servo = 11;
//Initiate 4 int variables that correspond to the 4 differently coloured LEDs, and assign them the value of the arduino pin that they are respectively connected to
int ALED = 5;
int BLED = 6;
int RLED = 9;
int GLED = 10;
//Initiate 4 int variables that correspond to the 4 push buttons, and assign them the value of the arduino pin that they are respectively connected to
int button_a = 2;
int button_b = 12;
int button_c = 8;
int button_d = 7;
unsigned long brightStart = millis();
unsigned long blinkStart = millis();
//declare an usigned long variable: 'currentMillis' for later use in program timing.
unsigned long currentMillis;
//the value is a number of milliseconds
const unsigned long blinkPeriod = 1000;
const unsigned long brightPeriod = 10;
int brightness = 0;
int increment = 1;
void setup() {
// put your setup code here, to run once:
//designate the uno pins connected to all LED's as outputs
pinMode(ALED, OUTPUT);
pinMode(BLED, OUTPUT);
pinMode(GLED, OUTPUT);
pinMode(RLED, OUTPUT);
servo1.attach(11);
//designate the uno pins connected to all pushbutton's as inputs
pinMode(button_a, INPUT);
pinMode(button_b, INPUT);
pinMode(button_c, INPUT);
pinMode(button_d, INPUT);
//Set the baud rate of the serial data to 9600 bits/second which is the standard for the arduino
Serial.begin(9600);
/*
set all the pins connected to the LED's to a logic high, this will cause them to push 5V into
the circuit that has 5V being pushed from the other end as well. The potential difference across
each LED circuit will be 5V - 5V = 0V, and the LED's will not light up.
*/
digitalWrite(ALED, HIGH);
digitalWrite(BLED, HIGH);
digitalWrite(RLED, HIGH);
digitalWrite(GLED, HIGH);
}
// put your main code here, to run repeatedly:
void loop() {
delay(1000);
digitalWrite(BLED, !digitalRead(BLED));
}