I have my desktop running windows 8 and have no problems uploading from it. I am trying to use my dads old laptop running windows xp for uploading and keep getting errors. One issue I run into is the IDE frequently cannot find the serial port, only COM1 and COM3 are shown. When it does find COM5 or 6 it only sometimes works. It uploaded blink fine, then I uploaded the same copy of code already on my uno and it said that uploaded fine (didn't change anything so I am not sure if the upload worked or if it simply restarted it). Then I tried to change a few values to see a difference and keep getting this error:
Binary sketch size: 12,986 bytes (of a 32,256 byte maximum)
processing.app.SerialException: Serial port 'COM5' already in use. Try quiting any programs that may be using it.
at processing.app.Serial.<init>(Serial.java:171)
at processing.app.Serial.<init>(Serial.java:77)
at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:77)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:175)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)
at processing.app.Sketch.upload(Sketch.java:1671)
at processing.app.Sketch.exportApplet(Sketch.java:1627)
at processing.app.Sketch.exportApplet(Sketch.java:1599)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)
at java.lang.Thread.run(Thread.java:619)
processing.app.debug.RunnerException: Serial port 'COM5' already in use. Try quiting any programs that may be using it.
at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:101)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:175)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)
at processing.app.Sketch.upload(Sketch.java:1671)
at processing.app.Sketch.exportApplet(Sketch.java:1627)
at processing.app.Sketch.exportApplet(Sketch.java:1599)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)
at java.lang.Thread.run(Thread.java:619)
I did not disconnect the uno in between uploads, I just changed some numbers in the sketch. Here is the code:
#include <Adafruit_PWMServoDriver.h>
#include <Wire.h>
#include "RTClib.h"
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include "DHT.h" //DHT library
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
int r = 500;
int b = 500;
int c = 1;
int w = 1;
int rstep = 1;
int bstep = 1;
int cstep = 1;
int wstep = 1;
int rday = 2000;
int bday = 1000;
int cday = 3000;
int wday = 4095;
int rnight = 10;
int bnight = 500;
int cnight = 0;
int wnight = 0;
DHT dht1; // define dht1 as a DHT
DHT dht2; // define dht2 as a DHT
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
int button = 1; //variable for buttons
int rain = 0;
RTC_DS1307 rtc;
void setup() {
Serial.begin(57600);
#ifdef AVR
Wire.begin();
#else
Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
rtc.begin();
lcd.begin(16, 2);
lcd.setBacklight(GREEN);
dht1.setup(7); // assign dht1 to pin 2
dht2.setup(8); // assign dht2 to pin 4
//outlet control
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
digitalWrite(2, HIGH);
digitalWrite(3, LOW); //pump on
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
pwm.begin();
pwm.setPWMFreq(1600); // This is the maximum PWM frequency
// save I2C bitrate
uint8_t twbrbackup = TWBR;
// must be changed after calling Wire.begin() (inside pwm.begin())
TWBR = 12; // upgrade to 400KHz!
}
uint8_t i=0;
void loop() {
DateTime now = rtc.now();
dht1.getMinimumSamplingPeriod();
float humidity = dht1.getHumidity();
float temperature = dht1.getTemperature();
//setup dht1
dht2.getMinimumSamplingPeriod();
float humidity2 = dht2.getHumidity();
float temperature2 = dht2.getTemperature();
//setup dht2
uint8_t buttons = lcd.readButtons();
// LED no longer fading, switch direction
if (now.hour() >= 8 && now.hour() < 9) {
pwm.setPWM(3, 0, c);
if (c < cday) {
c = c + cstep;
}
pwm.setPWM(0, 0, w);
if (w < wday) {
w = w + wstep;
}
pwm.setPWM(1, 0, b);
if (b < bday) {
b = b + bstep;
}
pwm.setPWM(2, 0, r);
if (r < rday) {
r = r + rstep;
}
delay(500);
}
if (now.hour() >= 9 && now.hour() < 21) {
pwm.setPWM(3, 0, c);
if (c < cday) {
c = c + cstep;
}
pwm.setPWM(0, 0, w);
if (w < wday) {
w = w + wstep;
}
pwm.setPWM(1, 0, b);
if (b < bday) {
b = b + bstep;
}
pwm.setPWM(2, 0, r);
if (r < rday) {
r = r + rstep;
}
delay(5);
digitalWrite(2, LOW);
}
if (now.hour() >= 21 && now.hour() < 22) {
pwm.setPWM(3, 0, c);
if (c > cnight) {
c = c - cstep;
}
pwm.setPWM(0, 0, w);
if (w > wnight) {
w = w - wstep;
}
pwm.setPWM(1, 0, b);
if (b > bnight) {
b = b - bstep;
}
pwm.setPWM(2, 0, r);
if (r > rnight) {
r = r - rstep;
}
delay(500);
digitalWrite(2, HIGH);
}
if (now.hour() >= 22 || now.hour() < 8) {
pwm.setPWM(3, 0, c);
if (c > cnight) {
c = c - cstep;
}
pwm.setPWM(0, 0, w);
if (w > wnight) {
w = w - wstep;
}
pwm.setPWM(1, 0, b);
if (b > bnight) {
b = b - bstep;
}
pwm.setPWM(2, 0, r);
if (r > rnight) {
r = r - rstep;
}
delay(500);
digitalWrite(2, HIGH);
}
//turn on outlet 1 if humidity drops below 60%
if ((humidity + humidity2)/2 <= 70) {
digitalWrite(5, LOW);
}
if ((humidity + humidity2)/2 >= 85) {
digitalWrite(5, HIGH);
}
//rain times
if (now.hour() == 4 && now.minute() == 20 && now.second() == 0) {
rain = 1;
}
if (now.hour() == 4 && now.minute() == 20 && now.second() == 12) {
rain = 0;
}
if (now.hour() == 7 && now.minute() == 24 && now.second() == 0) {
rain = 1;
}
if (now.hour() == 7 && now.minute() == 24 && now.second() == 15) {
rain = 0;
}
if (now.hour() == 11 && now.minute() == 24 && now.second() == 0) {
rain = 1;
}
if (now.hour() == 11 && now.minute() == 24 && now.second() == 8) {
rain = 0;
}
if (now.hour() == 14 && now.minute() == 24 && now.second() == 0) {
rain = 1;
}
if (now.hour() == 14 && now.minute() == 24 && now.second() == 15) {
rain = 0;
}
if (now.hour() == 17 && now.minute() == 24 && now.second() == 0) {
rain = 1;
}
if (now.hour() == 17 && now.minute() == 24 && now.second() == 10) {
rain = 0;
}
if (now.hour() == 20 && now.minute() == 24 && now.second() == 0) {
rain = 1;
}
if (now.hour() == 20 && now.minute() == 24 && now.second() == 10) {
rain = 0;
}
if (now.hour() == 23 && now.minute() == 24 && now.second() == 0) {
rain = 1;
}
if (now.hour() == 23 && now.minute() == 24 && now.second() == 10) {
rain = 0;
}
//turn on rain if it is rain time
if (rain == 0 && (humidity + humidity2)/2 >= 85) {
digitalWrite(5, HIGH);
}
if (rain == 1) {
digitalWrite(5, LOW);
}
if (buttons) {
lcd.clear();
lcd.setCursor(0,0);
if (buttons & BUTTON_UP) {
button = 1;
}
if (buttons & BUTTON_DOWN) {
button = 2;
}
if (buttons & BUTTON_LEFT) {
button = 3;
}
}
if (button == 1) {
lcd.setCursor(0,0);
lcd.print("Temp #1 ");
lcd.print(dht1.toFahrenheit(temperature), 1);
lcd.setCursor(0,1);
lcd.print("Humidity #1 ");
lcd.print(humidity, 1);
} // if up button is pushed show dht1 results
if (button == 2) {
lcd.setCursor(0,0);
lcd.print("Temp #2 ");
lcd.print(dht2.toFahrenheit(temperature2), 1);
lcd.setCursor(0,1);
lcd.print("Humidity #2 ");
lcd.print(humidity2, 1);
} // if down button is pushed show dht2 results
if (button == 3) {
lcd.setCursor(0, 0);
lcd.print(now.year(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.day(), DEC);
lcd.setCursor(0, 1);
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
} // if if left button is pushed show time
}
This code works 100% of the time when using my desktop running windows 8.