Stap 3: Zender en ontvanger Code
Dit is de test zender code die ik gebruikt:
#include <manchester.h>/*Manchester Transmitter example In this example transmitter will send one 16 bit number per transmission try different speeds using this constants, your maximum possible speed will depend on various factors like transmitter type, distance, microcontroller speed, ... MAN_300 0 MAN_600 1 MAN_1200 2 MAN_2400 3 MAN_4800 4 MAN_9600 5 MAN_19200 6 MAN_38400 7*/#define TX_PIN 0 //pin where your transmitter is connecteduint16_t transmit_data = 2761; void setup() { man.setupTransmit(TX_PIN, MAN_1200); } void loop() { man.transmit(transmit_data); delay(200); }
Dit is de test ontvanger code die ik gebruikt:
#include <manchester.h>/*Manchester Receiver example In this example receiver will receive one 16 bit number per transmittionTry different speeds using this constants, your maximum possible speed will depend on various factors like transmitter type, distance, microcontroller speed, ... MAN_300 0 MAN_600 1 MAN_1200 2 MAN_2400 3 MAN_4800 4 MAN_9600 5 MAN_19200 6 MAN_38400 7*/#define RX_PIN 7void setup() { Serial.begin(9600); man.setupReceive(RX_PIN, MAN_1200); man.beginReceive(); } void loop() { if (man.receiveComplete()) { uint16_t m = man.getMessage(); Serial.println(m); man.beginReceive(); //start listening for next message right after you retrieve the message } }