As I was reading the blink example I was under the impression that without the delay the led will just come on and off too quickly for the human eye to see. If it will already stay on, whenever it's in the preset range that is exactly what I want which might mean no need for changes and to actually copy my existing code onto the arduino 1.4 software to actually attempt to compile it? Is there a guide you'd recommend for that?
Without the delays in the Blink example the LED would, indeed, turn on and off too fast to to see and would appear dimly on. In your code it will stay on or off unless you explicitly change its state.
Whatever editor you have used to write it at the moment copy it then paste it into the IDE. Did you really need to be told how to do that or did you mean something else ?
Had to make some changes to make it compile. Do you guys forsee any problems?
void setup () {
Serial.begin(9600);
}
void loop() {
int led13 = 13;
int sensorValue = analogRead(A5); // I elimnated ledpin = output since led will be my output
if ( (sensorValue > 833) && (sensorValue <925) )
{
digitalWrite (led13, HIGH);// Changed these to led13 instead of ledpin
}
else
{
digitalWrite (led13, LOW);// Changed these to led13 instead of ledpin
}} //Added a second } to finish to compliment the void loop() {
Sorry Aarch i am a complete newb never coded before. Where should I indent and what is it's purpose? What is a code tag and purpose?
I couldn't find either of those under the reference. Arduino - Home
SuperNewb:
Sorry Aarch i am a complete newb never coded before. Where should I indent and what is it's purpose? What is a code tag and purpose?
I couldn't find either of those under the reference. http://arduino.cc/en/Reference/HomePage
Indentation - laying out your code so that it is indented consistently so that the structure is easier to see. Try Ctrl + T in the IDE or Tools Autoformat to have the IDE do it for you.
Code tags - when posting code here select the code in the edit window and click the # button above the smileys. It adds [ code ] tags to the post which stop it being mangled by the website and also easier to see the code in the post.
Think I got the code marker figured out not so sure about the indenting.
void setup () {
Serial.begin(9600);
pinMode (led13, OUTPUT);
}
void loop() {
int led13 = 13;
int sensorValue = analogRead(A5); // I elimnated ledpin = output since led will be my output
if ( (sensorValue > 833) && (sensorValue <925) )
{
digitalWrite (led13, HIGH);// Changed these to led13 instead of ledpin
}
else
{
digitalWrite (led13, LOW);// Changed these to led13 instead of ledpin
}} //Added a second } to finish to compliment the void loop() {
defines pin 13 as an output, the led13 variable having previously been set to a value of 13. It is a digital pin and does not support PWM (at least not on a Uno) so it will be a digital output capable of being HIGH (5V) or LOW (0V)
How do I properly declare pin 13 as the output as i'm having it as a non defined compiling error.
I thought i needed to define led13 to be energized in the voidsetup? A 5 volt output is fine since i'm running it to a relay, which is powered by 12v.
int led13 = 13;
void setup ()
{
Serial.begin(9600);
pinMode(led13, OUTPUT);
}
void loop() {
int sensorValue = analogRead(A5); // I elimnated ledpin = output since led13 will be my output
if (sensorValue < 717)
{
digitalWrite (led13, HIGH);// Changed this to led13 instead of ledpin
}
else
{
digitalWrite (led13, LOW);// Changed this to led13 instead of ledpin
}
} //Added a second } to finish to compliment the void loop() {
Had a little bit of help from the coding aspect I think it is now correct but when I try to upload after compiling it says that com1 is not found. Yet when I go to the tools>serial port is greyed out so i can't choose...
I am having the relayboard and the uno r3 board power lights come on... so not sure what to do from here.
It's fairly unlikely that your Uno was ever on COM1, though it's possible I suppose. You might try unplugging it from the PC and plugging it back in, worst case reboot your computer (thought that shouldn't be necessary). I have two Uno R3s and they are on COM8 and COM10.
Just rebooted and reloaded arduino 1.0.4
with nothing connected I tried tools>serial monitor
serial ports is still greyed out and it gave me the com 1 not found error. Is this normal? I'll try plugged it in to the r3 and running serial monitor tomorrow but I suspect i'll get the same error.
If the COM port is greyed out in the IDE then uploading will not work. It sounds as though the driver for the USB connection is not installed correctly.
If you are using Windows then what shows up under Ports in Device Manager ?
Like Bob asked, do you have any yellow question marks in Device Manager? With my boards (Uno R3), they show up as this:
Arduino UNO R3 (COM10)
Arduino UNO R3 (COM8)
You should something like that in Device Manager under Ports (COM & LPT). You should NOT see them showing up as some kind of FTDI or Generic USB to Serial port.