Pic Micro, Arduino, Atmel, Microchip, Freescale, Texas Instrument, ecc. Strumenti di sviluppo, firmware e progetti.
Avatar utente
da FrancoGual
#4648
Salve, una domanda al volo
Arduino nano e ricevitore 433 MHz, con il seguente sketch
Codice: Seleziona tutto/*
  Simple example for receiving
 
  https://github.com/sui77/rc-switch/
*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(0);  // Receiver on interrupt 0 => that is pin #2
}

void loop() {
  if (mySwitch.available()) {
   
    int value = mySwitch.getReceivedValue();
   
    if (value == 0) {
      Serial.print("Unknown encoding");
    } else {
      Serial.print("Received ");
      Serial.print( mySwitch.getReceivedValue() );
      Serial.print(" / ");
      Serial.print( mySwitch.getReceivedBitlength() );
      Serial.print("bit ");
      Serial.print("Protocol: ");
      Serial.println( mySwitch.getReceivedProtocol() );
    }

    mySwitch.resetAvailable();
  }
}

Ricevo reiolarmente i dati dal telecomando, cercavo una riga di codice per attivare una o più uscite a seconda del tasto premuto.
Ho un dato decimale o binario
Tutti i vari sketch che trovo in rete fanno tutto quello che a me non serve, ripetono, traducono, attivano via web ma un'uscita del cacchio no.
Grazie
Avatar utente
da GioRock
#4649
Allora,

prima di tutto devi impostare nella funzione setup i pin che userai come uscita:

Codice: Seleziona tuttopinMode(NUMBER, OUTPUT);


poi devi aggiungere delle istruzioni condizionali che discrimineranno il valore ricevuto, in seguito potrai attivare le uscite così:

Codice: Seleziona tuttodigitalWrite(PINNUMBER, HIGH/LOW);
Avatar utente
da FrancoGual
#4650
Grazie, comincia a danneggiare il codice. :D :D
Tanto alla fine c'è sempre quello originale hehehehe
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Visita il nostro canale telegram