DS18B20 Arduino Example
DS18B20 is 1-Wire digital temperature sensor from Maxim IC. Reports degrees in Celsius from -55 to 125 ( /-0.5). Each
Read moreDS18B20 is 1-Wire digital temperature sensor from Maxim IC. Reports degrees in Celsius from -55 to 125 ( /-0.5). Each
Read moreA Hall effect sensor is a device that is used to measure the magnitude
Read moreThis article shows how to use the SSD1306 0.96 inch I2C OLED display with the Arduino. We’ll show you some
Read moreLibrary: Receiver:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
/* https://forbiddenbit.com/arduino-tutorial/rf433-mhz-and-arduino/ Receiver: Arduino: Module 433Mhz Rx: - GND GND - 5V VCC - D3 Data */ #define D4 4 #define D5 5 #include <VirtualWire.h> byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message int value = 0; void setup() { Serial.begin(9600); pinMode(D4, OUTPUT); pinMode(D5, OUTPUT); Serial.println("Ready..."); vw_set_rx_pin(3); // pin vw_setup(2000); // bps vw_rx_start(); } void loop() { if (vw_get_message(message, &messageLength)) // { for (int i = 0; i < messageLength; i++) { value = message[i]; } Serial.println(value); if (value == 0) { digitalWrite(D4, HIGH); digitalWrite(D5, LOW); } else if (value == 2) { digitalWrite(D4, LOW); digitalWrite(D5, HIGH); } else if (value == 4) { digitalWrite(D4, HIGH); digitalWrite(D5, HIGH); } Serial.println(value); } } |
Transmitter:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
/* https://forbiddenbit.com/arduino-tutorial/rf433-mhz-and-arduino/ Transmitter: Arduino: Module 433Mhz Tx: - GND GND - 5V VCC - D3 Data */ #include <VirtualWire.h> #define size 1 int pot = A3; byte TX_buffer[size]={0}; byte i; int value; void setup() { Serial.begin(9600); pinMode(4, INPUT_PULLUP); pinMode(5, INPUT_PULLUP); // virtual wire vw_set_tx_pin(3); // pin vw_setup(2000); // bps for(i=0;i<size;i++) { TX_buffer[i]=i; } } void loop() { if (digitalRead(4) == LOW){value=2;} else if (digitalRead(5) == LOW){value=4;} else {value=0;} Serial.println(value); int val = value; TX_buffer[0] = val; vw_send(TX_buffer, size); vw_wait_tx(); delay(10); } |
Receiver:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
/* * ForbiddenBit.com * * IR Receiver */ #include <IRremote.h> int RECV_PIN = 3; IRrecv irrecv(RECV_PIN); decode_results results; void setup() { Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver pinMode(5,OUTPUT); // Led outputs ... pinMode(6,OUTPUT); } void loop() { if (irrecv.decode(&results)) { Serial.println(results.value); if(results.value == 881415973) { digitalWrite(5,HIGH); digitalWrite(6,HIGH); } else if(results.value == 1451704665) { digitalWrite(5,LOW); digitalWrite(6,HIGH); } else if(results.value == 1699117091 ) { digitalWrite(5,HIGH); digitalWrite(6,LOW); } irrecv.resume(); // Receive the next value } delay(100); } |
Transmitter:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
/* * ForbiddenBit.com * * IR Transmitter */ #include <IRremote.h> IRsend irsend; void setup() { Serial.begin(9600); pinMode(5,INPUT_PULLUP); // button 1 pinMode(6,INPUT_PULLUP); // button 2 } void loop() { if (digitalRead(5) == LOW){ irsend.sendNEC(0x34895725, 32); delay(30); } else if (digitalRead(6) == LOW){ irsend.sendNEC(0x56874159, 32); delay(30); } else{ irsend.sendNEC(0x65467823, 32); delay(30); } delay(1); } |