Premier Pas avec le Raspberry Pi: Difference between revisions
| Line 82: | Line 82: | ||
===Arduino Uno=== |
===Arduino Uno=== |
||
[[Premiers Pas avec Raspberry Pi et Arduino]] |
|||
* Via USB : http://blog.oscarliang.net/connect-raspberry-pi-and-arduino-usb-cable/ |
|||
* Via GPIO : http://blog.oscarliang.net/raspberry-pi-and-arduino-connected-serial-gpio/ |
|||
Read http://playground.arduino.cc/Interfacing/Python |
|||
Install pySerial |
|||
<pre> |
|||
sudo apt-get install python-serial |
|||
</pre> |
|||
Check the Arduino tty port |
|||
<pre> |
|||
ls /dev/tty* |
|||
</pre> |
|||
Download the following sketch on the Arduino board (using the Arduino IDE) |
|||
<pre> |
|||
void setup() { |
|||
Serial.begin(9600); |
|||
} |
|||
void loop() { |
|||
int sensorValue = analogRead(A0); |
|||
Serial.println(sensorValue); |
|||
delay(1000); |
|||
} |
|||
</pre> |
|||
Run the following python script |
|||
<pre> |
|||
import serial |
|||
ser = serial.Serial('/dev/ttyACM0', 9600) |
|||
while True : |
|||
print ser.readline() |
|||
</pre> |
|||
More test |
|||
Download the following sketch on the Arduino board (using the Arduino IDE) |
|||
<pre> |
|||
// from http://blog.oscarliang.net/connect-raspberry-pi-and-arduino-usb-cable/ |
|||
const int ledPin = 13; |
|||
void setup(){ |
|||
pinMode(ledPin, OUTPUT); |
|||
Serial.begin(9600); |
|||
} |
|||
void loop(){ |
|||
if (Serial.available()) { |
|||
light(Serial.read() - '0'); |
|||
} |
|||
delay(500); |
|||
} |
|||
void light(int n){ |
|||
for (int i = 0; i < n; i++) { |
|||
digitalWrite(ledPin, HIGH); |
|||
delay(100); |
|||
digitalWrite(ledPin, LOW); |
|||
delay(100); |
|||
} |
|||
} |
|||
</pre> |
|||
Run the following python script |
|||
<pre> |
|||
import serial |
|||
ser = serial.Serial('/dev/ttyACM0', 9600) |
|||
ser.write('10') |
|||
</pre> |
|||
More with [[Firmata]] : https://github.com/lupeke/python-firmata/ |
|||
Download the firmata sketch on the Arduino board (using the Arduino IDE > Examples > Firmata > StandardFirmata) |
|||
Run the following python script |
|||
<pre> |
|||
from firmata import * |
|||
a = Arduino('/dev/ttyACM0') |
|||
a.pin_mode(13, firmata.OUTPUT) |
|||
a.delay(2) |
|||
while True: |
|||
a.digital_write(13, firmata.HIGH) |
|||
a.delay(2) |
|||
a.digital_write(13, firmata.LOW) |
|||
a.delay(2) |
|||
</pre> |
|||
===Lego Mindstorm NXT=== |
===Lego Mindstorm NXT=== |
||
Revision as of 07:24, 14 August 2013
Prérequis
- carte SD 8 GB (classe 10 si possible)
- clavier Logitech K400
- cable HDMI
- écran ou TV avec entrée HDMI (normal)
Réseau
Branchez votre RPI avec un cable Ethernet à votre box (Ethernet), un routeur, une TimeCapsule ... Par défaut, l'adresse IP est donné par le serveur DHCP de la box.
Si vous n'en avez pas, il est possible d'activer le partage internet sur votre Mac :
Préférences Système > Partage > Partage Internet : cochez Thunderbolt Ethernet puis Partage Internet
Pour connaitre l'adresse du RPI, une de ces 3 commandes;
ping 192.168.1.255 ping 192.168.255.255 ping 10.0.1.255 arp -a
Démarrage
Suivez les instructions : http://elinux.org/RPi_Beginners
Loggez vous : pi puis raspberry
Changez le mot de passe de pi
Lancez le desktop
startx
Configuration complémentaire
Voir http://www.tropfacile.net/doku.php/raspberry-pi/comment-passer-votre-raspberry-en-francais
sudo raspi-config
Sélectionnez SSD pour l'activer (enable) afin de pouvoir vous passer d'un écran pour vous logger (à distance) sur le RPI.
Configuration du clavier Logitech K400
sudo nano /etc/default/keyboard
#Keyboard configuration files
#Consult the keyboard(5) manual page.
XKBMODEL="logicd"
XXBLAYOUT="fr"
XKBVARIANT=" "
XKBOPTIONS=" "
BACKSPACE="guess"
Equipements supplémentaires
Listez les équipements USB branchés au moyen de la commande lsusb
lsusb Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. Bus 001 Device 004: ID 046d:c52b Logitech, Inc. Unifying Receiver Bus 001 Device 005: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)
Dongle Wifi USB
Webcam Logitech
Arduino Uno
Premiers Pas avec Raspberry Pi et Arduino
Lego Mindstorm NXT
Quelques idées
- Via USB : http://www.burf.org.uk/2012/12/28/raspberry-pi-and-the-lego-nxt/
- Carte d'extension BrickPi