Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include "pitches.h"
- int melody () = {
- NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4;};
- int noteDurations () ={
- 4, 8, 8, 4, 4, 4, 4, 4
- };
- #include <LiquidCrystal.h>;
- LiquidCrystal miP (A5, A4, A3, A2, A1, A0); // pins of LCD
- const int controlPin1 =10;//pwn - h bridge
- const int controlPin2 =9; //pwn - h bridge
- const int enablePin =8; // does not need to be pwn
- const int directionoff =2; // switches direction
- const int switchonoff =4; // turns tune and dc motor on off button
- const int redPin =6; //red of rgb - has to be pwn
- const int greenPin =5;//green of rgb - has to be pwn
- const int bluePin =3; //blueof rgb - has to be pwn
- int photoVal;
- int readVal;
- int motorSpeed;
- bool oldPressOn=false;
- bool newPressOn=false;
- bool newDir=false;
- bool oldDir=false;
- bool enable=false;
- bool dir=false;
- void setup() {
- miP.begin(16,2);
- miP.print("Hi Stroboscope!");
- pinMode (controlPin1,OUTPUT);
- pinMode (controlPin2, OUTPUT);
- pinMode (enablePin, OUTPUT);
- pinMode (directionoff, INPUT);
- pinMode (switchonoff, INPUT);
- pinMode (bluePin, OUTPUT);
- pinMode (redPin, OUTPUT);
- pinMode (greenPin, OUTPUT);
- for (int thisNote =0; thisNote <8; thisNote++) {
- int noteDuration = 1000 / noteDurations[thisNote];
- tone(8, melody[thisNote], noteDuration);
- int pauseBetweenNotes = noteDuration * 1.30;
- delay(pauseBetweenNotes);
- noTone(8);
- }
- Serial.begin(9600);
- }
- void loop() {
- for (int positionCounter = 0; positionCounter <13; positionCounter++);{
- miP.scrollDisplayLeft(); // scrolling code
- delay(150);
- for (int positionCounter = 0; positionCounter<29; positionCounter++){
- miP.scrollDisplayLeft();
- delay(150);
- }
- digitalRead (switchonoff);
- miP.print ("disco mode");
- newPressOn = digitalRead(switchonoff);
- delay(5);
- if(newPressOn ==1 && newPressOn != oldPressOn)
- {
- enable=!enable;
- }
- newDir = digitalRead(directionoff);
- delay(5);
- if (newDir ==1 && newDir != oldDir)
- {
- dir =!dir;
- }
- if (enable)
- {
- motorSpeed = analogRead(directionoff);
- if (dir)
- {
- digitalWrite (controlPin1, HIGH);
- digitalWrite (controlPin2, LOW);
- analogWrite (enablePin, 1023);
- }
- else
- {
- digitalWrite(controlPin1, LOW);
- digitalWrite(controlPin2, HIGH);
- analogWrite (enablePin, 200);
- }
- }
- else
- {
- analogWrite (enablePin, 0);
- }
- oldPressOn = newPressOn;
- oldDir = newDir;
- }
- analogRead(switchonoff);
- analogWrite (redPin, 255);
- analogWrite (greenPin, 255);
- analogWrite (bluePin, 255);
- delay(5);
- analogWrite (redPin, 238);
- analogWrite (greenPin, 238);
- analogWrite (bluePin, 238);
- delay(5);
- analogWrite (redPin, 255);
- analogWrite (greenPin, 255);
- analogWrite (bluePin, 255);
- delay(5);
- analogWrite (redPin, 204);
- analogWrite (greenPin, 0);
- analogWrite (bluePin, 0);
- delay(5);
- analogWrite (redPin, 0);
- analogWrite (greenPin, 0);
- analogWrite (bluePin, 0);
- delay(5);
- analogRead (switchonoff);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement