Interfacing

wiringpi Core Functions for banana Pi

4 6053

Core Functions

These functions work directly on the Banana
Pi and also with external GPIO modules such as GPIO expanders and so on, and the Banana
Pi has no on-board analog hardware.

  • void pinMode (int pin, int mode) ;

This sets the mode of a pin to either INPUT, OUTPUT, PWM_OUTPUT. Note that only wiringPi pin 7 supports PWM output .

This function has no effect when in Sys mode. If you need to change the pin mode, then you can do it with the gpio program in a script before you start your program.

  • void pullUpDnControl (int pin, int pud) ;

This sets the pull-up or pull-down resistor mode on the given pin, which should be set as an input. Unlike the Arduino, the A20 has both pull-up an down internal resistors. The parameter pud should be; PUD_OFF, (no pull up/down), PUD_DOWN (pull to ground) or PUD_UP (pull to 3.3v) The internal pull up/down resistors have a value of approximately 50KΩ on the Banana
Pi.

This function has no effect on the Banana Pi’s GPIO pins when in Sys mode. If you need to activate a pull-up/pull-down, then you can do it with the gpio program in a script before you start your program.

  • void digitalWrite (int pin, int value) ;

Writes the value HIGH or LOW (1 or 0) to the given pin which must have been previously set as an output.

WiringPi treats any non-zero number as HIGH, however 0 is the only representation of LOW.

  • void pwmWrite (int pin, int value) ;

Writes the value to the PWM register for the given pin. The Banana
Pi has one on-board PWM pin, pin 7. Other PWM devices may have other PWM ranges.

This function is not able to control the Pi’s on-board PWM when in Sys mode.

  • int digitalRead (int pin) ;

This function returns the value read at the given pin. It will be HIGH or LOW (1 or 0) depending on the logic level at the pin.

  • analogRead (int pin) ;

This returns the value read on the supplied analog input pin.
Banana
Pi not support in current version

  • analogWrite (int pin, int value) ;

This writes the given value to the supplied analog pin. Banana
Pi not support in current version

Roy360  
Why only 1 PWN pin?

If I wanted to control two servos what would I need to do?

You can drive up to 24 servos or PWM outputs or any mix with RoboPi.

http://RoboPi.com

RoboPi supports the Banana Pi and Banana Pro with both C/C++ and Python libraries!

See

http://www.mikronauts.com/banana-pi/bpi-review/4/
http://www.mikronauts.com/banana-pi/banana-pro-review/5/

(note: the mounting holes are for rev.2 Model A/B Raspberry Pi's only)

Roy360  
mikronauts replied at Thu Feb 19, 2015 14:30
You can drive up to 24 servos or PWM outputs or any mix with RoboPi.

http://RoboPi.com

looks expensive. What if I were to use a 555 Timer in astable mode? How would the servo react to the negative voltages? Would I have to invert them before sending them to the servo?

Roy360 replied at Sat Feb 28, 2015 09:34
looks expensive. What if I were to use a 555 Timer in astable mode? How would the servo react to t ...

I would not try a 555, and servos would NOT like the negative voltages.

Try the adafruid 16 channel servo controller, it is based on a LED driver chip and costs less than RoboPi (of course it only has a small fraction of RoboPi's capabilities.

RoboPi costs more due to the very expensive parts it uses, development costs etc

I'll have a less expensive controller soon, but it will only have a fraction of the capabilities, and won't work on the Banana Pro/Pi as there is no equivalent to the DMA based pigpio or servo blaster for the Banana's.

You have to log in before you can reply Login | Sign Up

Points Rules