Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //A NOTE: All comments are EX POST FACTO. This was the code from an actual lab I did in 2017.
- #include "C:/users/USER/desktop/FUNCTIONS/FUNCTIONS.ino" //I had this library called FUNCTIONS.ino at some point.
- void setup() {
- pinMode(2,INPUT); //All the inputs were assigned to DIP switches on a bread board.
- pinMode(3,INPUT);
- pinMode(4,INPUT);
- pinMode(5,INPUT);
- pinMode(A0,INPUT);
- pinMode(A1,INPUT);
- pinMode(A2,INPUT);
- pinMode(A3,INPUT);
- pinMode(8,OUTPUT); //All the outputs were sent to LEDs that were protected with 220 Ohm resistors at the ground.
- pinMode(9,OUTPUT);
- pinMode(10,OUTPUT);
- pinMode(11,OUTPUT);
- pinMode(12,OUTPUT);
- }
- void loop(){
- int a = digitalRead(2);
- int b = digitalRead(3);
- int c = digitalRead(4);
- int d = digitalRead(5);
- int e = digitalRead(A0);
- int f = digitalRead(A1);
- int g = digitalRead(A2);
- int h = digitalRead(A3);
- int carry_out,out1,out2,out3,out4; //All the various carry outs for the four bit adder.
- FOURADD(d,c,b,a,h,g,f,e,&carry_out,&out1,&out2,&out3,&out4);
- digitalWrite(8,carry_out); //Writing the outputs to LEDs.
- digitalWrite(9,out1);
- digitalWrite(10,out2);
- digitalWrite(11,out3);
- digitalWrite(12,out4);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement