Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int tx = 2;
- void setup()
- {
- pinMode(tx,OUTPUT);
- }
- //1=0.5µs 2=1µs 3=35µs
- void wait(int code){
- if(code==1){
- delayMicroseconds(500);
- }
- if(code==2){
- delayMicroseconds(1000);
- }
- if(code==3){
- delayMicroseconds(5000);
- }
- }
- void fire(int i)
- {
- digitalWrite(tx,i);
- }
- void i()
- {
- fire(1);
- wait(1);
- fire(0);
- wait(2);
- fire(1);
- wait(1);
- fire(0);
- wait(2);
- }
- void o()//3µs
- {
- fire(1);
- wait(1);
- fire(0);
- wait(2);
- fire(1);
- wait(2);
- fire(0);
- wait(1);
- }
- void sync()
- {
- fire(1);
- wait(1);
- fire(0);
- wait(3);
- }
- void transmit(int one, int two, int three, int four, int five, String c,int on)
- {
- if(one==1){ i(); }else{ o(); }
- if(two==1){ i(); }else{ o(); }
- if(three==1){ i(); }else{ o(); }
- if(four==1){ i(); }else{ o(); }
- if(five==1){ i(); }else{ o(); }
- if(c == "a"){ i(); }else{ o(); }
- if(c == "b"){ i(); }else{ o(); }
- if(c == "c"){ i(); }else{ o(); }
- if(c == "d"){ i(); }else{ o(); }
- if(c == "e"){ i(); }else{ o(); }
- if(on==1){ i(); o(); sync(); }else{ o(); i(); sync(); }
- }
- void snd(int one, int two, int three, int four, int five, String c,int on)
- {
- transmit(one,two,three,four,five,c,on);
- transmit(one,two,three,four,five,c,on);
- transmit(one,two,three,four,five,c,on);
- transmit(one,two,three,four,five,c,on);
- }
- int index;
- String chr;
- int onx;
- void loop()
- {
- index = index + 1;
- if(index==1){ chr="a"; }
- if(index==2){ chr="b"; }
- if(index==3){ chr="c"; }
- if(index==4){ chr="d"; }
- if(index==5){ chr="e"; }
- if(index>=6){ index=1; chr="a"; onx=!onx; }
- snd(1,0,0,0,0,chr,onx);
- delay(5);
- snd(0,0,0,0,0,chr,onx);
- delay(5);
- snd(0,1,0,0,0,chr,onx);
- delay(5);
- snd(0,0,1,0,0,chr,onx);
- delay(5);
- snd(0,0,0,1,0,chr,onx);
- delay(5);
- snd(0,0,0,0,1,chr,onx);
- delay(5);
- snd(1,0,0,0,1,chr,onx);
- delay(5);
- snd(1,0,1,0,1,chr,onx);
- delay(5);
- snd(0,1,0,1,0,chr,onx);
- delay(5);
- snd(1,1,1,0,0,chr,onx);
- delay(5);
- snd(0,0,1,1,1,chr,onx);
- delay(5);
- snd(1,1,0,1,1,chr,onx);
- delay(5);
- snd(0,1,1,1,0,chr,onx);
- delay(5);
- snd(1,0,0,0,0,chr,onx);
- delay(5);
- snd(1,1,0,1,0,chr,onx);
- delay(5);
- snd(1,0,1,1,0,chr,onx);
- delay(5);
- snd(1,0,0,1,1,chr,onx);
- delay(5);
- snd(0,1,1,0,0,chr,onx);
- delay(5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement