Nano + NRF20L01 + 2 Potentiometer + 2 led

i need help ,

clear

232 / 5.000

Resultados de tradução

Resultado da tradução

I have transmission between the two nanos, but when adjusting potentiometer1 or potentiometer2, on the transmitter the PWM value goes from 0 to 255 correctly, but on the receiver, the values appear and disappear and mix input 1 with input 2

my code for transmit

// By Victor Marques Transmissor
#include <nRF24L01.h>
#include <RF24.h>
#include<SPI.h>
RF24 radio(9,10);
const byte address[6] = "00033";
#define pot1 A0
#define pot2 A7
const int threshold1 = 20;
int potValue1 = 0;
int pwmValue1 = 0;
int check1 = 0;
const int threshold2 = 20;
int potValue2 = 0;
int pwmValue2 = 0;
int check2 = 0;
char input1[32] = "";
char input2[32] = "";
const char var1[32] = "";
const char var2[32] = "";
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setChannel(100);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MAX);
radio.stopListening();
}
void loop()
{
potValue1 = analogRead(pot1);
if(potValue1 > check1 + threshold1 || potValue1 < check1 - threshold1)
radio.write(&var1, sizeof(var1));
pwmValue1 = map(potValue1, 0, 1023, 0, 255);
radio.write(&pwmValue1, sizeof(pwmValue1));
check1 = potValue1;
potValue2 = analogRead(pot2);
if(potValue2 > check2 + threshold2 || potValue2 < check2 - threshold2)
radio.write(&var2, sizeof(var2));
pwmValue2 = map(potValue2, 0, 1023, 0, 255);
radio.write(&pwmValue2, sizeof(pwmValue2));
check2 = potValue2;
Serial.println("INPUT:1");
Serial.print("PWM Value1:");
Serial.println(pwmValue1);
Serial.print("Voltage Level1:");
Serial.println(potValue1);
Serial.println("----------------------------------");
Serial.println("INPUT:2");
Serial.print("PWM Value2:");
Serial.println(pwmValue2);
Serial.print("Voltage Level2:");
Serial.println(potValue2);
Serial.println("----------------------------------");
}

my code for reception

// By Victor Marques Receptor
#include <nRF24L01.h>
#include <RF24.h>
#include<SPI.h>
RF24 radio(9,10);
const byte address[6] = "00033";
int led = 5;
int pwmValue1 = 0;
int led1 = 6;
int pwmValue2 = 0;
char input1[32] = "";
const char var1[32] = "";
char input2[32] = "";
const char var2[32] = "";
void setup()
{
pinMode(led,OUTPUT);
pinMode(led1,OUTPUT);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setChannel(100);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MAX);
radio.startListening();
}
void loop()
{
delay(1);
while(!radio.available());
radio.read(&input1, sizeof(input1));
if((strcmp(input1,var1) == 0))
while(!radio.available());
radio.read(&pwmValue1, sizeof(pwmValue1));
analogWrite(led,pwmValue1);
while(!radio.available());
radio.read(&input2, sizeof(input2));
if((strcmp(input2,var2) == 0))
while(!radio.available());
radio.read(&pwmValue2, sizeof(pwmValue2));
analogWrite(led1,pwmValue2);
Serial.println(input1);
Serial.print("PWM Value1:");
Serial.println(pwmValue1);
Serial.println("--------------------------------");
Serial.println(input2);
Serial.print("PWM Value2:");
Serial.println(pwmValue2);
Serial.println("--------------------------------");
}

Good Luck, without following forum guidelines and using code tags you code is just a bunch of gibberish. Your annotated schematic showing how this is interconnected did not upload or is missing.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.