1 / 15

Robootika lahenduste esitlus

Robootika lahenduste esitlus. Raul Liinev Martin Ligema Siim Suu Martin Tõnne. Idee. Arduino , ColorPal , Joystick ja tinkerkit seadmete kombineerimine õppimise eesmärgil. . Kasutus.

goro
Download Presentation

Robootika lahenduste esitlus

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Robootika lahenduste esitlus Raul Liinev Martin Ligema Siim Suu Martin Tõnne

  2. Idee Arduino, ColorPal, Joystickja tinkerkit seadmete kombineerimine õppimise eesmärgil.

  3. Kasutus Arduino, ColorPal, Joystickja tinkerkit seadmete kombineerimine. Värvide skännimineja nende liigutamine veebis.

  4. Arendus Arduino, ColorPal, Joystickja tinkerkit seadmete kombineerimine. Värvide skännimineja nende liigutamine veebis.

  5. KOOD

  6. ARDUINO.TXT #include <SoftwareSerial.h> constintsio = 2; // ColorPALconnectedtopin 2 constintunused = 255; // Non-existantpin # forSoftwareSerial constintsioBaud = 4800; constintwaitDelay = 200; // Received RGB valuesfromColorPAL intred; intgrn; intblu; #include <TinkerKit.h> TKButton button(I2); TKLightSensor ldr(I1); TKJoystick joystick(I0, I1); int x = 0; int y = 0; char buf[10]; // Setuptwosoftwareserials on thesamepin. SoftwareSerialserin(sio, unused); SoftwareSerialserout(unused, sio); voidsetup() { Serial.begin(9600); // reset(); // SendresettoColorPal serout.begin(sioBaud); pinMode(sio, OUTPUT); serout.print("= (00 $ m) !"); // Loop print values, see ColorPALdocumentation serout.end(); // Discontinueserial port fortransmitting serin.begin(sioBaud); // Setupserial port forreceiving pinMode(sio, INPUT); } voidloop() { //delay(2000); if (button.readSwitch() == HIGH) { x = joystick.readX(); y = joystick.readY(); sprintf(buf, "%d,", x); Serial.print(buf); sprintf(buf, "%d", y); Serial.println(buf); delay(500) ; //Serial.println(ldr.read()); //readData(); } } // ResetColorPAL; see ColorPALdocumentationforsequence voidreset() { delay(200); pinMode(sio, OUTPUT); digitalWrite(sio, LOW); pinMode(sio, INPUT); while (digitalRead(sio) != HIGH); pinMode(sio, OUTPUT); digitalWrite(sio, LOW); delay(80); pinMode(sio, INPUT); delay(waitDelay); } voidreadData() { char buffer[32]; if (serin.available() > 0) { // Waitfor a $ character, then read three 3 digithexnumbers buffer[0] = serin.read(); if (buffer[0] == '$') { for(int i = 0; i < 9; i++) { while (serin.available() == 0); // Waitfornextinputcharacter buffer[i] = serin.read(); if (buffer[i] == '$') // Returnearlyif $ characterencountered return; } parseAndPrint(buffer); delay(10); } } } // Parsethehexdataintointegers voidparseAndPrint(char * data) { sscanf (data, "%3x%3x%3x", &red, &grn, &blu); char buffer[32]; sprintf(buffer, "%4.4d_%4.4d_%4.4d", red, grn, blu); Serial.println(buffer); }

  7. PROCESS.TXT import processing.serial.*; SerialmyPort; // Theserial port intxPos = 1; // horizontalpositionofthegraph voidsetup () { // setthewindowsize: size(400, 300); // List all theavailableserial ports println(Serial.list()); // I knowthatthefirst port intheserial list on mymac // isalwaysmyArduino, so I open Serial.list()[0]. // Openwhatever port istheoneyou'reusing. myPort = newSerial(this, Serial.list()[2], 9600); // don'tgenerate a serialEvent() unlessyouget a newlinecharacter: myPort.bufferUntil('\n'); // setinitalbackground: background(0); } voiddraw () { } voidserialEvent (SerialmyPort) { // getthe ASCII string: String inString = myPort.readStringUntil('\n'); loadStrings("http://greeny.cs.tlu.ee/~liinevra/Robootika/11-11-13/index2.php/?tekst="+inString); if (inString != null) { println(inString); } }

  8. KOOD

More Related