tecnologia:proyectos:atril
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tecnologia:proyectos:atril [2022/12/28 19:07] – admin | tecnologia:proyectos:atril [2022/12/29 03:56] (current) – admin | ||
|---|---|---|---|
| Line 36: | Line 36: | ||
| String serverPath = " | String serverPath = " | ||
| String payload =""; | String payload =""; | ||
| + | |||
| + | int pinCoin = 15; // pin de la Arduino donde conectamos la salida COIN del detector de monedas | ||
| + | int lectura = 0; // variable para almacenar lo que leemos del pin COIN | ||
| + | |||
| void setup() { | void setup() { | ||
| Line 64: | Line 68: | ||
| server.on("/", | server.on("/", | ||
| - | request-> | + | request-> |
| }); | }); | ||
| | | ||
| Line 91: | Line 95: | ||
| } | } | ||
| + | pinMode(pinCoin, | ||
| } | } | ||
| void loop() { | void loop() { | ||
| + | |||
| + | lectura = digitalRead(pinCoin); | ||
| + | Serial.println(lectura); | ||
| + | if (lectura==1) | ||
| + | mensaje(); | ||
| + | else // si no | ||
| + | delay(50); | ||
| + | | ||
| + | } | ||
| + | |||
| + | |||
| + | void mensaje(){ | ||
| + | | ||
| HTTPClient http; | HTTPClient http; | ||
| | | ||
| Line 110: | Line 128: | ||
| Serial.println(payload.length()); | Serial.println(payload.length()); | ||
| int largo = payload.length(); | int largo = payload.length(); | ||
| - | String cadena = payload.substring(largo-1); | + | String cadena = payload.substring(0,largo-1); |
| - | | + | |
| - | // | + | // |
| Display.displayClear(); | Display.displayClear(); | ||
| - | Display.displayScroll(payload.c_str(), PA_CENTER, PA_SCROLL_LEFT, | + | Display.displayScroll(cadena.c_str(), PA_CENTER, PA_SCROLL_LEFT, |
| while (true) { | while (true) { | ||
| if (Display.displayAnimate()) { | if (Display.displayAnimate()) { | ||
| Line 122: | Line 140: | ||
| } | } | ||
| - | Display.setTextAlignment(PA_LEFT); | + | |
| - | delay(1000); | + | |
| } | } | ||
| else { | else { | ||
| Line 131: | Line 148: | ||
| // Free resources | // Free resources | ||
| http.end(); | http.end(); | ||
| - | Display.print(payload); | ||
| - | delay(1000); | ||
| - | |||
| - | Display.displayClear(); | ||
| - | Display.print(" | ||
| - | delay(1000); | ||
| } | } | ||
| </ | </ | ||
tecnologia/proyectos/atril.1672254430.txt.gz · Last modified: by admin
