Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h"
- #define FASTLED_ALLOW_INTERRUPTS 0
- #define LED_TYPE WS2812
- #define COLOR_ORDER GRB
- #define NUM_LEDS 8
- #define NUM_STRIPS 4
- #define Front_SX controllers[0]
- #define Rear_SX controllers[1]
- #define Front_DX controllers[2]
- #define Rear_DX controllers[3]
- //#define giallo CRGB(48,235,0)
- #define giallo CRGB::Orange
- #define rosso CRGB::Red
- #define bianco CRGB::White
- #define viola CRGB::Purple
- #define blu CRGB::CadetBlue
- #define spenti CRGB::Black
- #define blu CRGB(0,0,255)
- #define A spenti
- #define B rosso
- #define C bianco
- #define D viola
- CRGBPalette16 currentPalette;
- CRGBPalette16 currentPalette2;
- CRGBPalette16 PaletteFreccia;
- CRGB leds[NUM_LEDS];
- CRGB ledsFSX[NUM_LEDS];
- CRGB ledsRSX[NUM_LEDS];
- CRGB ledsFDX[NUM_LEDS];
- CRGB ledsRDX[NUM_LEDS];
- CLEDController *controllers[NUM_STRIPS];
- void setupStripedPalette()
- {
- //currentPalette = CRGBPalette16(B, B, B, B, A, A, A, A, A, B, B, A, A, A, A, A);
- currentPalette = CRGBPalette16(C, C, C, C, A, A, A, A, A, B, B, A, A, A, A, A);
- currentPalette2 = CRGBPalette16(B, B, B, B, A, A, A, A, A, C, C, A, A, A, A, A);
- PaletteFreccia = CRGBPalette16(D, D, D, D, D, D, D, D, D, D, A, A, A, A, A, A);
- //currentPalette2 = CRGBPalette16(C, C, C, C, C, C, C, C, A, A, A, A, A, A, A, A);
- }
- // varibili di test
- int zz = 0;
- int kk = 0;
- // fine variabili di test
- int const INPUT_SX = 2; //ingresso freccia destra
- int const INPUT_DX = 3; //ingresso freccia sinistra
- int const INPUT_STOP = 4; //ingresso stop
- int const INPUT_NO_FLOW = 5; //ingresso dipswitch (se "on" le frecce lampeggiano tutte insieme)
- int const INPUT_NO_STOP = 6; //ingresso dipswitch (se "on" le frecce non funzionano da stop)
- int const INPUT_NO_POS = 7; //ingresso dipswitch (se "on) le frecce non funzionano da luci di posizione)
- int const INPUT_STROBO = 8; //ingresso dipswitch (se "on" viene abilitato l'effetto strobo sull'emergenza)
- int const INPUT_ANIMAZIONE = 9; //ingresso dipswitch (se "on" viene abilitata l'animazione all'avvio)
- int const INPUT_DRL = 10; //ingresso dipswitch (se "on" aumenta del doppio la luminosità delle luci di posizione)
- int const INPUT_FADE = 11; //ingresso dipswitch (se "on" abilita l'effetto fade delle frecce solo tutte insieme)
- int const INPUT_RES = 12; //ingresso di riserva
- int const Freccia_FDX = 14;
- int const Freccia_RDX = 15;
- int const Freccia_FSX = 16;
- int const Freccia_RSX = 17;
- int STATO_SX = 0;
- int STATO_DX = 0;
- int STATO_STOP = 0;
- int STATO_NO_FLOW = 0;
- int STATO_NO_STOP = 0;
- int STATO_NO_POS = 0;
- int STATO_STROBO = 0;
- int STATO_ANIMAZIONE = 0;
- int STATO_DRL = 0;
- int STATO_FADE = 0;
- int STATO_RES = 0;
- int LUM_POS = 30;
- int const LUM_MAX = 255;
- int LUM_TEMP = 0;
- int LUM_POS_F = LUM_POS;
- int LUM_FADE = 0;
- int LAMP = 200;
- int LampON = 250;
- int LampOFF = 250;
- int Speed20 = 20;
- int Speed16 = 16;
- int adj = 150;
- int SX = 0;
- int DX = 0;
- int STATO_POS = 1;
- int strb = 0;
- int flw = 1;
- int brk = 0;
- int fade = 0;
- int lum = 0;
- int startIndex = 210;
- String CondizioniStringa = "0000";
- String CondizioniStringaTEMP = "0000";
- int i_DX = 0;
- int i_SX = 0;
- float ValRitardo = 0;
- int ValRitardoSpeed = 16;
- int ValRitardoLampON = LampON;
- int ValRitardoLampOFF = LampOFF;
- int BreakFor = 0;
- void setup() {
- Serial.begin(9600);
- pinMode(INPUT_SX, INPUT); //aziona freccia sinistra
- pinMode(INPUT_DX, INPUT); //aziona freccia destra
- pinMode(INPUT_STOP, INPUT); //aziona le luci posteriori in alta luminosità (stop)
- pinMode(INPUT_NO_FLOW, INPUT); //disabilita l'effetto flow delle frecce
- pinMode(INPUT_NO_STOP, INPUT); //disabilita lo stop
- pinMode(INPUT_NO_POS, INPUT); //disabilita le luci di posizione
- pinMode(INPUT_STROBO, INPUT); //abilita l'effetto strobo nelle luci di emergenza
- pinMode(INPUT_ANIMAZIONE, INPUT); //abilita l'animazione all'accensione
- pinMode(INPUT_DRL, INPUT); //aumenta la luminosità delle luci di posizione anteriori
- pinMode(INPUT_FADE, INPUT); //abilita l'effetto "incandescenza" delle frecce (no sulle flow)
- pinMode(Freccia_FDX, OUTPUT); //pin uscita freccia anteriore destra
- pinMode(Freccia_RDX, OUTPUT); //pin uscita freccia posteriore destra
- pinMode(Freccia_FSX, OUTPUT); //pin uscita freccia anteriore sinistra
- pinMode(Freccia_RSX, OUTPUT);//pin uscita freccia posteriore sinistra
- Front_DX = &FastLED.addLeds<LED_TYPE, Freccia_FDX, COLOR_ORDER>(ledsFDX, NUM_LEDS).setCorrection(TypicalLEDStrip);
- Rear_DX = &FastLED.addLeds<LED_TYPE, Freccia_RDX, COLOR_ORDER>(ledsRDX, NUM_LEDS).setCorrection(TypicalLEDStrip);
- Front_SX = &FastLED.addLeds<LED_TYPE, Freccia_FSX, COLOR_ORDER>(ledsFSX, NUM_LEDS).setCorrection(TypicalLEDStrip);
- Rear_SX = &FastLED.addLeds<LED_TYPE, Freccia_RSX, COLOR_ORDER>(ledsRSX, NUM_LEDS).setCorrection(TypicalLEDStrip);
- STATO_NO_FLOW = digitalRead(INPUT_NO_FLOW);
- STATO_NO_STOP = digitalRead(INPUT_NO_STOP);
- STATO_NO_POS = digitalRead(INPUT_NO_POS);
- STATO_STROBO = digitalRead(INPUT_STROBO);
- STATO_ANIMAZIONE = digitalRead(INPUT_ANIMAZIONE);
- STATO_DRL = digitalRead(INPUT_DRL);
- STATO_FADE = digitalRead(INPUT_FADE);
- STATO_RES = digitalRead(INPUT_RES);
- if (STATO_STROBO == HIGH) { //attivazione effetto strobo su emergenza
- strb = 1;
- }
- setupStripedPalette();
- static uint8_t startIndex = 0;
- if (STATO_NO_POS == HIGH) { //luci di posizione non attive
- STATO_POS = 0;
- LUM_POS = 0;
- LUM_POS_F = 0;
- }
- if (STATO_DRL == HIGH && STATO_NO_POS == LOW) { //luci posizione anteriore più intense (DRL)
- LUM_POS_F = 150;
- }
- if (STATO_ANIMAZIONE == HIGH) { //animazione iniziale
- LUM_TEMP = LUM_MAX;
- animazione();
- }
- if (STATO_NO_FLOW == HIGH) { //animazione flowing delle frecce non attiva
- flw = 0;
- }
- if (STATO_FADE == HIGH) { //effetto "incandescenza" attivo
- fade = 1;
- }
- }
- void posizione_no_fade() { //accende le luci di posizione senza effetto fading o le tiene spente
- //se STATO_NO_POS == HIGH spegnere i led
- if (STATO_NO_POS == HIGH) {
- spento();
- }
- else {
- FRONT(LUM_POS_F, bianco);
- REAR(LUM_POS, rosso);
- }
- }
- void posizione_fade() { //accende le luci di posizione con effetto fading
- if (lum <= LUM_POS_F && STATO_NO_POS == LOW) {
- lum++;
- if (lum > LUM_POS) {
- REAR(LUM_POS, rosso);
- } else {
- REAR(lum, rosso);
- }
- FRONT(lum, bianco);
- delay(2);
- } else {
- posizione_no_fade();
- //spento();
- }
- }
- void animazione() {
- // noInterrupts();
- for (startIndex; startIndex > 0; startIndex = startIndex - 2) {
- //startIndex = startIndex + 4; /* higher = faster motion */
- delay(15);
- fill_palette( ledsFSX, NUM_LEDS,
- startIndex, 4, /* higher = narrower stripes */
- currentPalette, LUM_MAX, LINEARBLEND);
- fill_palette( ledsFDX, NUM_LEDS,
- startIndex, 4, /* higher = narrower stripes */
- currentPalette, LUM_MAX, LINEARBLEND);
- fill_palette( ledsRSX, NUM_LEDS,
- startIndex, 4, /* higher = narrower stripes */
- currentPalette2, LUM_MAX, LINEARBLEND);
- fill_palette( ledsRDX, NUM_LEDS,
- startIndex, 4, /* higher = narrower stripes */
- currentPalette2, LUM_MAX, LINEARBLEND);
- FastLED.show();
- }
- static uint8_t startIndex = 0;
- //// Animazione base di fading
- // if (LUM_TEMP > LUM_POS && STATO_NO_POS == LOW) {
- // LUM_TEMP--;
- // if (LUM_TEMP > LUM_POS_F) {
- // FRONT(LUM_TEMP, bianco);
- // } else {
- // FRONT(LUM_POS_F, bianco);
- // }
- // REAR(LUM_TEMP, rosso);
- // delay(20);
- // }
- //// Fine animazione base di fading
- for (LUM_TEMP; LUM_TEMP >= LUM_POS; LUM_TEMP = LUM_TEMP - 1) {
- REAR(LUM_TEMP, rosso);
- if (LUM_TEMP > LUM_POS_F) {
- FRONT(LUM_TEMP, bianco);
- } else {
- FRONT(LUM_POS_F, bianco);
- }
- delay(1);
- }
- // for (LUM_TEMP; LUM_TEMP < LUM_POS; LUM_TEMP = LUM_TEMP + 1) {
- // REAR(LUM_TEMP, rosso);
- // FRONT(LUM_TEMP, bianco);
- // delay(10);
- // }
- }
- void FRONT (int LUM_F, CRGB(COLOR)) {
- fill_solid( ledsFSX, NUM_LEDS, COLOR);
- fill_solid( ledsFDX, NUM_LEDS, COLOR);
- Front_SX->showLeds(LUM_F);
- Front_DX->showLeds(LUM_F);
- }
- void REAR (int LUM_R, CRGB(COLOR)) {
- fill_solid( ledsRSX, NUM_LEDS, COLOR);
- fill_solid( ledsRDX, NUM_LEDS, COLOR);
- Rear_DX->showLeds(LUM_R);
- Rear_SX->showLeds(LUM_R);
- }
- void SINISTRA (int LUM_SX, CRGB(COLOR)) {
- fill_solid( ledsFSX, NUM_LEDS, COLOR);
- fill_solid( ledsRSX, NUM_LEDS, COLOR);
- Front_SX->showLeds(LUM_SX);
- Rear_SX->showLeds(LUM_SX);
- }
- void DESTRA (int LUM_DX, CRGB(COLOR)) {
- fill_solid( ledsFDX, NUM_LEDS, COLOR);
- fill_solid( ledsRDX, NUM_LEDS, COLOR);
- Front_DX->showLeds(LUM_DX);
- Rear_DX->showLeds(LUM_DX);
- }
- void spento() { //tutti i led spenti
- FRONT(0, spenti);
- REAR(0, spenti);
- Front_SX->showLeds(0);
- Front_DX->showLeds(0);
- Rear_DX->showLeds(0);
- Rear_SX->showLeds(0);
- }
- void STOP() {
- if (brk < NUM_LEDS) {
- fill_solid( &(ledsRSX[brk]), NUM_LEDS - brk, spenti);
- fill_solid( &(ledsRSX[0]), brk + 1, rosso);
- Rear_SX->showLeds(LUM_MAX);
- fill_solid( &(ledsRDX[brk]), NUM_LEDS - brk, spenti);
- fill_solid( &(ledsRDX[0]), brk + 1, rosso);
- Rear_DX->showLeds(LUM_MAX);
- delay(1);
- brk++;
- }
- }
- void Emergenza(int StrobeCount, int FlashDelay, int EndPause) {
- StrobeCount = StrobeCount * strb;
- FlashDelay = FlashDelay * strb;
- for (int j = 0; j < StrobeCount; j++) {
- FRONT(LUM_MAX, giallo);
- REAR(LUM_MAX, giallo);
- delay(FlashDelay);
- FRONT(0, spenti);
- REAR(0, spenti);
- delay(FlashDelay);
- }
- FRONT(LUM_MAX, giallo);
- REAR(LUM_MAX, giallo);
- delay((EndPause * 2) - (StrobeCount * FlashDelay));
- FRONT(0, spenti);
- REAR(0, spenti);
- delay(EndPause * 2);
- }
- void freccia_DX() {
- if (fade == 0) {
- LUM_FADE = LUM_MAX;
- }
- CondizioniStringaTEMP = CondizioniStringa;
- if (LUM_FADE < LUM_MAX) {
- DESTRA(LUM_FADE, giallo);
- LUM_FADE += 5;
- delay(2);
- if (CondizioniStringa.charAt(3) == char('1')) {
- fill_solid( &(ledsRSX[0]), NUM_LEDS, rosso);
- Rear_SX->showLeds(LUM_MAX);
- }
- } else if (LUM_FADE == LUM_MAX) {
- LeggiInput();
- DESTRA(LUM_MAX, giallo);
- LUM_FADE = 0;
- LeggiInput();
- for (ValRitardoLampON; ValRitardoLampON > 0; ValRitardoLampON--) {
- LeggiInput();
- if (CondizioniStringa.charAt(3) == char('1')) {
- fill_solid( &(ledsRSX[0]), NUM_LEDS, rosso);
- Rear_SX->showLeds(LUM_MAX);
- }
- if (CondizioniStringa.charAt(3) == char('0')) {
- Rear_SX->showLeds(LUM_POS);
- }
- if (CondizioniStringa.charAt(1) == char('0')) {
- break;
- }
- delay(1);
- } ValRitardoLampON = LampON;
- DESTRA(0, giallo);
- LeggiInput();
- for (ValRitardoLampOFF; ValRitardoLampOFF > 0; ValRitardoLampOFF--) {
- LeggiInput();
- if (CondizioniStringa.charAt(3) == char('1')) {
- fill_solid( &(ledsRSX[0]), NUM_LEDS, rosso);
- Rear_SX->showLeds(LUM_MAX);
- }
- if (CondizioniStringa.charAt(3) == char('0')) {
- Rear_SX->showLeds(LUM_POS);
- }
- if (CondizioniStringa.charAt(1) == char('0')) {
- break;
- }
- delay(1);
- } ValRitardoLampOFF = LampOFF;
- }
- }
- void freccia_SX() {
- }
- void freccia_SX_flow() {
- Serial.print(i_SX);
- fill_solid( &(ledsFSX[0]), NUM_LEDS, spenti);
- fill_solid( &(ledsRSX[0]), NUM_LEDS, spenti);
- CondizioniStringaTEMP = CondizioniStringa;
- if (i_SX < NUM_LEDS) {
- fill_solid( &(ledsFSX[0]), 1 + i_SX, giallo);
- fill_solid( &(ledsRSX[0]), 1 + i_SX, giallo);
- Front_SX->showLeds(LUM_MAX);
- Rear_SX->showLeds(LUM_MAX);
- i_SX++;
- for (ValRitardoSpeed; ValRitardoSpeed > 0; ValRitardoSpeed--) {
- Serial.print(CondizioniStringa);
- Serial.print(ValRitardoSpeed);
- LeggiInput();
- if (CondizioniStringa.charAt(3) == char('1')) {
- fill_solid( &(ledsRDX[0]), NUM_LEDS, rosso);
- Rear_DX->showLeds(LUM_MAX);
- }
- if (CondizioniStringa.charAt(3) == char('0')) {
- Rear_DX->showLeds(LUM_POS);
- }
- if (CondizioniStringa.charAt(1) == char('0')) {
- break;
- }
- delay(1);
- } ValRitardoSpeed = Speed16;
- }
- else if (i_SX == NUM_LEDS)
- {
- LeggiInput();
- for (ValRitardoLampON; ValRitardoLampON > 0; ValRitardoLampON--) {
- LeggiInput();
- if (CondizioniStringa.charAt(3) == char('1')) {
- fill_solid( &(ledsRDX[0]), NUM_LEDS, rosso);
- Rear_DX->showLeds(LUM_MAX);
- }
- if (CondizioniStringa.charAt(3) == char('0')) {
- Rear_DX->showLeds(LUM_POS);
- }
- if (CondizioniStringa.charAt(1) == char('0')) {
- break;
- }
- delay(1);
- } ValRitardoLampON = LampON;
- Front_SX->showLeds(0);
- Rear_SX->showLeds(0);
- LeggiInput();
- for (ValRitardoLampOFF; ValRitardoLampOFF > 0; ValRitardoLampOFF--) {
- LeggiInput();
- if (CondizioniStringa.charAt(3) == char('1')) {
- fill_solid( &(ledsRDX[0]), NUM_LEDS, rosso);
- Rear_DX->showLeds(LUM_MAX);
- }
- if (CondizioniStringa.charAt(3) == char('0')) {
- Rear_DX->showLeds(LUM_POS);
- }
- if (CondizioniStringa.charAt(1) == char('0')) {
- break;
- }
- delay(1);
- } ValRitardoLampOFF = LampOFF;
- i_SX = 0;
- Serial.print(CondizioniStringa);
- }
- }
- void freccia_DX_flow() {
- fill_solid( &(ledsFDX[0]), NUM_LEDS, spenti);
- fill_solid( &(ledsRDX[0]), NUM_LEDS, spenti);
- CondizioniStringaTEMP = CondizioniStringa;
- if (i_DX < NUM_LEDS) {
- fill_solid( &(ledsFDX[0]), 1 + i_DX, giallo);
- fill_solid( &(ledsRDX[0]), 1 + i_DX, giallo);
- Front_DX->showLeds(LUM_MAX);
- Rear_DX->showLeds(LUM_MAX);
- i_DX++;
- for (ValRitardoSpeed; ValRitardoSpeed > 0; ValRitardoSpeed--) {
- LeggiInput();
- if (CondizioniStringa.charAt(3) == char('1')) {
- fill_solid( &(ledsRSX[0]), NUM_LEDS, rosso);
- Rear_SX->showLeds(LUM_MAX);
- }
- if (CondizioniStringa.charAt(3) == char('0')) {
- Rear_SX->showLeds(LUM_POS);
- }
- if (CondizioniStringa.charAt(1) == char('0')) {
- break;
- }
- delay(1);
- } ValRitardoSpeed = Speed16;
- }
- else if (i_DX == NUM_LEDS)
- {
- LeggiInput();
- for (ValRitardoLampON; ValRitardoLampON > 0; ValRitardoLampON--) {
- LeggiInput();
- if (CondizioniStringa.charAt(3) == char('1')) {
- fill_solid( &(ledsRSX[0]), NUM_LEDS, rosso);
- Rear_SX->showLeds(LUM_MAX);
- }
- if (CondizioniStringa.charAt(3) == char('0')) {
- Rear_SX->showLeds(LUM_POS);
- }
- if (CondizioniStringa.charAt(1) == char('0')) {
- break;
- }
- delay(1);
- } ValRitardoLampON = LampON;
- Front_DX->showLeds(0);
- Rear_DX->showLeds(0);
- LeggiInput();
- for (ValRitardoLampOFF; ValRitardoLampOFF > 0; ValRitardoLampOFF--) {
- LeggiInput();
- if (CondizioniStringa.charAt(3) == char('1')) {
- fill_solid( &(ledsRSX[0]), NUM_LEDS, rosso);
- Rear_SX->showLeds(LUM_MAX);
- }
- if (CondizioniStringa.charAt(3) == char('0')) {
- Rear_SX->showLeds(LUM_POS);
- }
- if (CondizioniStringa.charAt(1) == char('0')) {
- break;
- }
- delay(1);
- } ValRitardoLampOFF = LampOFF;
- i_DX = 0;
- }
- }
- void loop() {
- LeggiInput();
- //TABELLA CONDIZIONI
- if (CondizioniStringa == String("0110") ||
- CondizioniStringa == String("0111") ||
- CondizioniStringa == String("1110") ||
- CondizioniStringa == String("1111")) { //EMERGENZA
- i_DX = 0;
- i_SX = 0;
- ValRitardo = 0;
- lum = 0;
- FRONT(0, spenti);
- REAR(0, spenti);
- delay(5);
- Emergenza(5, 20, LAMP);
- }
- if (CondizioniStringa == String("1000")) { //LUCI POSIZIONE ATTIVE
- ResetVariabili();
- posizione_fade();
- }
- if (CondizioniStringa == String("1001")) { //STOP con LUCI DI POSIZIONE
- FRONT(LUM_POS_F, bianco);
- REAR(LUM_MAX, rosso);
- //STOP();
- fill_solid( ledsFSX, NUM_LEDS, bianco);
- Front_SX->showLeds(LUM_POS_F);
- fill_solid( ledsRSX, NUM_LEDS, rosso);
- Rear_SX->showLeds(LUM_MAX);
- lum = LUM_POS_F;
- }
- if (CondizioniStringa == String("1100")) { //FRECCIA DESTRA con LUCI DI POSIZIONE
- lum = LUM_POS_F;
- if (flw == 0) {
- freccia_DX();
- } else {
- freccia_DX_flow();
- }
- fill_solid( ledsFSX, NUM_LEDS, bianco);
- Front_SX->showLeds(LUM_POS_F);
- fill_solid( ledsRSX, NUM_LEDS, rosso);
- Rear_SX->showLeds(LUM_POS);
- }
- if (CondizioniStringa == String("1010")) { //FRECCIA SINISTRA con LUCI DI POSIZIONE
- lum = LUM_POS_F;
- if (flw == 0) {
- freccia_SX();
- } else {
- freccia_SX_flow();
- }
- fill_solid( ledsFDX, NUM_LEDS, bianco);
- Front_DX->showLeds(LUM_POS_F);
- fill_solid( ledsRDX, NUM_LEDS, rosso);
- Rear_DX->showLeds(LUM_POS);
- }
- if (CondizioniStringa == String("1101")) { //FRECCIA DESTRA e STOP con LUCI DI POSIZIONE
- lum = LUM_POS_F;
- if (flw == 0) {
- freccia_DX();
- } else {
- freccia_DX_flow();
- }
- fill_solid( ledsFSX, NUM_LEDS, bianco);
- Front_SX->showLeds(LUM_POS_F);
- fill_solid( ledsRSX, NUM_LEDS, rosso);
- Rear_SX->showLeds(LUM_MAX);
- }
- if (CondizioniStringa == String("1011")) { //FRECCIA SINISTRA e STOP con LUCI DI POSIZIONE
- lum = LUM_POS_F;
- if (flw == 0) {
- freccia_SX();
- } else {
- freccia_SX_flow();
- }
- fill_solid( ledsFDX, NUM_LEDS, bianco);
- Front_DX->showLeds(LUM_POS_F);
- fill_solid( ledsRDX, NUM_LEDS, rosso);
- Rear_DX->showLeds(LUM_MAX);
- }
- if (CondizioniStringa == String("0000")) { //TUTTO SPENTO
- ResetVariabili();
- spento();
- }
- if (CondizioniStringa == String("0001")) { //STOP
- i_SX = 0;
- i_DX = 0;
- FRONT(0, bianco);
- REAR(LUM_MAX, rosso);
- //STOP();
- }
- if (CondizioniStringa == String("0100")) { //FRECCIA DESTRA
- Rear_SX->showLeds(LUM_POS);
- if (flw == 0) {
- freccia_DX();
- } else {
- freccia_DX_flow();
- }
- }
- if (CondizioniStringa == String("0010")) { //FRECCIA SINISTRA
- Rear_DX->showLeds(LUM_POS);
- if (flw == 0) {
- freccia_SX();
- } else {
- freccia_SX_flow();
- }
- }
- if (CondizioniStringa == String("0101")) { //FRECCIA DESTRA e STOP
- if (flw == 0) {
- freccia_DX();
- } else {
- freccia_DX_flow();
- }
- }
- if (CondizioniStringa == String("0011")) { //FRECCIA SINISTRA e STOP
- if (flw == 0) {
- freccia_SX();
- } else {
- freccia_SX_flow();
- }
- }
- //FINE TABELLA CONDIZIONI
- }
- void LeggiInput() {
- if (digitalRead(INPUT_SX) == HIGH) {
- STATO_SX = 1;
- } else if (digitalRead(INPUT_SX) == LOW) {
- STATO_SX = 0;
- }
- if (digitalRead(INPUT_DX) == HIGH) {
- STATO_DX = 1;
- } else if (digitalRead(INPUT_DX) == LOW) {
- STATO_DX = 0;
- }
- if (digitalRead(INPUT_STOP) == HIGH) {
- STATO_STOP = 1;
- } else if (digitalRead(INPUT_STOP) == LOW) {
- STATO_STOP = 0;
- }
- CondizioniStringa = String(String(STATO_POS) + String(STATO_DX) + String(STATO_SX) + String(STATO_STOP));
- }
- void ResetVariabili() {
- brk = 0;
- i_DX = 0;
- i_SX = 0;
- ValRitardo = 0;
- ValRitardoSpeed = 16;
- ValRitardoLampON = LampON;
- ValRitardoLampOFF = LampOFF;
- LUM_FADE = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement