New features, refinements, and basic Pi features
This commit is contained in:
parent
e8ce0a8688
commit
b642be2dc7
|
@ -0,0 +1,31 @@
|
|||
#ATmega 328p / Arduino over SPI
|
||||
|
||||
###Did you know that your Pi could power and program an ATmega 328p/Arduino directly, with nothing but a few wires, a breadboard, a 16Mhz crystal oscillator and some 22pF capacitors?
|
||||
|
||||
Read my [complete Pico PiDuino tutorial](http://pi.gadgetoid.com/article/building-the-pico-piduino) to get started for just over £5
|
||||
|
||||
You'll need to install [Gordon's modified AVRDude](https://projects.drogon.net/raspberry-pi/gertboard/arduino-ide-installation-isp/).
|
||||
|
||||
Connect 8/CEO to your ATmega's Reset/RST pin, 9/MISO to its MISO pin (D12), 10 to its MOSI pin (D11) and 11/SCLK to its SCLK pin (D13).
|
||||
|
||||
Power your ATmega with the 3.3v and GND pins from your Pi, and you're good to go.
|
||||
|
||||
Make sure you have no rogue SPI device drivers running and check it's connected correctly using:
|
||||
|
||||
```bash
|
||||
avrdude -p m328p -c gpio
|
||||
```
|
||||
|
||||
To get started compiling Arduino sketches from the command line:
|
||||
|
||||
```bash
|
||||
sudo apt-get install arduino arduino-mk
|
||||
```
|
||||
|
||||
This basic Makefile should get you started. Create a basic sketch, name it mysketch.ino and run:
|
||||
|
||||
```bash
|
||||
export BOARD=atmega328
|
||||
make
|
||||
avrdude -p m328p -c gpio -e -U flash:w:build-cli/Arduino.hex
|
||||
```
|
|
@ -0,0 +1,26 @@
|
|||
#I2C - Inter Integrated Circuit
|
||||
|
||||
The Raspberry Pi's I2C pins are an extremely useful way to talk to many different types of external peripheral; from the MCP23017 digital IO expander, to a connected ATmega.
|
||||
|
||||
You can verify the address of connected I2C peripherals with a simple one-liner:
|
||||
|
||||
```bash
|
||||
sudo apt-get install i2c-tools
|
||||
sudo i2cdetect -y 1
|
||||
```
|
||||
|
||||
You can access i2c from Python using the smbus library:
|
||||
|
||||
```bash
|
||||
sudo apt-get install python-smbus
|
||||
```
|
||||
|
||||
And then in Python:
|
||||
|
||||
```python
|
||||
import smbus
|
||||
DEVICE_BUS = 1
|
||||
DEVICE_ADDR = 0x15
|
||||
bus = smbus.SMBus(DEVICE_BUS)
|
||||
bus.write_byte_data(DEVICE_ADDR, 0x00, 0x01)
|
||||
```
|
|
@ -0,0 +1,26 @@
|
|||
#SPI - Serial Peripheral Interface
|
||||
|
||||
###Known as the four-wire serial bus, SPI lets you daisy-chain multiple compatible devices off a single set of pins by assigning them different addresses.
|
||||
|
||||
A simple example of an SPI peripheral is the MCP23S17 digital IO expander chip Note the S in place of the 0 found on the I2C version. Using it in WiringPi2 is a doddle:
|
||||
|
||||
```python
|
||||
import wiringpi2 as wiringpi
|
||||
HIGH = 1
|
||||
OUTPUT = 1
|
||||
PIN_BASE = 65
|
||||
SPI_ADDR = 0x20
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.mcp23S17Setup(PIN_BASE,SPI_ADDR)
|
||||
# 16 pins including the starting pin
|
||||
mcp23S17pins = range(PIN_BASE,PIN_BASE+15)
|
||||
for pin in mcp23S17pins:
|
||||
wiringpi.pinMode(pin,OUTPUT)
|
||||
wiringpi.digitalWrite(pin,HIGH)
|
||||
```
|
||||
|
||||
You can also use the SPI port to "Bit-Bang" an ATmega 328, loading Arduino sketches onto it with Gordon's modified version of AVRDude.
|
||||
|
||||
Hook up you Pi's SPI port to that of your ATmega, and power the ATmega from the 3.3v pin on the Pi. Make sure you're not running any SPI device drivers, and run "avrdude -p m328p -c gpio" to verify the connection.
|
||||
|
||||
See the individual pins to learn how to connect up your ATmega.
|
|
@ -0,0 +1,16 @@
|
|||
#UART - Universal Asynchronous Receiver/Transmitter
|
||||
|
||||
###The 2 UART pins in WiringPi are: 15, 16
|
||||
|
||||
UART is a handy, straight forward way to interface an Arduino ( or bootloaded ATmega ) with your Pi. You must, however, be careful with logic-levels between the two devices: the Pi is 3.3v and the Arduino is 5v. Connect the two and you might conjure up some magic blue smoke.
|
||||
|
||||
Personally I'm a fan of building out a Arduino Bootloaded ATmega 328 circuit on a breadboard with a voltage regulator to take the Pi's 5v line and convert it to 3.3v. The ATmega 328 seems to run quite happily at 3.3v using a 16Mhz crystal and you'll then have an Arduino clone with 3.3v logic.
|
||||
|
||||
Assuming you have WiringPi2-Python installed, the following python example opens the Pi's UART at 9600baud and puts 'hello world'
|
||||
|
||||
```python
|
||||
import wiringpi2 as wiringpi
|
||||
wiringpi.wiringPiSetup()
|
||||
serial = wiringpi.serialOpen('/dev/ttyAMA0',9600)
|
||||
wiringpi.serialPuts(serial,'hello world!')
|
||||
```
|
|
@ -11,6 +11,10 @@ resource_url = '/resources/'
|
|||
|
||||
|
||||
overlays = [
|
||||
'spi',
|
||||
'uart',
|
||||
'i2c',
|
||||
'arduino-spi',
|
||||
'pibrella',
|
||||
'explorer-hat-pro',
|
||||
'explorer-hat',
|
||||
|
@ -21,7 +25,7 @@ template = open('template/layout.html').read()
|
|||
|
||||
pages = {}
|
||||
navs = {}
|
||||
select_overlays = {}
|
||||
select_overlays = []
|
||||
|
||||
overlays_html = ''
|
||||
|
||||
|
@ -74,7 +78,7 @@ def load_overlay(overlay):
|
|||
loaded['page_url'] = slugify(loaded['name'])
|
||||
pages[loaded['page_url']] = render_overlay_page(loaded)
|
||||
navs[loaded['page_url']] = render_nav(loaded['page_url'], overlay=loaded)
|
||||
select_overlays[loaded['page_url']] = loaded['name']
|
||||
select_overlays.append((loaded['page_url'], loaded['name']))
|
||||
return loaded
|
||||
|
||||
def load_md(filename):
|
||||
|
@ -143,13 +147,18 @@ def render_pin(pin_num, selected_url, overlay=None):
|
|||
pin_name = pin['name']
|
||||
pin_text_name = pin['name']
|
||||
pin_used = False
|
||||
pin_link_title = []
|
||||
|
||||
|
||||
if overlay != None and str(pin_num) in overlay['pin']:
|
||||
overlay_pin = overlay['pin'][str(pin_num)]
|
||||
pin_text_name = ''
|
||||
#print(overlay)
|
||||
pin_name = overlay['pin'][str(pin_num)]['name']
|
||||
pin_name = overlay_pin['name']
|
||||
pin_used = True
|
||||
|
||||
if 'description' in overlay_pin:
|
||||
pin_link_title.append(overlay_pin['description'])
|
||||
#alternates = []
|
||||
|
||||
#for overlay in overlays:
|
||||
|
@ -169,8 +178,9 @@ def render_pin(pin_num, selected_url, overlay=None):
|
|||
# pin_subname_text = '({})'.format(pin['name'])
|
||||
pin_name = 'BCM {} {}'.format(bcm, pin_subname)
|
||||
# pin_text_name = 'BCM {} {}'.format(bcm, pin_subname_text)
|
||||
#if 'wiringpi' in pin['scheme']:
|
||||
# wiringpi = pin['scheme']['wiringpi']
|
||||
if 'wiringpi' in pin['scheme']:
|
||||
wiringpi = pin['scheme']['wiringpi']
|
||||
pin_link_title.append('Wiring Pi pin {}'.format(wiringpi))
|
||||
# alternates.append(render_alternate('wiringpi','Wiring Pi pin {}'.format(wiringpi)))
|
||||
|
||||
#print(pin_type)
|
||||
|
@ -185,13 +195,13 @@ def render_pin(pin_num, selected_url, overlay=None):
|
|||
if pin_used:
|
||||
selected += ' overlay-pin'
|
||||
|
||||
return '<li class="pin{} {}{}"><a href="{}"><span class="default"><span class="phys">{}</span> {}</span><span class="pin"></span></a></li>\n'.format(
|
||||
pin_num,
|
||||
' '.join(map(slugify,pin_type)),
|
||||
selected,
|
||||
pin_url,
|
||||
pin_num,
|
||||
pin_name
|
||||
return '<li class="pin{pin_num} {pin_type}{pin_selected}"><a href="{pin_url}" title="{pin_title}"><span class="default"><span class="phys">{pin_num}</span> {pin_name}</span><span class="pin"></span></a></li>\n'.format(
|
||||
pin_num = pin_num,
|
||||
pin_type = ' '.join(map(slugify,pin_type)),
|
||||
pin_selected = selected,
|
||||
pin_url = pin_url,
|
||||
pin_title = ', '.join(pin_link_title),
|
||||
pin_name = pin_name
|
||||
)
|
||||
|
||||
def render_nav(url, overlay=None):
|
||||
|
@ -215,8 +225,8 @@ pins = db['pins']
|
|||
|
||||
overlays = map(load_overlay,overlays)
|
||||
|
||||
for url in select_overlays:
|
||||
overlays_html += '<option value="{}">{}</option>'.format(url, select_overlays[url])
|
||||
for url, name in select_overlays:
|
||||
overlays_html += '<option value="{}">{}</option>'.format(url, name)
|
||||
|
||||
|
||||
pages['pinout'] = render_overlay_page({'name':'Index','long_description':load_md('description/index.md')})
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "Arduino SPI",
|
||||
"description": "Program Arduino with Raspberry Pi SPI",
|
||||
"pin": {
|
||||
"19": {
|
||||
"name": "MOSI",
|
||||
"direction": "output",
|
||||
"active": "high",
|
||||
"description": "Master Out / Slave In"
|
||||
},
|
||||
"21": {
|
||||
"name": "MISO",
|
||||
"direction": "input",
|
||||
"active": "high",
|
||||
"description": "Master In / Slave Out"
|
||||
},
|
||||
"23": {
|
||||
"name": "SCKL",
|
||||
"direction": "output",
|
||||
"active": "high",
|
||||
"description": "Clock"
|
||||
},
|
||||
"24": {
|
||||
"name": "CE0",
|
||||
"direction": "output",
|
||||
"active": "high",
|
||||
"description": "Arduino Reset"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "I2C",
|
||||
"description": "Raspberry Pi i2c pins",
|
||||
"pin": {
|
||||
"3": {
|
||||
"name": "Data",
|
||||
"direction": "both",
|
||||
"active": "high"
|
||||
},
|
||||
"5": {
|
||||
"name": "Clock",
|
||||
"direction": "both",
|
||||
"active": "high"
|
||||
},
|
||||
"27": {
|
||||
"name": "EEPROM Data",
|
||||
"direction": "both",
|
||||
"active": "high"
|
||||
},
|
||||
"28": {
|
||||
"name": "EEPROM Clock",
|
||||
"direction": "both",
|
||||
"active": "high"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Pibrella",
|
||||
"manufacturer": "Pimoroni",
|
||||
"manufacturer": "Pimoroni Vs Cyntech",
|
||||
"url": "https://github.com/pimoroni/pibrella",
|
||||
"description": "An all-in-one light, sound, input and output add-on board.",
|
||||
"pincount": 26,
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"name": "SPI",
|
||||
"description": "Raspberry Pi SPI pins",
|
||||
"pincount": 5,
|
||||
"pin": {
|
||||
"19": {
|
||||
"name": "MOSI",
|
||||
"direction": "output",
|
||||
"active": "high",
|
||||
"description": "Master Out / Slave In"
|
||||
},
|
||||
"21": {
|
||||
"name": "MISO",
|
||||
"direction": "input",
|
||||
"active": "high",
|
||||
"description": "Master In / Slave Out"
|
||||
},
|
||||
"23": {
|
||||
"name": "SCKL",
|
||||
"direction": "output",
|
||||
"active": "high",
|
||||
"description": "Clock"
|
||||
},
|
||||
"24": {
|
||||
"name": "CE0",
|
||||
"direction": "output",
|
||||
"active": "high",
|
||||
"description": "Chip Select 0"
|
||||
},
|
||||
"26": {
|
||||
"name": "CE1",
|
||||
"direction": "output",
|
||||
"active": "high",
|
||||
"description": "Chip Select 1"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "UART",
|
||||
"description": "Raspberry Pi UART pins",
|
||||
"pin": {
|
||||
"8": {
|
||||
"name": "TXD / Transmit",
|
||||
"direction": "output",
|
||||
"active": "high"
|
||||
},
|
||||
"10": {
|
||||
"name": "RXD / Receive",
|
||||
"direction": "input",
|
||||
"active": "high"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,8 @@ table td, table th {border:1px solid #073642;padding:5px;}
|
|||
table th {background:#073642;color:#EBE6D3;}
|
||||
table * {text-align:left;font-size:13px;}
|
||||
|
||||
h2 {font-size:18px;margin-top:20px;}
|
||||
|
||||
.main-nav {
|
||||
position:absolute;
|
||||
right:0px;
|
||||
|
@ -51,6 +53,7 @@ nav#gpio {
|
|||
.bottom .phys {color:#002B36;}
|
||||
.bottom .active .phys, .bottom :hover .phys,
|
||||
.bottom .legend .phys {color:#FFF;}
|
||||
|
||||
#content {
|
||||
float:left;
|
||||
background:#EBE6D3;
|
||||
|
@ -58,11 +61,9 @@ nav#gpio {
|
|||
min-height:600px;
|
||||
padding-bottom:60px;
|
||||
}
|
||||
|
||||
#content article {
|
||||
background:#EBE6D3;
|
||||
padding:20px;
|
||||
width:460px;
|
||||
min-height:680px;
|
||||
}
|
||||
nav#gpio ul.top {
|
||||
position:absolute;
|
||||
|
@ -303,4 +304,13 @@ li.legend_ledborg {background:#000000;}
|
|||
ul.legend li.legend_ledborg a {color:#FFFFFF;}
|
||||
li.legend_clockatoo {background:#D33682;}
|
||||
span.alternate {display:none;}
|
||||
ol.linenums {margin-left:30px;}
|
||||
ol.linenums {margin-left:30px;}
|
||||
|
||||
@media (min-width:1200px){
|
||||
#container {
|
||||
width:1200px;
|
||||
}
|
||||
#content {
|
||||
width:700px;
|
||||
}
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script>
|
||||
<head>
|
||||
<title>Raspberry Pi Pinout - Rev 2 Board</title>
|
||||
<meta name="description" content="The comprehensive Raspberry Pi Pinout guide for the Raspberry Pi, now with Model B+ and Pi 2" />
|
||||
<link href='http://fonts.googleapis.com/css?family=Sanchez|Ubuntu+Mono' rel='stylesheet' type='text/css' />
|
||||
<link href='{{resource_url}}prettify/prettify.css' rel='stylesheet' />
|
||||
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
|
||||
<link href="{{resource_url}}pinout.css?v={{v}}" rel="stylesheet">
|
||||
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
|
||||
<!--script type='text/javascript'>
|
||||
<script type='text/javascript'>
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-32070014-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
@ -16,7 +17,7 @@
|
|||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
</script-->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
|
@ -25,7 +26,7 @@
|
|||
<li><a href="https://twitter.com/gadgetoid"><i class="fa fa-twitter"></i> @Gadgetoid</a></li>
|
||||
<li><a href="https://github.com/Gadgetoid/Pinout2"><i class="fa fa-github"></i> Contribute</a></li>
|
||||
</ul>
|
||||
<h1 class="logo"><a href="/pinout"><img src="{{resource_url}}pinout-logo.png" style="top:8px;" /></a><span>Pi</span>n<span class="out">out</span></h1>
|
||||
<h1 class="logo"><a href="/pinout"><img src="{{resource_url}}pinout-logo.png" style="top:8px;" /><span>Pi</span>n<span class="out">out</span></a></h1>
|
||||
<div class="overlay-container">
|
||||
<span>Learn more about:</span>
|
||||
<select class="overlay">
|
||||
|
@ -45,24 +46,9 @@
|
|||
</div>
|
||||
|
||||
<script type="text/javascript" src="http://cdn.jsdelivr.net/jquery/1.9.1/jquery-1.9.1.min.js"></script>
|
||||
<script type="text/javascript" src="http://cdn.jsdelivr.net/cycle/2.9999.81/jquery.cycle.all.js"></script>
|
||||
<script type="text/javascript" src="http://cdn.jsdelivr.net/prettify/0.1/prettify.js"></script>
|
||||
<script src='{{resource_url}}prettify/lang-ruby.js'></script>
|
||||
<script src='{{resource_url}}prettify/lang-bash.js'></script>
|
||||
<script src='http://cdn.jsdelivr.net/history.js/1.7.1/history.js'></script>
|
||||
<script src='http://cdn.jsdelivr.net/history.js/1.7.1/history.adapter.jquery.js'></script>
|
||||
<script src='{{resource_url}}pinout.js?v={{v}}'></script>
|
||||
<!--script type="text/javascript">if (typeof NREUMQ !== "undefined") { if (!NREUMQ.f) { NREUMQ.f=function() {
|
||||
NREUMQ.push(["load",new Date().getTime()]);
|
||||
var e=document.createElement("script");
|
||||
e.type="text/javascript";
|
||||
e.src=(("http:"===document.location.protocol)?"http:":"https:") + "//" +
|
||||
"js-agent.newrelic.com/nr-100.js";
|
||||
document.body.appendChild(e);
|
||||
if(NREUMQ.a)NREUMQ.a();
|
||||
};
|
||||
NREUMQ.a=window.onload;window.onload=NREUMQ.f;
|
||||
};
|
||||
NREUMQ.push(["nrfj","bam.nr-data.net","3cd5994c2d","2368869","Jl1cQ0MODVRUSho1DAtTRkVQTiBIQRdyIzFFQltZXhQVFxlja0laRm8ZHg==",0,1,new Date().getTime(),"","","","",""]);}</script-->
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue