Hello,
First time project is almost complete.! After 6 month, a few burned out hbridges, late nights, hours on forums, my DC motor is under my control! ]
HAHA! "kinda"
I am using a Arduino Micro with a, Sparkfun L298 Hbridge motor shield. I have a photocell and one LM35s with a DS18B.
Everthing works, but the Arduino get very hot!! I have tried almost ever wire unplugged, tried disconnecting 12v power, tried switching limit switches to the motor directional pin instead of the CSB pin on motor shield. STILL HOTT ]
I have copied my code, in hopes that someone can take a look at it. Can having the pin high all the time make it hot? I have the limit switches on the CSB enable voltage pin. So, when the gate reaches it's destination and trips the switch it breaks the 11 and 12 pin, but they stay high in the code. Can that make the board hot? Also, when I run code for just the LM 35 temp sensor the reading is very consistent, but when I run it in my code it fluctuates almost 9 degrees.
thank you in advance for your time!!
xian
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 6 on the Arduino
#define ONE_WIRE_BUS 6
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// These constants won't change:
float tempC;
int tempPin = 1; // temp sensor is plugged into analog pin 1 LM35
int fan = 5; // led is connected to pin 13
int analogPin = A0; // to photocell on 0
int ledPin = 13; // pin that the LED is attached to
int threshold = 30; // an arbitrary threshold level that's in the range of the analog input
int motoru = 10; // pin 10 motor up
int motord = 9; // pin 9 motor down
int motorenable = 8;//enable motor
int voltagedown = 11; //CSB pin on uk1122 shield
int voltageup = 12; //CSB pin on uk1122 shield
int ledopen = 3; //LED red
int ledclose = 2; //LED green
void setup() {
// initialize the LED pin as an output
Serial.begin(9600); // start serial port
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
pinMode(motorenable, OUTPUT);
pinMode(motoru, OUTPUT); // set motor up pin 10 to up position
pinMode(motord, OUTPUT); // set motor down pin 9 to down position
pinMode(voltageup, OUTPUT);
pinMode(voltagedown, OUTPUT); //led down red
pinMode(ledopen, OUTPUT); //led down red
pinMode(ledclose, OUTPUT); //led down red
pinMode(fan, OUTPUT); // turn on fan
// initialize serial communications:
Serial.begin(9600);
}
void loop() {
tempC = analogRead(tempPin);
tempC = (5.0*tempC*100.0)/1024.0; // will convert analog input into temp
//Serial.println((byte)tempC);
// read the value of the Photocell:
int analogValue = analogRead(analogPin);
// open door
// if the analog value is high enough, turn on the LED:
if (analogValue > threshold) {
digitalWrite(voltageup, HIGH); // voltage from motor shield
digitalWrite (motorenable, HIGH); //enable
digitalWrite (motoru, HIGH); //motor up
digitalWrite (motord, LOW); // pin 9 low
digitalWrite (ledopen,HIGH); // red led on
digitalWrite (ledclose,LOW); // off
Serial.print("DANGER__Coop Door is OPEN "); //print
}
else {
// Close door
digitalWrite(voltageup,LOW); //voltage
digitalWrite (motorenable, HIGH); //enable
digitalWrite (motoru, LOW); // pin 9 low
digitalWrite (motord, HIGH); //pin 10 high motor down
digitalWrite(voltagedown, HIGH);
digitalWrite (ledopen, LOW); //led off
digitalWrite (ledclose,HIGH);// green led on closed
Serial.println("GOODNIGHT Door is CLOSED ");
delay(1000);
}
if (tempC>60)
{
digitalWrite(fan, HIGH); //turn fan on
}
else
{
digitalWrite(fan, LOW);
}
delay(1000);
// print the analog value:
Serial.println(" Coop ");
Serial.print("TempC... ");
Serial.println((byte)tempC);
Serial.print("Light...");
Serial.println(analogValue);
delay(1000); // delay in between reads for stability
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print("SUGARHOUSE SYSTEM REQUEST...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
Serial.print("Control Box Temp (index 0) is: ");
Serial.println(sensors.getTempCByIndex(0));
}
moderatore: please add code tags, ==> # button above smileys.
