Pages: 1 2 [3]   Go Down
Author Topic: First attempt at combining the blink example with readanalogvoltage example  (Read 1781 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Think I got the code marker figured out not so sure about the indenting.
Code:
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() {
« Last Edit: March 19, 2013, 02:45:32 pm by SuperNewb » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26495
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

"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.

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 118
Posts: 4335
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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)
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

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() {
« Last Edit: March 19, 2013, 10:58:18 pm by SuperNewb » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: March 19, 2013, 11:40:29 pm by SuperNewb » Logged

texas
Offline Offline
God Member
*****
Karma: 27
Posts: 862
old, but not dead
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Experience, it's what you get when you were expecting something else.

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 118
Posts: 4335
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

texas
Offline Offline
God Member
*****
Karma: 27
Posts: 862
old, but not dead
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. 
Logged

Experience, it's what you get when you were expecting something else.

Pages: 1 2 [3]   Go Up
Jump to: