Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //==============================================================================
- #include <RCSwitch.h>
- //Instacia a Biblioteca
- RCSwitch mySwitch = RCSwitch();
- //Conexao 1 (IN1) do motor 1 (M1) = 1N1M1
- int led=13;
- int valor1 = 1;
- void setup() {
- //Seta os Pinos dos Motores como Saida
- pinMode(led,OUTPUT);
- Serial.begin(9600);
- // delay para estabilizacao do Sinal
- ///////delay(500);
- delay(50);
- //Seta como Receptor/ O "0" é para não interromper, deixar continuo
- //O Pino padrão é o 2
- mySwitch.enableReceive(0);
- }
- void loop() {
- //Quado estiver sinal disponivel
- if (mySwitch.available()){
- //recebe na variavel value o Status
- long int value = mySwitch.getReceivedValue();
- if (value == 0) {
- Serial.println("Codigo desconhecido");
- }
- //==============================================================================
- if (value == 5635843)
- { //Comparaçao de códigos do botão CH+ do controle remoto
- if (valor1 == 1)
- {
- liga_1(); //Chamada da função liga_1
- valor1=0;
- }
- else
- {
- desl_1(); //Chamada da função desl_1
- valor1=1;
- }
- void liga_1(){ //função ligar led
- digitalWrite(led, HIGH);
- }
- void desl_1(){ //função desliga o led
- digitalWrite(led, LOW);
- }
- mySwitch.resetAvailable();
- }
- }
- //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement