Ameya Angadi
Published © GPL3+

Photon Drive — Intelligent IoT-Based Solar Car

A solar-powered, IoT-enabled hybrid car built using Pico W with Bluetooth control, smart lights & custom laser-cut chassis.

IntermediateFull instructions provided6 hours81
Photon Drive — Intelligent IoT-Based Solar Car

Things used in this project

Hardware components

Raspberry Pi Pico W
Raspberry Pi Pico W
×1
SparkFun Motor Driver - Dual TB6612FNG (1A)
SparkFun Motor Driver - Dual TB6612FNG (1A)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
DC Motor, 12 V
DC Motor, 12 V
×1
3mm white LED
×2
3mm red LED
×6
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×1
Slide Switch
Slide Switch
×2
JST Jumper Bundle for the BeagleBone Blue
Renaissance Robotics JST Jumper Bundle for the BeagleBone Blue
×5
Solar panel (6V, ~1W)
×1
Acrylic sheet
×1
Wires
×1
Resistor 220 ohm
Resistor 220 ohm
×4
USB Type-C TP4056 charging module
×1
JLCPCB Custom PCB
×1

Software apps and online services

Arduino IDE
Arduino IDE
JLCPCB
KiCad
KiCad
RD Works

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Custom parts and enclosures

Photon Link App

Use this file to install Photon Link App

Car Chassis

Use this file to laser cut the acrylic sheet

PCB Gerber Files

Use this file for manufacturing the PCB

Schematics

Circuit Diagram

Use this circuit diagram to assemble the car

Code

Intelligent IoT Based Solar Car

Arduino
Upload this code
/*
* Project Name: Photon Drive – Intelligent IoT Based Solar Car
* Designed For: Raspberry Pi Pico W
*
* License: GPL3+
* This project is licensed under the GNU General Public License v3.0 or later.
* You are free to use, modify, and distribute this software under the terms
* of the GPL, as long as you preserve the original license and credit the original
* author. For more details, see <https://www.gnu.org/licenses/gpl-3.0.en.html>.
*
* Copyright (C) 2025 Ameya Angadi
*
* Code Created And Maintained By: Ameya Angadi
* Last Modified On: July 20, 2025
* Version: 1.0.0
*
*/


#include <SerialBT.h>
#include <Servo.h>


// ---------- Pin Configuration ----------
const int HeadLight = 0;
const int BrakeLight = 1;
const int LeftLight = 2;
const int RightLight = 3;


const int STBY = 17;
const int PWMA = 18;
const int AIN1 = 19;
const int AIN2 = 20;


const int SERVO_PIN = 9;


// ---------- Servo Angles ----------
// Change these values according to your needs
const int LeftServoAngle = 120;
const int RightServoAngle = 60;
const int CenterServoAngle = 90;

Servo Servo;


// ---------- Caution Light Blink Handling ----------
bool cautionBlinking = false;
bool cautionLightState = false;
unsigned long lastBlinkTime = 0;
const unsigned long blinkInterval = 400;


void setup() {
Serial.begin(115200);

SerialBT.setName("Photon Drive Car"); // Name of the bluetooth car
SerialBT.begin();

// Attach Servo
Servo.attach(SERVO_PIN, 500, 2500);
Servo.write(CenterServoAngle); // Set the servo to center position

// Initialize output pins
pinMode(HeadLight, OUTPUT);
pinMode(BrakeLight, OUTPUT);
pinMode(LeftLight, OUTPUT);
pinMode(RightLight, OUTPUT);

pinMode(AIN1, OUTPUT);
pinMode(AIN2, OUTPUT);
pinMode(PWMA, OUTPUT);
pinMode(STBY, OUTPUT);

digitalWrite(STBY, HIGH);
digitalWrite(LED_BUILTIN, HIGH); // Status LED to show that the car is turned on
}


