Greetings every one
I wrote the two manchester encoding and decoding codes bellow. I tested them suing two ARDUINOs and they both worked for DC. I used simple 8 switches to feed the inputs of the transmitting arduino and fed the 8 outputs of the receivng arduino to LEDs and it worked great. However, in my project I need to transmit audio signal which I already converted it to 8-bit . My question is how to controll the frequancy of the transmission and receiving. by the way, this is my first time I have ever used arduino in any of my projects.
[#include <Manchester.h>
/*
Manchester Transmitter example
In this example transmitter will send one 16 bit number per transmittion
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 4 //pin where your transmitter is connected
#define D0 5
#define D1 6
#define D2 7
#define D3 8
#define D4 9
#define D5 10
#define D6 11
#define D7 12
int a = 0;
int a0 = 0;
int a1 = 0;
int a2 = 0;
int a3 = 0;
int a4 = 0;
int a5 = 0;
int a6 = 0;
int a7 = 0;
void setup() {
pinMode(D0, INPUT);
pinMode(D1, INPUT);
pinMode(D2, INPUT);
pinMode(D3, INPUT);
pinMode(D4, INPUT);
pinMode(D5, INPUT);
pinMode(D6, INPUT);
pinMode(D7, INPUT);
man.workAround1MhzTinyCore(); //add this in order for transmitter to work with 1Mhz Attiny85/84
man.setupTransmit(TX_PIN, 1);
}
void loop() {
a0=digitalRead(D0);
a1=digitalRead(D1);
a2=digitalRead(D2);
a3=digitalRead(D3);
a4=digitalRead(D4);
a5=digitalRead(D5);
a6=digitalRead(D6);
a7=digitalRead(D7);
a=a0+2*a1+4*a2+8*a3+16*a4+32*a5+64*a6+128*a7;
man.transmit(a);
}]
manchester_receiver.ino (2 KB)
manchester_transmitter.ino (1.27 KB)