æ¹æ³/æ¥éª¤
1
å®è£
SD Linuxç³»ç»
å¦å¾æ示ï¼å
åå°Arduino Software 1.5.3 ï¼Arduino IDEï¼åSD-Card Linux Imageä¸è½½å°æ¬æºï¼Arduino IDEå¨åé¢æ¥æ¾GPIOä¸Arduino IO ä¹é´çæ å°å
³ç³»æ¶éè¦ç¨å°ã
å¦å¾æ示ï¼å°SDCard1.0.4.tar.bz2解åååºç°ä¸ä¸ªâimage-full-galileoâçæ件夹ã
å¨MicroSD使ç¨åéå
å°å
¶ä»¥Fat32è¿è¡æ ¼å¼åï¼ç¶åå°âimage-full-galileoâæ件夹ä¸å°æææ件ç´æ¥æ·è´å°microSDå¡çæ ¹ç®å½ä¸ã
è¿å
¥Galileo
å°MicroSDæå°Galileoä¸ï¼å¨è·¯ç±å¨é¡µé¢çå·²è¿æ¥è®¾å¤å表ä¸ä¼çå°è®¾å¤å称为âclantonâæ线è¿æ¥è®¾å¤ï¼æ¾å°å
¶IPå°åï¼ç¶åä¸
Terminalï¼UnixåLinuxï¼Windowså¯ç¨Puttyï¼ä¸éè¿sshè¿å
¥Galileoï¼âssh
[email protected]âã
æææçæ¯ï¼è¿ä¸ªå¨MicroSDä¸è¿è¡çLinuxç³»ç»å¼å¯äºsshæå¡ï¼å¹¶ä¸rootè´¦å·æ²¡æ设置å¯ç ï¼å¯ä»¥ç´æ¥è¿å
¥ãå¦ä¸å¾æ示ï¼å¼¹åºä¸å¯¹è¯æ¡åè¾å
¥ âyesâå车å³å¯è¿å
¥Galileoï¼åºç°ä¸å¾ä¸ç âroot@clantonâ说æè¿ä¸æ¥æåå®æäº
å°è¿éï¼å¯è½ä¼æçé®äºï¼Galileoæ¿è½½ä¹æ¯æä¸ä¸ªæä½ç³»ç»çï¼microSDå¡ä¸ä¹æä¸ä¸ªLinuxï¼å¦ä½ä¿è¯ç°å¨è¿å
¥çå°±æ¯microSDå¡ä¸çç³»
ç»å¢ï¼å¨Terminalä¸è¾å
¥âcat/proc/versionâå³å¯æ¥çLinuxç³»ç»çæ¬ï¼æ¾ç¤ºä¸ºâ3.8.7-yocto-standardâï¼è¿å°±æ¯åé¢ä¸è½½ç为Galileoå®å¶çLinuxæä½ç³»ç»ï¼Yoctoã
æ¾å°é£ä¸ªå±äºä½ çGPIO
ä¸é¢å°±è¦å¼å§è¿ç¯æç« ä¸çæ ¸å¿é¨åï¼ä¹æ¯æé¾çä¸é¨ãæ¾Linux GPIO ä¸ Arduino IOä¹é´çæ å°å
³ç³»ï¼
å¦å³å¾æ示ï¼å¨â/sys/class/gpio/âä¸æå¤å¤§60å¤ä¸ªGPIOï¼å¦ä½æ¾åºå³ä¾§GPIOä¸å·¦ä¾§Arduino IDEä¸å¯¹åºçIOå¢ã
é¦å
å°0-13IOå£å
¨é¨è®¾ä¸ºâINPUTâè¾å
¥æ¨¡å¼
voidsetup(){//putyoursetupcodehere,torunonce:
pinMode(0,INPUT); pinMode(1,INPUT); pinMode(2,INPUT); pinMode(3,INPUT);
pinMode(4,INPUT); pinMode(5,INPUT); pinMode(6,INPUT); pinMode(7,INPUT);
pinMode(8,INPUT); pinMode(9,INPUT); pinMode(10,INPUT);
pinMode(11,INPUT); pinMode(12,INPUT); pinMode(13,INPUT); } voidloop(){
//putyourmaincodehere,torunrepeatedly: }
å¦å¾æ示ï¼å·¦ä¾§"pinMode(13,OUTPUT)"å°13å¼èå为è¾åºæ¨¡å¼ï¼å³ä¾§gpio7åæout模å¼ï¼å æ¤gpio7对åºçå°±æ¯Arduino IO 13ï¼pin13ï¼
æç
§è¿ç§æ¹æ³ä¾æ¬¡æ¾åºArduino IOä¸GPIOä¹é´å¦ä¸ç对åºå
³ç³»
GPIODigitalI/Ogpio11pin0
gpio12pin1 gpio13pin2 gpio14pin3 gpio6pin4 gpio0pin5 gpio1pin6
gpio38pin7 gpio40pin8 gpio4pin9 gpio10pin10 gpio5pin11 gpio15pin12
gpio7pin13
ä¸é¢å°±éè¦æ¥å¯¹ä¸é¢æ¾å°çgpio对åºå
³ç³»è¿è¡éªè¯äºãâecho "out"
>/sys/class/gpio/gpio*/directionâ为å°gpioå为è¾åºæ¨¡å¼ï¼âecho "1"
>/sys/class/gpio/gpio*/valueâ为å°gpioè¾åºé«çµå¹³ãç¶åå°±æäºä¸é¢è¿æ®µpythonç¨åºï¼è¿æ®µç¨åºä¾æ¬¡å°
pin13,pin12,pin11,pin10å个å¼èçLEDç¹äº®ç¶åå
³éï¼ä½ç±äºpythonç¨åºçæ§è¡æçé®é¢ï¼åºè¯¥ææLEDåæ¶ç¹äº®æäºå»¶æ¶
æ为æµæ°´ç¯ï¼å¦ä¸å¾æ示ææãè¿æ®µç¨åºå¨Linuxç³»ç»çä»»ææ件夹å
åå¯ã
importos,timewhileTrue:os.system('echo"out">/sys/class/gpio/gpio7/direction')
os.system('echo"1">/sys/class/gpio/gpio7/value')
os.system('echo"out">/sys/class/gpio/gpio15/direction')
os.system('echo"1">/sys/class/gpio/gpio15/value')
os.system('echo"out">/sys/class/gpio/gpio5/direction')
os.system('echo"1">/sys/class/gpio/gpio5/value')
os.system('echo"out">/sys/class/gpio/gpio10/direction')
os.system('echo"1">/sys/class/gpio/gpio10/value') time.sleep(0.2)
os.system('echo"0">/sys/class/gpio/gpio5/value')
os.system('echo"0">/sys/class/gpio/gpio15/value')
os.system('echo"0">/sys/class/gpio/gpio7/value')
os.system('echo"0">/sys/class/gpio/gpio10/value') time.sleep(0.2)