void loop() {


// ---------- Bluetooth Input Handling ----------
while (SerialBT.available()) {
char input = char(SerialBT.read());

if (input == 'H') {
digitalWrite(HeadLight, HIGH);
}

else if (input == 'h') {
digitalWrite(HeadLight, LOW);
}

else if (input == 'F') {
moveForward();
}

else if (input == 'B') {
moveBackward();
}

else if (input == 'L') {
turnLeft();
}

else if (input == 'R') {
turnRight();
}

else if (input == '1') {
moveLeftForward();
}

else if (input == '2') {
moveRightForward();
}

else if (input == '3') {
moveLeftBackward();
}

else if (input == '4') {
moveRightBackward();
}

else if (input == 'S') {
stopCar();
}

else if (input == 'C') {
cautionBlinking = true;
}

else if (input == 'c') {
cautionBlinking = false;
digitalWrite(LeftLight, LOW);
digitalWrite(RightLight, LOW);
}
}


// ---------- Caution Blinking Logic ----------
if (cautionBlinking && millis() - lastBlinkTime >= blinkInterval) {
lastBlinkTime = millis();
cautionLightState = !cautionLightState;
digitalWrite(LeftLight, cautionLightState);
digitalWrite(RightLight, cautionLightState);
}
}


// ---------- Movement & Light Control Functions ----------


void moveForward() { // Function to move the car Forward
digitalWrite(AIN1, HIGH);
digitalWrite(AIN2, LOW);
analogWrite(PWMA, 200);

Servo.write(CenterServoAngle);
turnOffAllLights();
}

void moveBackward() { // Function to move the car Backward
digitalWrite(AIN1, LOW);
digitalWrite(AIN2, HIGH);
analogWrite(PWMA, 200);

Servo.write(CenterServoAngle);
digitalWrite(BrakeLight, HIGH);
digitalWrite(LeftLight, LOW);
digitalWrite(RightLight, LOW);
}

void turnLeft() { // Function to turn the car Left
digitalWrite(BrakeLight, LOW);
digitalWrite(LeftLight, HIGH);
digitalWrite(RightLight, LOW);
Servo.write(LeftServoAngle);
}

void turnRight() { // Function to turn the car Right
digitalWrite(BrakeLight, LOW);
digitalWrite(LeftLight, LOW);
digitalWrite(RightLight, HIGH);
Servo.write(RightServoAngle);
}

void moveLeftForward() { // Function to move the car Left-Forward
digitalWrite(AIN1, HIGH);
digitalWrite(AIN2, LOW);
analogWrite(PWMA, 150);

Servo.write(LeftServoAngle);
digitalWrite(LeftLight, HIGH);
digitalWrite(RightLight, LOW);
digitalWrite(BrakeLight, LOW);
}

void moveRightForward() { // Function to move the car Right-Forward
digitalWrite(AIN1, HIGH);
digitalWrite(AIN2, LOW);
analogWrite(PWMA, 150);

Servo.write(RightServoAngle);
digitalWrite(LeftLight, LOW);
digitalWrite(RightLight, HIGH);
digitalWrite(BrakeLight, LOW);
}

void moveLeftBackward() { // Function to move the car Left-Backward
digitalWrite(AIN1, LOW);
digitalWrite(AIN2, HIGH);
analogWrite(PWMA, 150);

Servo.write(LeftServoAngle);
digitalWrite(LeftLight, HIGH);
digitalWrite(RightLight, LOW);
digitalWrite(BrakeLight, HIGH);
}

void moveRightBackward() { // Function to move the car Right-Backward
digitalWrite(AIN1, LOW);
digitalWrite(AIN2, HIGH);
analogWrite(PWMA, 150);

Servo.write(RightServoAngle);
digitalWrite(LeftLight, LOW);
digitalWrite(RightLight, HIGH);
digitalWrite(BrakeLight, HIGH);
}

void stopCar() { // Function to stop the car
digitalWrite(AIN1, LOW);
digitalWrite(AIN2, LOW);
analogWrite(PWMA, 0);

Servo.write(CenterServoAngle);
turnOffAllLights();
}

void turnOffAllLights() { // Function to turn off all the lights
digitalWrite(BrakeLight, LOW);
digitalWrite(LeftLight, LOW);
digitalWrite(RightLight, LOW);
}

Credits

Ameya Angadi
10 projects • 7 followers

Comments