Advertisement
Guest User

FCM#97 - Asteroid Sim.

a guest
May 15th, 2015
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <LiquidCrystal_I2C.h>
  3. // Set the LCD address to 0x27 for a 16 chars and 2 lines display
  4. LiquidCrystal_I2C lcd(0x27, 16, 2);
  5. #include <Stepper.h>
  6. const int stepsPerRevolution = 200;
  7. // initialize the stepper library on pins 8 through 11:
  8. Stepper myStepper(stepsPerRevolution, 8,9,10,11);
  9. int stepCount = 0; // number of steps the motor has taken
  10. int light=0;
  11. float angle=0.;
  12. void setup()
  13. {
  14. Serial.begin(9600);
  15. lcd.begin();
  16. lcd.backlight();
  17. lcd.print("** Asteroids **");
  18. delay(2000);
  19. lcd.clear();
  20. lcd.print("E. Barres School");
  21. lcd.setCursor(0,1);
  22. lcd.print("Falling 2014");
  23. delay(2000);
  24. }
  25. void loop()
  26. {
  27. myStepper.step(1);
  28. light=analogRead(A0);
  29. angle=(stepCount%2048)/5.625;
  30. Serial.print(angle);
  31. Serial.print(" , ");
  32. Serial.println(light);
  33.  
  34. lcd.clear();
  35. lcd.print("Angle : ");
  36. lcd.print(angle);
  37. lcd.print(" ");
  38. lcd.setCursor(0,1);
  39. lcd.print("Light : ");
  40. lcd.print(light);
  41. lcd.print(" ");
  42. stepCount++;
  43. delay(50);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement