Stap 2: Verzenden van Arduino: de Code.
Deze tutorial maakt gebruik van versie 1.20 (downloaden verbinding: http://www.airspayce.com/mikem/arduino/) elke versie compatibel moet zijn.
Op de top van de schets vragen:
#include <VirtualWire.h> //include the required library
In de setup functie zetten:
void setup() { //Begin the serial connection Serial.begin(9600); while(!Serial); //Wait till serial connection is ready Serial.println("Serial ready"); //Debugging //Initialize the IO and ISR vw_setup(2000); // Bits per sec }
Deze code initialiseert gewoon de seriële verbinding en virtuele draad.
De Loop-functie moet er zo uitzien:
void loop() { //If serial input is available if(Serial.available()) { char input = Serial.read(); //Read input send(&input); //Send input via RF transmitter } else { } }
Dit een input karakter leest en verzendt dit naar de functie verzenden.
Tot slot moet de functie verzenden worden gemaakt om er als volgt uitzien:
void send (char *message) { vw_send((uint8_t *)message, strlen(message)); //Send the message vw_wait_tx(); // Wait until the whole message is gone }
De verzenden-functie neemt een teken en wordt verzonden met behulp van de virtuele draad bibliotheek.
Dit is alles wat nodig voor de verzendende Arduino.
U kunt de volledige sketch downloaden vanaf hier: https://dl.dropboxusercontent.com/u/63127140/Simpl...