Go Down

Topic: First attempt at combining the blink example with readanalogvoltage example (Read 1 time) previous topic - next topic

SuperNewb

Think I got the code marker figured out not so sure about the indenting.
Code: [Select]
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() {

AWOL

Quote
Awol that link just tells me how to sign in when i'm already signed in.

"Just"?
Really?
Did you follow the very first link?


Indentation can be aided by the auto format tool in the IDE
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

UKHeliBob

Code: [Select]
pinMode(led13, OUTPUT);
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)
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

SuperNewb

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.
Code: [Select]


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() {

SuperNewb

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.

afremont

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.
Experience, it's what you get when you were expecting something else.

SuperNewb

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.

UKHeliBob

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 ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

afremont

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. 
Experience, it's what you get when you were expecting something else.

Go Up