© 2024 EasyEDA Some rights reserved ISO/IEC
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
1.Brand new interactions and interfaces
2.Smooth support for design sizes of over 5,000 devices or 10,000 pads
3.More rigorous design constraints, more standardized processes
4.For enterprises, more professional users
STD DIY Receiver 3 Channel
Mode: Editors' pick
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); }
ID | Name | Designator | Footprint | Quantity |
---|---|---|---|---|
1 | 100uF | C1 | CAP-TH_BD6.3-P2.50-D1.0-FD | 1 |
2 | CH1 STEERING | H1 | HDR-TH_3P-P2.54-V-M | 1 |
3 | CH2 ESC | H2 | HDR-TH_3P-P2.54-V-M | 1 |
4 | CH3 SERVO | H3 | HDR-TH_3P-P2.54-V-M | 1 |
5 | OPTIONAL INPUT | H4 | HDR-TH_2P-P2.54-V-M-1 | 1 |
6 | ARDUINO NANO 3.0 | M1 | ARDUINO-NANO-3.0 | 1 |
7 | NFR24L01+ | M2 | NRF24L01+SMA | 1 |
Unfold
Loading...
Do you need to add this project to the album?