Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- #include <Servo.h>
- const int SERVO_PIN = 7;
- Servo myServo;
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- int angle;
- void setup(){
- lcd.begin(16, 2);
- myServo.attach(SERVO_PIN);
- Serial.begin(9600);
- myServo.write(0);
- lcd.setCursor(0, 0);
- lcd.print("Moto proiettili");
- lcd.setCursor(0, 1);
- lcd.print("Inserisci angolo");
- Serial.print("Angle (0-177): ");
- }
- void loop(){
- if(Serial.available() > 0){
- angle = Serial.parseInt();
- Serial.print("You entered ");
- Serial.println(angle);
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Moto proiettili");
- lcd.setCursor(0, 1);
- lcd.print("Angolo: ");
- lcd.print(angle);
- lcd.print(" gradi");
- myServo.write(angle);
- Serial.print("Angle (0-179): ");
- }
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement