Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumProgramming Questions & HelpSyntax › question about different pins

Page Index Toggle Pages: 1
question about different pins (Read 2808 times)
10/27/07 at 09:25:17

Titus   Offline
Full Member
Wiring Soccer Robot!
Amsterdam

Posts: 176
***
 
Since the digital I/O pins have a pin 0 and the analog in have a pin 0 and the PWM have a pin 0

if you create an int, like so:
int ledpin = 0;

The led would be on pin 0.

Which pin 0 is it:
Is this correct:



if you use a "analogWrite" command, it is a PWM pin
If you use a "analogRead" command it is a Analog in pin(analog in pins can't be used for analog out, can they, because that's the PWM)

As for the Digital pin:
If you want to use a digital pin, you will need to put a "pinMode" command in the void setup, like so:

void setup()
{
  pinMode(ledPin, OUTPUT); // sets the digital pin as output
}

The OUTPUT or INPUT changes the sort of Digital pin.

Can you use a "digitalWrite" command without the "pinMode" command in the void setup?

Or a "digitalRead" command without the "pinMode" command in the void setup


Thanks,

Titus
 

Check www.TeamVossius.nl for our Autonomous soccer robots!
IP Logged
 
Reply #1 - 10/27/07 at 17:33:44

worapoht   Offline
YaBB Newbies
Thailand

Posts: 21
*
 
As pin assignement, I think it's ok

 int ledpin = 0;
// just assign a variable named "ledpin" keep number 0 only, not direct to I/O until placed on digital I/O function

Wiring/Arduino program formed
void setup()
{
}

void loop()
{
}

actually, Real code of both section look like this

int main(void)
{
 init();
 setup();
 for ( ; ; )
   loop();
 return 0;
}

that's pinMode can be use anywhere in program..
about digitalWrite function shouldn't modified direction because some interface need internal pull-up resistor while operate on input mode..
 
IP Logged
 
Page Index Toggle Pages: 1