Team Members:
- Joseph Kopacz (Right)
- Justin Kopacz (Left)
Technical Details:
- Brake Regeneration
- Solar Augmented Battery
- Automatic Lights
- Station Detection
- DC motor with gearbox (298:1)
Pictures:
Mechanical Drawings:Detailed drawings available upon request
Arduino Source Code:
//Pin Setup
//Pin Setup
//Analog Pins:
int photoPin = 0;
int magnetPin = 1;
int batteryPin = 4;
//Mosfets:
int drivePin = 2;
int regenPin = 3;
int solarPin = 8;
//Lights:
int whitelightPin = 5;
int redlightPin = 6;
int bluelightPin = 7;
//Boundrys for analog pins:
int lightboundry = 500;
int magfieldboundry = 150;
double batteryboundry = 5.5;
void setup()
{
Serial.begin(9600);
pinMode(2,
OUTPUT);
pinMode(3,
OUTPUT);
pinMode(5,
OUTPUT);
pinMode(6,
OUTPUT);
pinMode(7, OUTPUT);
pinMode(8,
OUTPUT);
}
void loop()
{
//Monitor where the train is based on the presence of
magnetic field
if (analogRead(magnetPin)
> magfieldboundry ) //if there is no magnetic field
{
digitalWrite(drivePin,
HIGH); //proceed
normally
digitalWrite(regenPin,
LOW); //do
not regenerate
delay(1000);
//test if there is a magnetic field 1 second
later
}
else
//if a magnetic field is detected
{
digitalWrite(redlightPin,
HIGH); //turn
on brake lights for effect
delay(3000);
//continue driving for 3 seconds to get away
from mag field
digitalWrite(drivePin,
LOW); //disable
power feed into motor
digitalWrite(regenPin,
HIGH); //enable
regeneration
delay(3000);
//pause for desired time at station – 3
seconds,
}
//Control the onboard lights based on the intensity of the
outside light
if (analogRead(photoPin)
< lightboundry) //if the light is dim enough
{
digitalWrite(redlightPin,
HIGH); //turn all lights on
digitalWrite(bluelightPin,
HIGH);
digitalWrite(whitelightPin,
HIGH);
delay(10);
//test intensity frequently
}
else
{
digitalWrite(redlightPin,
LOW);
//all lights
off if not satisfied
digitalWrite(bluelightPin,
LOW);
digitalWrite(whitelightPin,
LOW);
delay(10);
//test intensity frequently
}
//Controls the MOSFET based on the level of the battery
int sensorValue = analogRead(batteryPin);
//
if(voltage(sensorValue) <
batteryboundry) //if
the battery is not fully charged
{
digitalWrite(solarPin,
HIGH); //allow the solar
panel to charge
delay(1000); //test battery every 1 second
}
else
//if the battery is fully charged
{
digitalWrite(solarPin,
LOW); //protect
battery by stopping solar panel current
delay(1000); //test battery every 1 second
}
}
//Converts the analog input to a voltage level- 9 Is the
maximum voltage, 1020 is the maximum analog //value.
double voltage(int
analogIn)
{
double voltage = (analogIn/1020.)*9;
return voltage;
}
No comments:
Post a Comment