Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. //A NOTE: All comments are EX POST FACTO. This was the code from an actual lab I did in 2017.
  2.  
  3. #include "C:/users/USER/desktop/FUNCTIONS/FUNCTIONS.ino" //I had this library called FUNCTIONS.ino at some point.
  4.  
  5. void setup() {
  6. pinMode(2,INPUT); //All the inputs were assigned to DIP switches on a bread board.
  7. pinMode(3,INPUT);
  8. pinMode(4,INPUT);
  9. pinMode(5,INPUT);
  10. pinMode(A0,INPUT);
  11. pinMode(A1,INPUT);
  12. pinMode(A2,INPUT);
  13. pinMode(A3,INPUT);
  14. pinMode(8,OUTPUT); //All the outputs were sent to LEDs that were protected with 220 Ohm resistors at the ground.
  15. pinMode(9,OUTPUT);
  16. pinMode(10,OUTPUT);
  17. pinMode(11,OUTPUT);
  18. pinMode(12,OUTPUT);
  19. }
  20.  
  21. void loop(){
  22. int a = digitalRead(2);
  23. int b = digitalRead(3);
  24. int c = digitalRead(4);
  25. int d = digitalRead(5);
  26. int e = digitalRead(A0);
  27. int f = digitalRead(A1);
  28. int g = digitalRead(A2);
  29. int h = digitalRead(A3);
  30.  
  31. int carry_out,out1,out2,out3,out4; //All the various carry outs for the four bit adder.
  32.  
  33. FOURADD(d,c,b,a,h,g,f,e,&carry_out,&out1,&out2,&out3,&out4);
  34.  
  35. digitalWrite(8,carry_out); //Writing the outputs to LEDs.
  36. digitalWrite(9,out1);
  37. digitalWrite(10,out2);
  38. digitalWrite(11,out3);
  39. digitalWrite(12,out4);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement