From eec3414364a778d9a50dffefc7e1d51bd08c8de5 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 21 Apr 2016 08:33:16 -0400 Subject: [PATCH] Add basic endstop code to projector_test --- ino/mcopy_light_tests/mcopy_light_tests.ino | 2 +- .../mcopy_projector_tests.ino | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ino/mcopy_light_tests/mcopy_light_tests.ino b/ino/mcopy_light_tests/mcopy_light_tests.ino index 39adefc..97818f7 100644 --- a/ino/mcopy_light_tests/mcopy_light_tests.ino +++ b/ino/mcopy_light_tests/mcopy_light_tests.ino @@ -95,5 +95,5 @@ void colorString () { b = strB.toInt(); light.setPixelColor(0, r, g, b); - light.show(); + light.show(); } diff --git a/ino/mcopy_projector_tests/mcopy_projector_tests.ino b/ino/mcopy_projector_tests/mcopy_projector_tests.ino index ad138e6..4bfb014 100644 --- a/ino/mcopy_projector_tests/mcopy_projector_tests.ino +++ b/ino/mcopy_projector_tests/mcopy_projector_tests.ino @@ -1,4 +1,5 @@ //Test lighting with NeoPixels instead of Pixies to prevent eye damage. + //LIGHT HEADERS //#include "SoftwareSerial.h" //#include "Adafruit_Pixie.h" @@ -12,6 +13,9 @@ Adafruit_NeoPixel light = Adafruit_NeoPixel(1, PIXELPIN, NEO_GRB + NEO_KHZ800); //PROJECTOR HEADERS +boolean debug_state = false; + +//LIGHT VARIABLES String color = "000,000,000"; volatile int commaR = 0; @@ -25,15 +29,12 @@ volatile int r = 0; volatile int g = 0; volatile int b = 0; -boolean debug_state = false; - +//PROJECTOR VARIABLES //const int proj_pin = 5; //relay 4 //const int proj_time = {{proj.time}}; //const int proj_delay = {{proj.delay}}; +const int proj_endstop_pin = 4; -//LIGHT VARIABLES - -//PROJECTOR VARIABLES boolean proj_dir = true; const char cmd_light = 'l'; @@ -56,6 +57,8 @@ void setup() { light.begin(); light.setPixelColor(0, 0, 0, 0); light.show(); + + pinMode(proj_endstop_pin, INPUT); } void loop() { @@ -67,6 +70,12 @@ void loop() { cmd(cmd_char); cmd_char = 'z'; } + if (digitalRead(proj_endstop_pin)) { + Serial.println("blocked."); + } else { + Serial.println("open."); + } + delay(500); } void cmd (char val) {