//\\\\\\\allo paradeigm pws sundeei sensor klp //\\\\\\\https://www.makerguides.com/hc-sr04-arduino-tutorial/ /////////////////////////////////////////////////////////////// //apo edv phra th sundesh arduino processing //https://gist.github.com/timpulver/5ba4a29cddd543b4a900 //arduino sound trigger with processing ///////kai//////////////////////////////////////////////////////// //https://create.arduino.cc/projecthub/microBob/lcd-liquid-crystal-display-e72c74?ref=similar&ref_id=158930&offset=3 //apo edv phra th syndesh ths othonhs lcd.. ////////////////////////////////////////////////////////// #include //Include^ //Init LiquidCrystal lcd(12,11, 5, 4, 3, 2); /*Initialize the LCD and tell it which pins is to be used for communicating*/ //Global Var #define contra 9 //Define the pin that controls the contrast of the screen #define bri 10 //Define the pin the controls the brightness of the screen //Both pins are PWM so you can analogWrite to them and have them output a variable value /* Example code for HC-SR04 ultrasonic distance sensor with Arduino. No library required. More info: https://www.makerguides.com */ //Global Var #define contra 9 //Define the pin that controls the contrast of the screen #define bri 10 //Define the pin the controls the brightness of the screen //Both pins are PWM so you can analogWrite to them and have them output a variable value // Define Trig and Echo pin for ultra sonic sensor: #define trigPin 7 #define echoPin 6 // Define variables: //dhlvnv long duration; int distance; void setup() { // put your setup code here, to run once: lcd.begin(16, 2); //Tell the LCD that it is a 16x2 LCD pinMode(contra, OUTPUT); //set pin 9 to OUTPUT pinMode(bri, OUTPUT); //Set pin 10 to OUTPUT //pinMode-ing OUTPUT makes the specified pin output power analogWrite(contra, 110); //*outputs power to the contrast pin. // this lets you see the words*/ analogWrite(bri, 255); //Outputs full power to the screen brightness LED // Define inputs and outputs for ultra sonic sensor: pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); //Begin Serial communication at a baudrate of 9600: Serial.begin(9600); } void reset() { analogWrite(contra, 18 * 5); analogWrite(bri, 255); } void brihigh() { analogWrite(contra, 10 * 5); analogWrite(bri, 255); } void contrhigh() { analogWrite(contra, 22 * 6); digitalWrite(bri, 255); } void endhigh() { analogWrite(contra, 10 * 8); digitalWrite(bri, 255); } void loop() { // put your main code here, to run repeatedly: // Clear the trigPin of UltraSonic sensor by setting it LOW: digitalWrite(trigPin, LOW); delayMicroseconds(5); // Trigger the sensor by setting the trigPin high for 10 microseconds: digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Read the echoPin, pulseIn() returns the duration (length of the pulse) in microseconds: duration = pulseIn(echoPin, HIGH); //initialize//arxikopoihsh metavlhths me mia timh // Calculate the distance: distance = duration * 0.034 / 2; //initialize//arxikopoihsh metavlhths me mia timh if (distance > 1182 || distance < 26) { for (int l = 0; l < 16; l++) { //For loop. Repeating 16 times brihigh(); lcd.setCursor(l, 0); //Scroll only first line -text to the right once lcd.print(String("META")); delay(70); //Slight delay for animation lcd.clear(); } for (int l = 0; l < 10; l++) { // brihigh(); // delay(35); // reset(); // delay(15); // contrhigh(); // delay(15); lcd.setCursor(0, 0); lcd.print(String("META")); delay(20); lcd.setCursor(10 - (l + 1), 1); lcd.print(String("KINHSH")); delay(30); if (l == 9) { contrhigh(); delay(700); // Serial.println("leitoyrgv"); } lcd.clear(); } for (int l = 0; l < 6; l++) { lcd.setCursor(l, 0); lcd.print(String("META")); delay(100); lcd.clear(); if (l > 3) { contrhigh(); delay(10); endhigh(); delay(10); } } } else { contrhigh(); // Print the distance on the Serial Monitor (Ctrl+Shift+M): //use these numbers in processing to activate sound and more!!!!//////////////////////// //\\\\\\\\\\\\\\\\\\\\\\\\\\\\Serial.print("Distance = "); //and // Serial.println(" cm"); do not need them\\\\\\\\\\\\\\// Serial.println(distance); //\\\\so we take only numbers without cm!!!***// //write the distance on screen //lcd.setCursor(0, 0); lcd.print(String("Distance")); //Output " Distance" on the first line of the LCD lcd.setCursor(0, 1); /*Set the (invisible) cursor on the first place second row of the LCD. Cursor values are 0-indexed, 0 would the be the first place. The cursor coordinates are X,Y coordinates.*/ lcd.print(distance + String(" cm")); //puts the number taken from ultra sonic sensor and puts cm at the end///// //prosthetei th metavlhth mesa san keimeno mazi me to cm kai th vgalei ena megalutero keimeno gia auto vazv to string //g n mhn kanei prosthesei epeidh h mia metavljhth mou einai int// //to string einai typos metavlhths poy dhlvnei keimeno !!!/// delay(1000); //Wait a second lcd.clear(); //clears the screen } }