Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- // Set the LCD address to 0x27 for a 16 chars and 2 lines display
- LiquidCrystal_I2C lcd(0x27, 16, 2);
- #include <Stepper.h>
- const int stepsPerRevolution = 200;
- // initialize the stepper library on pins 8 through 11:
- Stepper myStepper(stepsPerRevolution, 8,9,10,11);
- int stepCount = 0; // number of steps the motor has taken
- int light=0;
- float angle=0.;
- void setup()
- {
- Serial.begin(9600);
- lcd.begin();
- lcd.backlight();
- lcd.print("** Asteroids **");
- delay(2000);
- lcd.clear();
- lcd.print("E. Barres School");
- lcd.setCursor(0,1);
- lcd.print("Falling 2014");
- delay(2000);
- }
- void loop()
- {
- myStepper.step(1);
- light=analogRead(A0);
- angle=(stepCount%2048)/5.625;
- Serial.print(angle);
- Serial.print(" , ");
- Serial.println(light);
- lcd.clear();
- lcd.print("Angle : ");
- lcd.print(angle);
- lcd.print(" ");
- lcd.setCursor(0,1);
- lcd.print("Light : ");
- lcd.print(light);
- lcd.print(" ");
- stepCount++;
- delay(50);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement