Arduino Programming
Programming the Arduino will be done on an already owned PC with the stock Arduino IDE. The Arduino sketch will need to provide the following tasks:
- Servo Rudder
- Take PWM info in via RC RX
- ESC Motor Driver
- Variable Thrust
- Lighting (NeoPixel Effects)
Show Arduino Code
// Libraries for Program B
#include <FastLED.h>
// Program A variables
const int CH5_PIN = 2; // Channel receiver pin
const int CH6_PIN = 3; // New channel receiver pin
const int LIGHT_PIN = 4; // Lightbulb pin
// Program B variables
#define NUM_LEDS 30 // Number of LEDs on the strip
#define DATA_PIN 5 // Data pin of the LED strip
#define LED_PIN 5 // !! DATA_PIN = LED_PIN !! LED STRIP
#define NUM_COLORS 4 // Number of colors in the ocean gradient
CRGB leds[NUM_LEDS]; // Array to store the LED colors
// Define the ocean color palette
CRGBPalette16 oceanPalette = CRGBPalette16(
CRGB(0, 0, 255), // dark blue
CRGB(0, 92, 200), // medium blue
CRGB(0, 255, 255), // cyan
CRGB(0, 0, 255) // dark blue
);
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Set pins as input/output
pinMode(CH5_PIN, INPUT);
pinMode(LIGHT_PIN, OUTPUT);
pinMode(CH6_PIN, INPUT);
// Initialize FastLED library
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(100); // Set brightness to maximum
}
void loop() {
// Read channel receiver input
int CH5 = pulseIn(CH5_PIN, HIGH);
int CH6 = pulseIn(CH6_PIN, HIGH);
// Check channel input range for lightbulb
if (CH5 >= 900 && CH5 <= 1100) {
digitalWrite(LIGHT_PIN, HIGH); // Turn on lightbulb
// Check channel input range for LED strip
if (CH6 >= 900 && CH6 <= 1100) {
static uint8_t hue = 0;
uint8_t index = 0;
// Fill the LED array with colors from the ocean palette
for (int i = 0; i < NUM_LEDS / 2; i++) {
index = map(i, 0, NUM_LEDS / 2 - 1, 0, NUM_COLORS * 256 - 1);
leds[NUM_LEDS / 2 - i - 1] = leds[NUM_LEDS / 2 + i] = ColorFromPalette(oceanPalette, index + hue);
}
// Increment the hue to create the moving gradient effect
hue -= 5;
// Show the LED colors
FastLED.show();
} else if (CH6 >= 1400 && CH6 <= 1600) {
// Do nothing for now
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::White;
}
// Show the LED colors
FastLED.show();
Serial.println("CH6 SW2");
} else if (CH6 >= 1900 && CH6 <= 2100) {
// Do nothing for now
FastLED.clear(true);
Serial.println("CH6 SW3");
} else {
// Display error message if CH6 is not recognized
digitalWrite(LED_PIN, LOW); // Turn off LED strip
delay(500);
digitalWrite(LED_PIN, HIGH); // Turn on LED strip
delay(500);
Serial.println("LED Strip data error: check channel and pin connection");
}
} else if (CH5 >= 1900 && CH5 <= 2000) {
digitalWrite(LIGHT_PIN, LOW); // Turn off lightbulb
FastLED.clear(true); // Turn off LED strip
} else {
digitalWrite(LIGHT_PIN, LOW); // Turn off lightbulb
delay(500); // Wait for half a second
digitalWrite(LIGHT_PIN, HIGH); // Turn on lightbulb
delay(500); // Wait for half a second
Serial.println("LED Strip data error: check channel and pin connection");
}
// Print channel receiver inputs to serial monitor
Serial.print("CH5: ");
Serial.print(CH5);
Serial.print("\tCH6: ");
Serial.println(CH6);
// Wait for a brief period before reading again
delay(100);
}
User Experience
What would it look like to use the rover as a user?
The rover will be able to operate wirelessly through a radio RC that is similar to a FPV drone controller. Both the velocity and direction of the rover can be altered, as well as toggling the onboard LED lights for better visibility and visual appeal at nighttime. More details for the RC can be viewed in the linked website, but otherwise it has around 500m of range. Additionally, the user will also be able to view the rover as a first-person perspective with the onboard GoPro streaming RTMP to the Raspberry Pi on a monitor (already owned).
Real Life Applications
In terms of applications, this rover has a wide range of potential uses. It could be used in search and rescue operations, where it could access areas that are difficult or impossible for human rescuers to reach, such as flooded areas or swamps. For example, follwing the semi-recent event of the Thailand cave rescue mission where few cave divers were stranded in an enlosed cave, this rover could be used to converse with the stranded divers and giving them support given further development of the rover such as full-body waterproofing. Additionally, the rover could be used in scientific research, such as for collecting water samples or monitoring aquatic habitats. The rover could also be used in the field of exploration, such as inspecting and traversing hard to reach areas like underground caves, rocky terrains, or else remote island.
Budget
Product | Supplier/Link | Cost |
---|---|---|
Ardunino Mega | Mega has more pinouts for ease of use | $45.76 |
RPi SD Card | For RC controller and WIFI RC comms | $17.94 |
Motor | 1000KV Underwater Brushless Motor | $13.35 |
Brushless Driver | 1pcs FVT LITTLEBEE BLlheli SPRING 30A | $5.72 |
Power Distribute | Power Distribution Board with BEC 12V | $2.38 |
Battery Pack | 1500mah 120C RC Battery (Li-Po) | $31.34 |
RC Transmitter | FlySky 6CH Radio Transmitter+ Reciever | $66.35 |
Waterproof Servo | 25KG Digital Servo Full Metal Gear | $11.75 |
LiPo Charger | Multi-Function LIPO Balance Charger | $20.36 |
WiFi Extender | For extending GoPro video feed to RC | $13.50 |
LiPo Indicator | LiPo Voltage Indicator LED Display | $1.67 |
LED Decorations | WS2812b Serial Adressable LED Strips | $7.18 |
Casing +Filament | Estimated cost for 3D Printing1 | $11.44 |
Total before tax | BEFORE Tax + Delivery Fees | $237.30 |
Delivery Fees | Shopee: $1.26 Per Item x12 items = | $15.12 |
TOTAL COST | $263.86 |
Thank you so much to everyone at the HackClub and the community for this amazing opportunity!
(I don’t have a 3D Printer so I will have to rent) Prices are converted from MYR to USD from Google.. Please allow +- few dollars differ ↩