SHARE
TWEET

Arduino - projectile motion

tuixte Dec 21st, 2014 30 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <LiquidCrystal.h>
  2. #include <Servo.h>
  3.  
  4. const int SERVO_PIN = 7;
  5. Servo myServo;
  6. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  7. int angle;
  8.  
  9. void setup(){
  10.   lcd.begin(16, 2);
  11.   myServo.attach(SERVO_PIN);
  12.   Serial.begin(9600);
  13.   myServo.write(0);
  14.   lcd.setCursor(0, 0);
  15.   lcd.print("Moto proiettili");
  16.   lcd.setCursor(0, 1);
  17.   lcd.print("Inserisci angolo");
  18.   Serial.print("Angle (0-177): ");
  19. }
  20.  
  21. void loop(){
  22.   if(Serial.available() > 0){
  23.     angle = Serial.parseInt();
  24.     Serial.print("You entered ");
  25.     Serial.println(angle);
  26.     lcd.clear();
  27.     lcd.setCursor(0, 0);
  28.     lcd.print("Moto proiettili");
  29.     lcd.setCursor(0, 1);
  30.     lcd.print("Angolo: ");
  31.     lcd.print(angle);
  32.     lcd.print(" gradi");
  33.     myServo.write(angle);
  34.     Serial.print("Angle (0-179): ");
  35.   }
  36.   delay(100);
  37. }
RAW Paste Data
Top