Advertisement
belrey10

[KY-008] Laser

Nov 12th, 2024
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * inventr.io 37 in 1 Sensor Kit (https://learn.inventr.io/product/37-in-1-sensor-kit/)
  3.  * Sensor Course (https://learn.inventr.io/course/sensor-training/)
  4.  *
  5.  * Lesson - [KY-008] LASER
  6.  *
  7.  * The KY-008 is a laser transmitter module commonly used in DIY electronics
  8.  * projects such as robots or home automation systems. It operates at a
  9.  * wavelength of 650 nm and produces a red laser beam that can be used as a
  10.  * sensor or an indicator. The module can be easily connected to a microcontroller,
  11.  * such as an Arduino, and controlled with a few lines of code.
  12.  *
  13.  * Code contributions:
  14.  *    David Schmidt (davids@inventr.io)
  15.  */
  16.  
  17. /* This project just needs a Digital pin.
  18.  * On the Hero (Arduino Uno compatible) we *could* use: D0-D13, A0-A5.
  19.  * Skip: A0-A5 (save for Analog),
  20.  *       D0/D1 (used by USB),
  21.  *       D2/D3 (save for interrupts),
  22.  *       D13 (used by LED_BUILTIN and SPI Clock),
  23.  *       D5, D6, D9, D10 and D11 (save for PWM)
  24.  *       D11 (SPI MOSI)
  25.  *       D12 (SPI MISO)
  26.  * Recommended for fewest conflicts:
  27.  *    D4, D7 or D8
  28.  */
  29. const int KY_008_PIN = 4;
  30.  
  31. void setup() {
  32.   pinMode(KY_008_PIN, OUTPUT);  // define the digital output interface 13 feet
  33. }
  34.  
  35. void loop() {
  36.   digitalWrite(KY_008_PIN, HIGH);  // turn on LASER
  37.   delay(1000);                     // delay one second
  38.   digitalWrite(KY_008_PIN, LOW);   // turn off LASER
  39.   delay(1000);                     // delay one second
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement