RPi Easy SD Card Setup - eLinux.org
RPi Easy SD Card Setup - eLinux.org RPi Easy SD Card Setup - eLinux.org
GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.IN) GPIO.setup(18, GPIO.OUT) input_value = GPIO.input(17) GPIO.output(18, True) GPIO Driving Example (Java using the Pi4J Library) This uses the Java library available at http://www.pi4j.com/. (Any Java application that controls GPIO must be run as root.) Please note that the Pi4J library uses the WiringPi GPIO pin numbering scheme [21] [22] . Please see the usage documentation for more details: http://pi4j.com/usage.html public static void main(String[] args) { } // create gpio controller GpioController gpio = GpioFactory.getInstance(); // provision gpio pin #01 as an output pin and turn off GpioPinDigitalOutput outputPin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_01, "MyLED", PinState.LOW); // turn output to LOW/OFF state outputPin.low(); // turn output to HIGH/ON state outputPin.high(); // provision gpio pin #02 as an input pin with its internal pull down resistor enabled GpioPinDigitalInput inputPin = gpio.provisionDigitalInputPin(RaspiPin.GPIO_02, "MyButton", PinPullResista // get input state from pin 2 boolean input_value = inputPin.isHigh(); More complete and detailed examples are included on the Pi4J website at http://www.pi4j.com/. The Pi4J library includes support for: ▪ GPIO Control ▪ GPIO Listeners ▪ Serial Communication ▪ I2C Communication ▪ SPI Communication
GPIO Driving Example (Java) This uses the Java library available at https://github.com/jkransen/framboos. Any Java application that controls GPIO must be run as root. public static void main(String[] args) { // reading from an in pin InPin button = new InPin(8); boolean isButtonPressed = button.getValue(); button.close(); } // writing to an out pin OutPin led = new Outpin(0); led.setValue(true); led.setValue(false); led.close(); GPIO Driving Example (Java Webapp GPIO web control via http) This uses the Java Webapp available at https://bitbucket.org/sbub/raspberry-pi-gpio-webcontrol/overview. You can control your GPIO over the internet. Any Java application that controls GPIO must be run as root. host:~ sb$ curl 'http://raspberrypi:8080/handle?g0=1&g1=0' {"g1":0,"g0":1} GPIO Driving Example (Shell script) This must be done as root. To change to the root user: sudo -i #!/bin/sh # GPIO numbers should be from this list # 0, 1, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 21, 22, 23, 24, 25 # Note that the GPIO numbers that you program here refer to the pins # of the BCM2835 and *not* the numbers on the pin header. # So, if you want to activate GPIO7 on the header you should be # using GPIO4 in this script. Likewise if you want to activate GPIO0 # on the header you should be using GPIO17 here. # Set up GPIO 4 and set to output echo "4" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio4/direction
- Page 149 and 150: Coloured splash screen With recent
- Page 151 and 152: Some users have reported that their
- Page 153 and 154: Copyright (c) 2012 Broadcom version
- Page 155 and 156: Networking Ethernet connection is l
- Page 157 and 158: As of 1 September 2012, this fault
- Page 159 and 160: Speaker-test -c 2 -s 1 -t wav -W /u
- Page 161 and 162: Can only get 800x480 resolution in
- Page 163 and 164: Edit the configuration file, see th
- Page 165 and 166: Composite displays no image The out
- Page 167 and 168: sudo apt-get update Troubleshooting
- Page 169 and 170: 3. Turn your board over and find th
- Page 171 and 172: Board ver. RAM Chip USB Chip BS12xx
- Page 173 and 174: ▪ This page was last modified on
- Page 175 and 176: Here is an example file # Set stdv
- Page 177 and 178: hdmi_ignore_cec Pretends CEC is not
- Page 179 and 180: hdmi_mode=18 1024x768 75Hz hdmi_mod
- Page 181 and 182: Which values are valid for my monit
- Page 183 and 184: Overclocking WARNING: Setting any o
- Page 185 and 186: enables dynamic clocks and voltage
- Page 187 and 188: Retrieved from "http://elinux.org/i
- Page 189 and 190: Hardware and Hardware History. Low-
- Page 191 and 192: Each GPIO can interrupt, high/low/r
- Page 193 and 194: Colour legend +5 V +3.3 V Ground, 0
- Page 195 and 196: GPIO02, 03, 05 and 27 are available
- Page 197 and 198: GPIO as input or output and change
- Page 199: Make sure pointer is on 4K boundary
- Page 203 and 204: gpio export 17 out gpio export 18 i
- Page 205 and 206: # call set_debug(1) to do a non-des
- Page 207 and 208: References 1. ↑ http://www.raspbe
- Page 209 and 210: RaspberryPi Boards From eLinux.org
- Page 211 and 212: Model B:
- Page 213 and 214: BS1218 Samsung ? BH1208 BH1219 BH12
- Page 215 and 216: BH1218 Hynix SMSC BH1218 Hynix SMSC
- Page 217 and 218: BS1224 BS1218 BS1222 BS1232 BS1228
- Page 219 and 220: RPi Hardware From eLinux.org Back t
- Page 221 and 222: Components (Provisional - some of t
- Page 223 and 224: ▪ S8: SD/MMC/SDIO memory card slo
- Page 225 and 226: ▪ Board B: 5V, 700 mA (3.5W) with
- Page 227 and 228: ▪ If the PSU is unregulated it ca
- Page 229 and 230: work initially but be unreliable be
- Page 231 and 232: 4. ↑ RPiBlog Post: High-res pics
- Page 233 and 234: Cheap PSU Cheap PSU - inside So ins
- Page 235 and 236: With this values (R1=1k, R2=100) ad
- Page 237 and 238: Mobile battery power supply options
- Page 239 and 240: RPi Documentation From eLinux.org B
- Page 241 and 242: Beta Boards: Gert's Beta Boards Mec
- Page 243: Retrieved from "http://elinux.org/i
GPIO.setmode(GPIO.BCM)<br />
GPIO.setup(17, GPIO.IN)<br />
GPIO.setup(18, GPIO.OUT)<br />
input_value = GPIO.input(17)<br />
GPIO.output(18, True)<br />
GPIO Driving Example (Java using the Pi4J Library)<br />
This uses the Java library available at http://www.pi4j.com/. (Any Java application that<br />
controls GPIO must be run as root.)<br />
Please note that the Pi4J library uses the WiringPi GPIO pin numbering scheme [21] [22] .<br />
Please see the usage documentation for more details: http://pi4j.com/usage.html<br />
public static void main(String[] args) {<br />
}<br />
// create gpio controller<br />
GpioController gpio = GpioFactory.getInstance();<br />
// provision gpio pin #01 as an output pin and turn off<br />
GpioPinDigitalOutput outputPin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_01, "MyLED", PinState.LOW);<br />
// turn output to LOW/OFF state<br />
outputPin.low();<br />
// turn output to HIGH/ON state<br />
outputPin.high();<br />
// provision gpio pin #02 as an input pin with its internal pull down resistor enabled<br />
GpioPinDigitalInput inputPin = gpio.provisionDigitalInputPin(RaspiPin.GPIO_02, "MyButton", PinPullResista<br />
// get input state from pin 2<br />
boolean input_value = inputPin.isHigh();<br />
More complete and detailed examples are included on the Pi4J website at<br />
http://www.pi4j.com/.<br />
The Pi4J library includes support for:<br />
▪ GPIO Control<br />
▪ GPIO Listeners<br />
▪ Serial Communication<br />
▪ I2C Communication<br />
▪ SPI Communication