Author Topic: how work pin input and output pin in axon microcontroller?  (Read 1649 times)

0 Members and 1 Guest are viewing this topic.

Offline RoboteccanTopic starter

  • Jr. Member
  • **
  • Posts: 20
  • Helpful? 0
how work pin input and output pin in axon microcontroller?
« on: November 10, 2010, 08:12:23 PM »
hi, I have a big problem with input pin and output pin, when I put this code all work, I push switch and the led is turn off and when I dont push switch the led is turn on, this is the code.

#include "sys/axon.h"
#include "C:\WebbotLib\iopin.h"

void appInitHardware(void){
pin_make_output(C0,FALSE);
pin_make_input(A0,FALSE);
}

TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
    return 0;
}

TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {

if(pin_is_high(A0)){
    pin_low(C0);
}else{
    pin_high(C0);
}
return 1;
}

the problem become when you change the pin_low(C0); in the "else" and the pin_high(C0); in the "if", when the program get started there are a problem, because the program get started the led turn on(when the led must turn off), and when I push the switch the led shine to much(a lot) and when I dont push switch the led return to the original shine(less shine), this is the code, when that happen.

if(pin_is_high(A0)){
    pin_high(C0);
}else{
    pin_low(C0);
}


Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: how work pin input and output pin in axon microcontroller?
« Reply #1 on: November 11, 2010, 10:24:55 AM »
The reason is because your mcu high voltage is 5V, but your LED is attached to the 6V+ battery.

So when C0 is low, the LED sees 6V-0V = 6V (on).

And when C0 is hi, the LED sees 6V-5V = 1V (on).

It'll be on either way, just not as bright when C0 is high.

So to correct this, you need to use a 5V voltage pin on the regulated bus (the ADC headers) for the LED.

 


Get Your Ad Here

data_list