Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int rfPin = A0;
- const int rfTransmitPin = 4;
- int led = 13;
- int inty;
- bool rf_on=true;
- bool rf_print=true;
- float sensorValue=0;
- int RF=0;
- String RF_Sinal="0";
- int RF_play=false;
- int RF_c=2;
- bool RF_led=false;
- int delayRF=1;
- void setup() {
- Serial.begin(250000);
- pinMode(led,OUTPUT);
- pinMode(rfTransmitPin, OUTPUT);
- }
- void loop() {
- sensorValue= analogRead(rfPin);
- //Serial.print("Voltage output = ");
- //Serial.println(sensorValue*5/1023);
- if(rf_on){
- RF=(sensorValue*5/1023);
- RF_Sinal=(RF_Sinal+String(RF));
- Serial.println(RF_Sinal);
- //delay(50);
- }
- if(RF_Sinal.length()==100 & rf_on){
- //Serial.print("Characers:");
- //Serial.print(String(RF_Sinal[2])+String(RF_Sinal[3])+String(RF_Sinal[4]));
- rf_on=false;
- RF_play=true;
- Serial.println("");
- Serial.println("RF = "+RF_Sinal);
- Serial.println("INIT...");
- }
- if(RF_play){
- //digitalWrite(led, HIGH);
- Serial.println(delayRF);
- if(RF_c <= 100){
- //Serial.println("<=100");
- //Serial.println(RF_c+" = "+RF_Sinal[3]);
- //Serial.println(RF_Sinal[RF_c]);
- //digitalWrite(rfTransmitPin, HIGH);
- if(String(RF_Sinal[RF_c])=="2" or String(RF_Sinal[RF_c])=="1"){
- Serial.println("RF_Sinal ON");
- digitalWrite(rfTransmitPin, HIGH);
- //digitalWrite(led, HIGH);
- delay(delayRF);
- RF_c++;
- }if(String(RF_Sinal[RF_c])=="0"){
- Serial.println("RF_Sinal OFF");
- digitalWrite(rfTransmitPin, LOW);
- //digitalWrite(led, LOW);
- delay(delayRF);
- RF_c++;
- }else{
- RF_c=2;
- delayRF++;
- }
- }
- }
- if(rfTransmitPin==HIGH){
- digitalWrite(led, HIGH);
- }else{
- digitalWrite(led, LOW);
- }
- if (sensorValue > 1000){
- inty++;
- }else{
- inty=0;
- }
- if(inty >= 4){
- //digitalWrite(led,HIGH);
- }else{
- //digitalWrite(led,LOW);
- }/*
- if(RF==2){
- digitalWrite(rfTransmitPin, HIGH);
- }else{
- digitalWrite(rfTransmitPin, LOW);
- }*/
- //delay(50);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement