SHARE
TWEET

Untitled

katiebogdanow Feb 17th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. include "pitches.h"
  2. int melody () = {
  3. NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4;};
  4. int noteDurations () ={
  5.  4, 8, 8, 4, 4, 4, 4, 4
  6. };
  7. #include <LiquidCrystal.h>;
  8. LiquidCrystal miP (A5, A4, A3, A2, A1, A0); // pins of LCD
  9. const int controlPin1 =10;//pwn - h bridge
  10. const int controlPin2 =9; //pwn - h bridge
  11. const int enablePin =8; // does not need to be pwn
  12. const int directionoff =2; // switches direction
  13. const int switchonoff =4; // turns tune and dc motor on off button
  14. const int redPin =6; //red of rgb - has to be pwn
  15. const int greenPin =5;//green of rgb - has to be pwn
  16. const int bluePin =3; //blueof rgb - has to be pwn
  17. int photoVal;
  18. int readVal;
  19. int motorSpeed;
  20. bool oldPressOn=false;
  21. bool newPressOn=false;
  22. bool newDir=false;
  23. bool oldDir=false;
  24. bool enable=false;
  25.  
  26. bool dir=false;
  27. void setup() {
  28. miP.begin(16,2);
  29. miP.print("Hi Stroboscope!");
  30. pinMode (controlPin1,OUTPUT);
  31. pinMode (controlPin2, OUTPUT);
  32. pinMode (enablePin, OUTPUT);
  33. pinMode (directionoff, INPUT);
  34. pinMode (switchonoff, INPUT);
  35. pinMode (bluePin, OUTPUT);
  36. pinMode (redPin, OUTPUT);
  37. pinMode (greenPin, OUTPUT);
  38. for (int thisNote =0; thisNote <8; thisNote++) {
  39.   int noteDuration = 1000 / noteDurations[thisNote];
  40.   tone(8, melody[thisNote], noteDuration);
  41.     int pauseBetweenNotes = noteDuration * 1.30;
  42.     delay(pauseBetweenNotes);
  43.     noTone(8);
  44. }
  45.  
  46. Serial.begin(9600);
  47. }
  48.  
  49. void loop() {
  50.  
  51.   for (int positionCounter = 0; positionCounter <13; positionCounter++);{
  52.   miP.scrollDisplayLeft(); // scrolling code
  53.   delay(150);
  54.   for (int positionCounter = 0; positionCounter<29; positionCounter++){
  55.  miP.scrollDisplayLeft();
  56.  delay(150);
  57. }
  58. digitalRead (switchonoff);
  59. miP.print ("disco mode");
  60. newPressOn = digitalRead(switchonoff);
  61. delay(5);
  62. if(newPressOn ==1 && newPressOn != oldPressOn)
  63. {
  64.   enable=!enable;
  65. }
  66. newDir = digitalRead(directionoff);
  67.  
  68. delay(5);
  69. if (newDir ==1 && newDir != oldDir)
  70. {
  71.   dir =!dir;
  72. }
  73. if (enable)
  74.  {
  75.   motorSpeed = analogRead(directionoff);
  76.   if (dir)
  77.  {
  78.   digitalWrite (controlPin1, HIGH);
  79.   digitalWrite (controlPin2, LOW);
  80.   analogWrite (enablePin, 1023);
  81.  }
  82.  else
  83.  {
  84.   digitalWrite(controlPin1, LOW);
  85.   digitalWrite(controlPin2, HIGH);
  86.   analogWrite (enablePin, 200);
  87.  }
  88.  }
  89.  else
  90.  {
  91.   analogWrite (enablePin, 0);
  92.  }
  93.  oldPressOn = newPressOn;
  94.  oldDir = newDir;
  95. }
  96. analogRead(switchonoff);
  97. analogWrite (redPin, 255);
  98. analogWrite (greenPin, 255);
  99. analogWrite (bluePin, 255);
  100. delay(5);
  101. analogWrite (redPin, 238);
  102. analogWrite (greenPin, 238);
  103. analogWrite (bluePin, 238);
  104. delay(5);
  105. analogWrite (redPin, 255);
  106. analogWrite (greenPin, 255);
  107. analogWrite (bluePin, 255);
  108. delay(5);
  109. analogWrite (redPin, 204);
  110. analogWrite (greenPin, 0);
  111. analogWrite (bluePin, 0);
  112. delay(5);
  113. analogWrite (redPin, 0);
  114. analogWrite (greenPin, 0);
  115. analogWrite (bluePin, 0);
  116. delay(5);
  117. analogRead (switchonoff);
  118.  
  119. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top