You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

5 years ago
  1. /*
  2. Blink
  3. The basic Energia example.
  4. Turns on an LED on for one second, then off for one second, repeatedly.
  5. Change the LED define to blink other LEDs.
  6. Hardware Required:
  7. * LaunchPad with an LED
  8. This example code is in the public domain.
  9. */
  10. // most launchpads have a red LED
  11. //#define LED RED_LED
  12. //see pins_energia.h for more LED definitions
  13. #define LED GREEN_LED
  14. #define DUSTSENSORPIN 1
  15. // the setup routine runs once when you press reset:
  16. void setup() {
  17. // initialize the digital pin as an output.
  18. pinMode(LED, OUTPUT);
  19. pinMode(DUSTSENSORPIN, INPUT);
  20. Serial.begin(4800);
  21. }
  22. // the loop routine runs over and over again forever:
  23. void loop() {
  24. Serial.println("test");
  25. digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
  26. delay(1000); // wait for a second
  27. digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
  28. delay(1000); // wait for a second
  29. int DustSensorState = digitalRead(DUSTSENSORPIN);
  30. Serial.print("Sensor reads:");
  31. Serial.println(DustSensorState);
  32. }