Last active
December 15, 2015 19:18
-
-
Save remisarrailh/5309911 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Test de conversion d'un integer en binaire puis en onde radio sur Arduino | |
//Chiffre vers 4bits, cette méthode permet de ne pas avoir à occuper de l'espace et le microcontrolleur | |
//pour la conversion du code radio (le compilateur va s'en charger) | |
const String code0 = "0000"; | |
const String code1 = "0001"; | |
const String code2 = "0010"; | |
const String code3 = "0011"; | |
const String code4 = "0100"; | |
const String code5 = "0101"; | |
const String code6 = "0110"; | |
const String code7 = "0110"; | |
const String code8 = "1000"; | |
const String code9 = "1001"; | |
const String code10 = "1010"; | |
const String code11 = "1011"; | |
const String code12 = "1100"; | |
const String code13 = "1101"; | |
const String code14 = "1110"; | |
const String code15 = "1111"; | |
const String coderadio = code13; | |
void setup() | |
{ | |
//Initalise la communication série | |
Serial.begin(9600); | |
Serial.println("Connexion Etabli"); | |
//Envoi code radio | |
envoi_codeRadio(coderadio); | |
} | |
void loop() | |
{ | |
} | |
//Conversion du code Radio du binaire en ondes radio | |
void envoi_codeRadio(String coderadio) | |
{ | |
for(int x = 0; x < 4;x++){ | |
if (coderadio[x] == 49) | |
{ | |
sendPair(true); | |
} | |
else | |
{ | |
sendPair(false); | |
} | |
} | |
} | |
//Simulation de la fonction sendPair | |
void sendPair(boolean b) | |
{ | |
if(b) | |
Serial.print("1"); | |
else | |
{ | |
Serial.print("0"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment