© 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 Transmitter 3 Channel
Mode:
Transmitter Code:
// 3 Channel Transmitter #include <SPI.h> #include <nRF24L01.h> #include <RF24.h> const uint64_t pipeOut = 0xE9E8F0F0E1LL; // Match key RF24 radio(9, 10); // Select CE,CSN pin struct Signal { byte throttle; byte steering; byte aux1; }; Signal data; void ResetData() { data.throttle = 127; // Motor stop (Signal lost position) data.steering = 127; // Center (Signal lost position) data.aux1 = 0; // (Signal lost position) } void setup() { //Start everything up radio.begin(); radio.openWritingPipe(pipeOut); radio.setAutoAck(false); radio.setDataRate(RF24_250KBPS); radio.setPALevel(RF24_PA_MAX); radio.stopListening(); //start the radio comunication for Receiver ResetData(); } // Joystick center and it's borders int mapJoystickValues(int val, int lower, int middle, int upper, bool reverse) { val = constrain(val, lower, upper); if ( val < middle ) val = map(val, lower, middle, 0, 128); else val = map(val, middle, upper, 128, 255); return ( reverse ? 255 - val : val ); } void loop() { // Control Stick Calibration // Setting may be required for the correct values of the control levers. data.steering = mapJoystickValues( analogRead(A0), 200, 460, 650, true ); // "true" or "false" for servo direction data.throttle = mapJoystickValues( analogRead(A1), 200, 440,670, true ); // "true" or "false" for signal direction data.aux1 = digitalRead(4); radio.write(&data, sizeof(Signal)); }
Loading...
Do you need to add this project to the album?