Editor Version ×
Standard

1.Easy to use and quick to get started

2.The process supports design scales of 300 devices or 1000 pads

3.Supports simple circuit simulation

4.For students, teachers, creators

Profession

1.Brand new interactions and interfaces

2.Smooth support for design sizes of over 30,000 devices or 100,000 pads

3.More rigorous design constraints, more standardized processes

4.For enterprises, more professional users

Std EditionDIY Receiver 3 Channel

Profile:Receiver For Model Car 3 Channel. ESC, Steering, And Gearbox

License:

Published Time:2022-01-07 18:08:38
  • 145
  • 0
  • 0
Description

Receiver Code:

//  3 Channel Receiver
//  PWM output on pins D3, D5, D6

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>

int ch_width_1 = 0;
int ch_width_2 = 0;
int ch_width_3 = 0;

Servo ch1;
Servo ch2;
Servo ch3;

struct Signal {
byte throttle;      
byte steering;
byte aux1;

};

Signal data;

const uint64_t pipeIn = 0xE9E8F0F0E1LL;
RF24 radio(10, 9); 

void ResetData()
{
// Define the inicial value of each data input
// The middle position for Potenciometers
data.steering = 127;   // Center
data.throttle = 127;   // Motor Stop
data.aux1 = 0;         // Center
}

void setup()
{
  //Set the pins for each PWM signal
  ch1.attach(3);
  ch2.attach(5);
  ch3.attach(6);

  //Configure the NRF24 module
  ResetData();
  radio.begin();
  radio.openReadingPipe(1,pipeIn);
  radio.setAutoAck(false);
  radio.setDataRate(RF24_250KBPS);
  radio.setPALevel(RF24_PA_MAX);
  radio.startListening(); //start the radio comunication for receiver
}

unsigned long lastRecvTime = 0;

void recvData()
{
while ( radio.available() ) {
radio.read(&data, sizeof(Signal));
lastRecvTime = millis();   // receive the data
}
}
void loop()
{
recvData();
unsigned long now = millis();
if ( now - lastRecvTime > 1000 ) {
ResetData(); // Signal lost.. Reset data
}

ch_width_1 = map(data.steering, 0, 255, 1000, 2000);     // pin D3 (PWM signal)
ch_width_2 = map(data.throttle, 0, 255, 800, 2200);     // pin D5 (PWM signal)
ch_width_3 = map(data.aux1, 0, 1, 1000, 2000);           // pin D6 (PWM signal)

   // Write the PWM signal
ch1.writeMicroseconds(ch_width_1);
ch2.writeMicroseconds(ch_width_2);
ch3.writeMicroseconds(ch_width_3);
}
Documents

PCB_DIY Receiver For Model Car 3 Channel

Open in editor
Project Attachments
Empty
Project Members

服务时间

周一至周五 9:00~18:00
  • 0755 - 2382 4495
  • 153 6159 2675

服务时间

周一至周五 9:00~18:00
  • 立创EDA微信号

    easyeda

  • QQ交流群

    664186054

  • 立创EDA公众号

    lceda-cn