您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > ArduinoProject
ArduinoProjectAOpenSourceHardwareandSoftwareProject1Wednesday,July21,2010ArduinoProject•ATmelAVRMicroController•OpenSourceHardware•OpenSourceSoftware•Theboardcanbebuildbyhand••Inexpensive•CrossPlatform•SimpleandClearProgrammingEnvironment•OpenSourceandExtensibleSoftware•OpenSourceandExtensibleHardware3Wednesday,July21,2010Licensing•PhysicallyembeddinganArduinoboardinsideacommercialproductdoesnotrequireyoutodiscloseoropen-sourceanyinformationaboutitsdesign.•DerivingthedesignofacommercialproductfromtheEaglefilesforanArduinoboardrequiresyoutoreleasethemodifiedfilesunderthesameCreativeCommonsAttributionShare-Alikelicense.Youmaymanufactureandselltheresultingproduct.•UsingtheArduinocoreandlibrariesforthefirmwareofacommercialproductdoesnotrequireyoutoreleasethesourcecodeforthefirmware.TheLGPLdoes,however,requireyoutomakeavailableobjectfilesthatallowfortherelinkingofthefirmwareagainstupdatedversionsoftheArduinocoreandlibraries.AnymodificationstothecoreandlibrariesmustbereleasedundertheLGPL.•ThesourcecodefortheArduinoenvironmentiscoveredbytheGPL,whichrequiresanymodificationstobeopen-sourcedunderthesamelicense.Itdoesnotpreventthesaleofderivativesoftwareoritsinclusionincommercialproducts.4Wednesday,July21,2010ATMELAVR•8bitAVRRISCProcessorupto20MIPS•4/8/16/32KBFlashMemory•256/512/1024BytesEEPROM•512/1024/2048ByteSRAM•6PWM/10bitADC/USART/SPI/I2C•1.8Vto5.5V•InternalOSC(0to20MHz)•23I/OLines5Wednesday,July21,2010ATMELAVR6Wednesday,July21,2010HardwareLilyPadProSerialBoardMegaDiecimilaMini7Wednesday,July21,2010HardwareMicrocontroller:ATmega168/ATmega368/ATmega1280OperatingVoltage:5VInputVoltage(recommended):7-12VInputVoltage(limits):6-20VDigitalI/OPins:14(ofwhich6providePWMoutput)AnalogInputPins:6DCCurrentperI/OPin:40mADCCurrentfor3.3VPin:50mAFlashMemory:16KB(ATmega168):32KB(ATmega328):2KBusedbybootloaderSRAM:1KB(ATmega168):2KB(ATmega328)EEPROM:512bytes(ATmega168):1KB(ATmega328)ClockSpeed:16MHz8Wednesday,July21,2010PICv.s.AVRPICAVRPIC18F452($10.35)AVRTools(FreeOpenSource)8/16/32Bit8Bit40MHzClock20MHzClock16KB/32KBFlash16KB/32KBFlash768/1536ByteSRAM1024/2048ByteSRAM256ByteEEPROM512/1024ByteEEPROMESUARTSUARTSPISPII2CI2C10bitA/D10BitA/DMPLAB/CCS($450)/SDCC(Free)Atmega328($8.17)9Wednesday,July21,2010HardwareOpenSource10Wednesday,July21,2010HardwareOpenSource11Wednesday,July21,2010Plug-inShieldsEthernetShieldMotorControllerVideoShieldTouchShieldXportEthernetShieldGPSDatalogerShield12Wednesday,July21,2010OpenSourceSoftware•IDEandcompilerforWindows/Linux/OSXcrossplatform•SimpleIDEviaJava•EasytodevelopmentwithoutMICE•Workwith/withoutBootloader13Wednesday,July21,2010WorkFlow14Wednesday,July21,2010SoftwareIDE15Wednesday,July21,2010BlinkLEDSource/*BlinkTurnsonanLEDonforonesecond,thenoffforonesecond,repeatedly.Thecircuit:*LEDconnectedfromdigitalpin13toground.*/intledPin=13;//LEDconnectedtodigitalpin13//Thesetup()methodrunsonce,whenthesketchstartsvoidsetup(){//initializethedigitalpinasanoutput:pinMode(ledPin,OUTPUT);}//theloop()methodrunsoverandoveragain,//aslongastheArduinohaspowervoidloop(){digitalWrite(ledPin,HIGH);//settheLEDondelay(1000);//waitforaseconddigitalWrite(ledPin,LOW);//settheLEDoffdelay(1000);//waitforasecond}16Wednesday,July21,2010WebServerCode/**WebServer**Asimplewebserverthatshowsthevalueoftheanaloginputpins.*/#includeEthernet.hbytemac[]={0xDE,0xAD,0xBE,0xEF,0xFE,0xED};byteip[]={10,0,0,177};Serverserver(80);voidsetup(){Ethernet.begin(mac,ip);server.begin();}voidloop(){Clientclient=server.available();if(client){//anhttprequestendswithablanklinebooleancurrent_line_is_blank=true;while(client.connected()){if(client.available()){charc=client.read();//ifwe'vegottentotheendoftheline(receivedanewline//character)andthelineisblank,thehttprequesthasended,//sowecansendareplyif(c=='\n'&¤t_line_is_blank){//sendastandardhttpresponseheaderclient.println(HTTP/1.1200OK);client.println(Content-Type:text/html);client.println();//outputthevalueofeachanaloginputpinfor(inti=0;i6;i++){client.print(analoginput);client.print(i);client.print(is);client.print(analogRead(i));client.println(br/);}break;}if(c=='\n'){//we'restartinganewlinecurrent_line_is_blank=true;}elseif(c!='\r'){//we'vegottenacharacteronthecurrentlinecurrent_line_is_blank=false;}}}//givethewebbrowsertimetoreceivethedatadelay(1);client.stop();}}17Wednesday,July21,2010Ethernet.h#ifndefEthernet_h#defineEthernet_h#includeinttypes.h#includeClient.h#includeServer.hclassEthernetClass{private:public:staticuint8_t_state[MAX_SOCK_NUM];staticuint16_t_server_port[MAX_SOCK_NUM];voidbegin(uint8_t*,uint8_t*);voidbegin(uint8_t*,uint8_t*,uint8_t*);voidbegin(uint8_t*,uint8_t*,uint8_t*,uint8_t*);friendclassClient;friendclassServer;};externEthernetClassEthernet;#endif18Wednesday,July21,2010Ethernet.cppexternC{#includetypes.h#includew5100.h}#includeEthernet.h//XXX:don'tmakeassumptionsaboutthevalueofMAX_SOCK_NUM.uint8_tEthernetClass::_state[MAX_SOCK_NUM]={0,0,0,0};uint16_tEthernetClass::_server_port[MAX_SOCK_NUM]={0,0,0,0};voidEthernetClass
本文标题:ArduinoProject
链接地址:https://www.777doc.com/doc-6296502 .html