Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Gabriel Rodriguez
Published © GPL3+

Solar Charging DSTR Robot

This is a solar tracking charging system for the DSTR robot. Sponsored by Texas Instruments and Texas A&M.

IntermediateShowcase (no instructions)Over 1 day1,064
Solar Charging DSTR Robot

Things used in this project

Hardware components

MSP-EXP430FR5969 MSP430 FRAM LaunchPad
Texas Instruments MSP-EXP430FR5969 MSP430 FRAM LaunchPad
×1

Software apps and online services

Energia
Texas Instruments Energia
Fusion
Autodesk Fusion

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Schematics

Original Schematic

This is the original circuit schematic.

Code

Solar Tracking Code

Arduino
This code is uploaded to the MSP430 Launchpad to calculate the correct position for the solar panels and to move the panels to that position.
#include <Servo.h>

//Creates servo objects to control servos
Servo HorizontalServo;
Servo VerticalServo;

//Creates variables to store servo positions
int HorizontalServoPosition = 0;
int VerticalServoPosition = 0;
 
//Photo-resistors assigned pins
const int PR1 = A3;
const int PR2 = A4;
const int PR3 = A5;
const int PR4 = A12;

void setup() {
 //Attaches servos to pins
 HorizontalServo.attach(7);
 VerticalServo.attach(8);
}

void loop() {
 //Averages photoresistors on rows and columns and assigns them to variables
 int Row1 = ((analogRead(PR1) + analogRead(PR2)) / 2);
 int Row2 = ((analogRead(PR3) + analogRead(PR4)) / 2);
 int Col1 = ((analogRead(PR1) + analogRead(PR3)) / 2);
 int Col2 = ((analogRead(PR2) + analogRead(PR4)) / 2);
 
 if((Row1) < Row2){
  VerticalServoPosition++;
  VerticalServo.write(VerticalServoPosition);
  delay(5);
 }
 if((Row2) < Row1){
  VerticalServoPosition--;
  VerticalServo.write(VerticalServoPosition);
  delay(5);
 }
 if((Col1) < Col2){
  if(HorizontalServoPosition < 180){
    HorizontalServoPosition++;
    HorizontalServo.write(HorizontalServoPosition);
    delay(50);
  }
 }
 if((Col2) < Col1){
  if(HorizontalServoPosition > 0){
    HorizontalServoPosition --;
    HorizontalServo.write(HorizontalServoPosition);
    delay(50);
  }
 }
}

Credits

Gabriel Rodriguez
1 project • 1 follower
Thanks to Ross Baldridge and Forrest Hartman.

Comments