diff --git a/arduino/all the sketchs of my life/0sony/Cellular_Shield_Passthrough/Cellular_Shield_Passthrough.ino b/arduino/all the sketchs of my life/0sony/Cellular_Shield_Passthrough/Cellular_Shield_Passthrough.ino new file mode 100644 index 0000000..99aa2f1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/Cellular_Shield_Passthrough/Cellular_Shield_Passthrough.ino @@ -0,0 +1,110 @@ +/* +SparkFun Cellular Shield - Pass-Through Sample Sketch +SparkFun Electronics +Written by Ryan Owens +3/8/10 + +Description: This sketch is written to interface an Arduino Duemillanove to a Cellular Shield from SparkFun Electronics. +The cellular shield can be purchased here: http://www.sparkfun.com/commerce/product_info.php?products_id=9607 +In this sketch serial commands are passed from a terminal program to the SM5100B cellular module; and responses from the cellular +module are posted in the terminal. More information is found in the sketch comments. + +An activated SIM card must be inserted into the SIM card holder on the board in order to use the device! + +This sketch utilizes the NewSoftSerial library written by Mikal Hart of Arduiniana. The library can be downloaded at this URL: +http://arduiniana.org/libraries/NewSoftSerial/ + +This code is provided under the Creative Commons Attribution License. More information can be found here: +http://creativecommons.org/licenses/by/3.0/ + +(Use our code freely! Please just remember to give us credit where it's due. Thanks!) +*/ + +#include //Include the NewSoftSerial library to send serial commands to the cellular module. +#include //Used for string manipulations + +char incoming_char=0; //Will hold the incoming character from the Serial Port. + +SoftwareSerial cell(2,3); //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin. + +void setup() +{ + //Initialize serial ports for communication. + Serial.begin(9600); + cell.begin(9600); + + //Let's get started! + Serial.println("Starting SM5100B Communication..."); +} + +void loop() { + //If a character comes in from the cellular module... + if(cell.available() >0) + { + incoming_char=cell.read(); //Get the character from the cellular serial port. + Serial.print(incoming_char); //Print the incoming character to the terminal. + } + //If a character is coming from the terminal to the Arduino... + if(Serial.available() >0) + { + incoming_char=Serial.read(); //Get the character coming from the terminal + cell.print(incoming_char); //Send the character to the cellular module. + } +} + +/* SM5100B Quck Reference for AT Command Set +*Unless otherwise noted AT commands are ended by pressing the 'enter' key. + +1.) Make sure the proper GSM band has been selected for your country. For the US the band must be set to 7. +To set the band, use this command: AT+SBAND=7 + +2.) After powering on the Arduino with the shield installed, verify that the module reads and recognizes the SIM card. +With a terimal window open and set to Arduino port and 9600 buad, power on the Arduino. The startup sequence should look something +like this: + +Starting SM5100B Communication... + ++SIND: 1 ++SIND: 10,"SM",1,"FD",1,"LD",1,"MC",1,"RC",1,"ME",1 + +Communication with the module starts after the first line is displayed. The second line of communication, +SIND: 10, tells us if the module +can see a SIM card. If the SIM card is detected every other field is a 1; if the SIM card is not detected every other field is a 0. + +3.) Wait for a network connection before you start sending commands. After the +SIND: 10 response the module will automatically start trying +to connect to a network. Wait until you receive the following repsones: + ++SIND: 11 ++SIND: 3 ++SIND: 4 + +The +SIND response from the cellular module tells the the modules status. Here's a quick run-down of the response meanings: +0 SIM card removed +1 SIM card inserted +2 Ring melody +3 AT module is partially ready +4 AT module is totally ready +5 ID of released calls +6 Released call whose ID= +7 The network service is available for an emergency call +8 The network is lost +9 Audio ON +10 Show the status of each phonebook after init phrase +11 Registered to network + +After registering on the network you can begin interaction. Here are a few simple and useful commands to get started: + +To make a call: +AT command - ATDxxxyyyzzzz +Phone number with the format: (xxx)yyy-zzz + +If you make a phone call make sure to reference the devices datasheet to hook up a microphone and speaker to the shield. + +To send a txt message: +AT command - AT+CMGF=1 +This command sets the text message mode to 'text.' +AT command = AT+CMGS="xxxyyyzzzz"(carriage return)'Text to send'(CTRL+Z) +This command is slightly confusing to describe. The phone number, in the format (xxx)yyy-zzzz goes inside double quotations. Press 'enter' after closing the quotations. +Next enter the text to be send. End the AT command by sending CTRL+Z. This character can't be sent from Arduino's terminal. Use an alternate terminal program like Hyperterminal, +Tera Term, Bray Terminal or X-CTU. + +The SM5100B module can do much more than this! Check out the datasheets on the product page to learn more about the module.*/ diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_4RELES_203/Ethernet.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_4RELES_203/Ethernet.ino new file mode 100644 index 0000000..ae5591c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_4RELES_203/Ethernet.ino @@ -0,0 +1,98 @@ +char comando[30]; +char comandoOK[30]; +int contador = 0; + +void ethernet() { + EthernetClient client = server.available(); + + if (client) { + //debug Serial.println("comecando..."); + contador =0; + limpa(); + // an http request ends with a blank line + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + //debug Serial.print(c); + //Serial.println("aaa"); + comando[contador++]=c; + if (c == '\n') { + //debug Serial.println("\nComando recebido"); + //if(c=='\n') { + //debug Serial.print("COMANDO ORIGINAL: "); + //debug Serial.println(comando); + contador=0; + //debug Serial.print("Comando OK antes: "); + //debug Serial.println(comandoOK); + + limpaOK(); + //debug Serial.print("Comando OK depois do limpa: "); + //debug Serial.println(comandoOK); + + for(int x=5;x<30;x++) { + if(comando[x]==' ') break; + comandoOK[contador++]=comando[x]; + //Serial.println(x); + } + //debug Serial.println("Comando OK depois: "); + //debug Serial.println(comandoOK); + //limpa(); + + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println("Connection: close"); + client.println(); + client.println(""); + client.println(""); + //debug Serial.println("Vai executar..."); + homeDevice.execute(comandoOK); + //debug Serial.println("Terminou..."); + + client.println(""); + client.flush(); + + break; + + } + if (c == '\n') { + // you're starting a new line + currentLineIsBlank = true; + } + else if (c != '\r') { + // you've gotten a character on the current line + currentLineIsBlank = false; + } + + } + } + //debug Serial.println("Finalizou..."); + + // give the web browser time to receive the data + delay(5); + // close the connection: + client.stop(); + //Serial.println("client disonnected"); + + } +} + +void limpa() { + for(int x=0;x<30;x++) { + comando[x]='\0'; + comandoOK[x]='\0'; + } +} +void limpaOK() { + //Serial.print("dentro do limpa antes: "); + //Serial.println(comandoOK); + + for(int x=0;x<30;x++) { + comandoOK[x]='\0'; + } + //Serial.print("dentro do limpa depois: "); + //Serial.println(comandoOK); + +} + + diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_4RELES_203/RBS_4RELES_203.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_4RELES_203/RBS_4RELES_203.ino new file mode 100644 index 0000000..b4c075a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_4RELES_203/RBS_4RELES_203.ino @@ -0,0 +1,36 @@ +#include "Device.h" +#include +#include +#include + +Device homeDevice=Device("central-device"); +byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xEC, 0x09 }; //Atentar ao MAC unico de cada placa! +IPAddress ip(192,168,0, 203); +EthernetServer server(80); + +void setup() { + Serial.begin(115200); + homeDevice.add("LED", DIGITAL, 13); + homeDevice.add("L1F", DIGITAL, 6); //Luz 1 frontal + homeDevice.add("L1T", DIGITAL, 7); // Luz 1 tras + homeDevice.add("L2F", DIGITAL, 8); // Luz 2 frontal + homeDevice.add("L2T", DIGITAL, 9); // Luz 2 tras + + //homeDevice.add("light", ANALOG, 3); + //homeDevice.add("temp", ANALOG, 2); + //homeDevice.add("ir", CUSTOM, 3, irSender_read , irSender_write); + //homeDevice.add("panasonic", CUSTOM, 0, rs232_read, rs232_write); + //homeDevice.add("rs2321", CUSTOM, 0, rs232_read, rs232_write); + + + Ethernet.begin(mac, ip); + server.begin(); +} + +void loop() { + //Para aceitar requisições por Serial + //homeDevice.loop(); + //Para aceitar requisições por TCP/IP + ethernet(); +} + diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO/Ethernet.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO/Ethernet.ino new file mode 100644 index 0000000..cd1d061 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO/Ethernet.ino @@ -0,0 +1,58 @@ +char comando[30]; +char comandoOK[30]; +int contador = 0; + +void ethernet() { + EthernetClient client = server.available(); + if (client) { + contador =0; + // an http request ends with a blank line + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + //Serial.println("aaa"); + comando[contador++]=c; + if(c=='\n') { + //Serial.print("COMANDO: "); + //Serial.println(comando); + + + contador=0; + for(int x=5;x<30;x++) { + if(comando[x]==' ') break; + comandoOK[contador++]=comando[x]; + //Serial.println(x); + } + limpa(); + + //Serial.print("COMANDO OK: "); + //Serial.println(comandoOK); + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println("Connection: close"); + client.println(); + client.println(homeDevice.execute(comandoOK)); + client.flush(); + break; + + } + + } + + } + // give the web browser time to receive the data + delay(5); + // close the connection: + client.stop(); + //Serial.println("client disonnected"); + + } +} + +void limpa() { + for(int x=0;x<30;x++) { + comando[x]='\0'; + comandoOK[x]='\0'; + } +} diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO/IR.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO/IR.ino new file mode 100644 index 0000000..1887cd1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO/IR.ino @@ -0,0 +1,26 @@ +IRsend irsend; +//unsigned int rawCodes[] = { 19850,1250,450,1200,450,400,1250,1250,400,400,1250,400,1250,450,1200,450,1250,1250,400,400,1250,450,1200,450}; +// m1150 s550 m1100 s550 m300 s1300 m1200 s500 m300 s1350 m300 s1350 m350 s1300 m350 s1300 m1150 s550 m300 s1350 m300 s1350 m300 + +unsigned int rawUp[] = { 1150 ,550 ,1100 ,550 ,300 ,1300 ,1200 ,500 ,300 ,1350 ,300 ,1350 ,350 ,1300 ,350 ,1300 ,1150 ,550 ,300 ,1350 ,300 ,1350 ,300}; +unsigned int rawDown[] = { 1150 ,550 ,1100 ,550 ,300 ,1350 ,1100 ,550 ,300 ,1350 ,300 ,1350 ,1150 ,500 ,300 ,1400 ,300 ,1300 ,350 ,1350 ,300 ,1350 ,300}; + + +char* irSender_write(char* args) { + int codigo = atoi(args); + if(codigo==0) { + irsend.sendRaw(rawUp,23,38); + } + else if(codigo==1) { + irsend.sendRaw(rawDown,23,38); + } + //else if(codigo==2) { //Faltou o STOP da tela + + //} +} + +//Nao tem leitura de emissor de IR... +char* irSender_read() { + char* r="\0"; +} + diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO/Panasonic.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO/Panasonic.ino new file mode 100644 index 0000000..7581c14 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO/Panasonic.ino @@ -0,0 +1,31 @@ +char* rs232_write1(char* args) { + int codigo = atoi(args); + if(codigo==1) { + Serial.write(0x02); //Power On + Serial.write("PON"); + Serial.write(0x03); + } + else if(codigo==2) { //Power Off + Serial.write(0x02); + Serial.write("POF"); + Serial.write(0x03); + } + else if(codigo==3) { //Volume UP + Serial.write(0x02); + Serial.write("AUU"); + Serial.write(0x03); + } + else if(codigo==4) { //Volume Down + Serial.write(0x02); + Serial.write("AUD"); + Serial.write(0x03); + } +} + +char* rs232_read1() { + char* r="\0"; + //while(Serial.available()) { + // Serial.print((char) Serial.read()); + //} +} + diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO/RBS_PROJETOR_TELA_UNO.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO/RBS_PROJETOR_TELA_UNO.ino new file mode 100644 index 0000000..31eafd8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO/RBS_PROJETOR_TELA_UNO.ino @@ -0,0 +1,29 @@ +#include "Device.h" +#include +#include +#include + +Device homeDevice=Device("central-device"); +byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xEC, 0x26 }; //Atentar ao MAC unico de cada placa! +IPAddress ip(192,168,0, 201); +EthernetServer server(80); + +void setup() { + + homeDevice.add("tela1", CUSTOM, 3, irSender_read , irSender_write); + //panasonic com max232 - 19200 + Serial.begin(19200); + homeDevice.add("pana1", CUSTOM, 0, rs232_read1, rs232_write1); + + + Ethernet.begin(mac, ip); + server.begin(); +} + +void loop() { + //Para aceitar requisições por Serial + //homeDevice.loop(); + //Para aceitar requisições por TCP/IP + ethernet(); +} + diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO_2/Ethernet.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO_2/Ethernet.ino new file mode 100644 index 0000000..a2357c7 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO_2/Ethernet.ino @@ -0,0 +1,58 @@ +char comando[30]; +char comandoOK[30]; +int contador = 0; + +void ethernet() { + EthernetClient client = server.available(); + if (client) { + contador =0; + // an http request ends with a blank line + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + //Serial.println("aaa"); + comando[contador++]=c; + if(c=='\n') { + //Serial.print("COMANDO: "); + //Serial.println(comando); + + + contador=0; + for(int x=5;x<30;x++) { + if(comando[x]==' ') break; + comandoOK[contador++]=comando[x]; + //Serial.println(x); + } + limpa(); + + //Serial.print("COMANDO OK: "); + //Serial.println(comandoOK); + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println("Connection: close"); + client.println(); + client.println(homeDevice.execute(comandoOK)); + client.flush(); + break; + + } + + } + + } + // give the web browser time to receive the data + delay(5); + // close the connection: + client.stop(); + //Serial.println("client disonnected"); + + } +} + +void limpa() { + for(int x=0;x<30;x++) { + comando[x]=='\0'; + comandoOK[x]=='\0'; + } +} diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO_2/IR.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO_2/IR.ino new file mode 100644 index 0000000..1887cd1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO_2/IR.ino @@ -0,0 +1,26 @@ +IRsend irsend; +//unsigned int rawCodes[] = { 19850,1250,450,1200,450,400,1250,1250,400,400,1250,400,1250,450,1200,450,1250,1250,400,400,1250,450,1200,450}; +// m1150 s550 m1100 s550 m300 s1300 m1200 s500 m300 s1350 m300 s1350 m350 s1300 m350 s1300 m1150 s550 m300 s1350 m300 s1350 m300 + +unsigned int rawUp[] = { 1150 ,550 ,1100 ,550 ,300 ,1300 ,1200 ,500 ,300 ,1350 ,300 ,1350 ,350 ,1300 ,350 ,1300 ,1150 ,550 ,300 ,1350 ,300 ,1350 ,300}; +unsigned int rawDown[] = { 1150 ,550 ,1100 ,550 ,300 ,1350 ,1100 ,550 ,300 ,1350 ,300 ,1350 ,1150 ,500 ,300 ,1400 ,300 ,1300 ,350 ,1350 ,300 ,1350 ,300}; + + +char* irSender_write(char* args) { + int codigo = atoi(args); + if(codigo==0) { + irsend.sendRaw(rawUp,23,38); + } + else if(codigo==1) { + irsend.sendRaw(rawDown,23,38); + } + //else if(codigo==2) { //Faltou o STOP da tela + + //} +} + +//Nao tem leitura de emissor de IR... +char* irSender_read() { + char* r="\0"; +} + diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO_2/Panasonic.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO_2/Panasonic.ino new file mode 100644 index 0000000..813417c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO_2/Panasonic.ino @@ -0,0 +1,32 @@ +char* rs232_write1(char* args) { + Serial.begin(19200); + int codigo = atoi(args); + if(codigo==1) { + Serial.write(0x02); //Power On + Serial.write("PON"); + Serial.write(0x03); + } + else if(codigo==2) { //Power Off + Serial.write(0x02); + Serial.write("POF"); + Serial.write(0x03); + } + else if(codigo==3) { //Volume UP + Serial.write(0x02); + Serial.write("AUU"); + Serial.write(0x03); + } + else if(codigo==4) { //Volume Down + Serial.write(0x02); + Serial.write("AUD"); + Serial.write(0x03); + } +} + +char* rs232_read1() { + char* r="\0"; + //while(Serial.available()) { + // Serial.print((char) Serial.read()); + //} +} + diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO_2/RBS_PROJETOR_TELA_UNO_2.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO_2/RBS_PROJETOR_TELA_UNO_2.ino new file mode 100644 index 0000000..70064f6 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_PROJETOR_TELA_UNO_2/RBS_PROJETOR_TELA_UNO_2.ino @@ -0,0 +1,28 @@ +#include "Device.h" +#include +#include +#include + +Device homeDevice=Device("central-device"); +byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xEC, 0x7D }; //Atentar ao MAC unico de cada placa! +IPAddress ip(192,168,0, 202); +EthernetServer server(80); + +void setup() { + + homeDevice.add("tela2", CUSTOM, 3, irSender_read , irSender_write); + homeDevice.add("pana2", CUSTOM, 0, rs232_read1, rs232_write1); + + + + Ethernet.begin(mac, ip); + server.begin(); +} + +void loop() { + //Para aceitar requisições por Serial + //homeDevice.loop(); + //Para aceitar requisições por TCP/IP + ethernet(); +} + diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_1/Ethernet.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_1/Ethernet.ino new file mode 100644 index 0000000..78d2944 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_1/Ethernet.ino @@ -0,0 +1,98 @@ +char comando[30]; +char comandoOK[30]; +int contador = 0; + +void ethernet() { + EthernetClient client = server.available(); + + if (client) { + //debug Serial.println("comecando..."); + contador =0; + limpa(); + // an http request ends with a blank line + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + //debug Serial.print(c); + //Serial.println("aaa"); + comando[contador++]=c; + if (c == '\n') { + //debug Serial.println("\nComando recebido"); + //if(c=='\n') { + //debug Serial.print("COMANDO ORIGINAL: "); + //debug Serial.println(comando); + contador=0; + //debug Serial.print("Comando OK antes: "); + //debug Serial.println(comandoOK); + + limpaOK(); + //debug Serial.print("Comando OK depois do limpa: "); + //debug Serial.println(comandoOK); + + for(int x=5;x<30;x++) { + if(comando[x]==' ') break; + comandoOK[contador++]=comando[x]; + //Serial.println(x); + } + //debug Serial.println("Comando OK depois: "); + //debug Serial.println(comandoOK); + //limpa(); + + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println("Connection: close"); + client.println(); + client.println(""); + client.println(""); + //debug Serial.println("Vai executar..."); + homeDevice.execute(comandoOK); + //debug Serial.println("Terminou..."); + + client.println(""); + client.flush(); + + break; + + } + if (c == '\n') { + // you're starting a new line + currentLineIsBlank = true; + } + else if (c != '\r') { + // you've gotten a character on the current line + currentLineIsBlank = false; + } + + } + } + //debug Serial.println("Finalizou..."); + + // give the web browser time to receive the data + delay(5); + // close the connection: + client.stop(); + //Serial.println("client disonnected"); + + } +} + +void limpa() { + for(int x=0;x<30;x++) { + comando[x]='\0'; + comandoOK[x]='\0'; + } +} +void limpaOK() { + //Serial.print("dentro do limpa antes: "); + //Serial.println(comandoOK); + + for(int x=0;x<30;x++) { + comandoOK[x]='\0'; + } + //Serial.print("dentro do limpa depois: "); + //Serial.println(comandoOK); + +} + +7 diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_1/Kramer.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_1/Kramer.ino new file mode 100644 index 0000000..ef724ed --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_1/Kramer.ino @@ -0,0 +1,77 @@ + +//codigos para matrix switcher Kramer, IN-OUT, ex 11 -> In 1, Out 1. + +char* kramer_write(char* args) { + Serial.begin(9600); //kramer serial - conectar no UNO no TX1 e RX0, lembrar de soltar os fios antes de subir firmware + int codigo = atoi(args); + //Serial.println("vamos la"); + if(codigo==11) { + Serial.write(0x01); + Serial.write(0x81); + Serial.write(0x81); + Serial.write(0x81); + + } + else if(codigo==12) { + Serial.write(0x01); + Serial.write(0x81); + Serial.write(0x82); + Serial.write(0x81); + + } + + else if(codigo==21) { + Serial.write(0x01); + Serial.write(0x82); + Serial.write(0x81); + Serial.write(0x81); + + } + + else if(codigo==22) { + Serial.write(0x01); + Serial.write(0x82); + Serial.write(0x82); + Serial.write(0x81); + + } + + else if(codigo==31) { + Serial.write(0x01); + Serial.write(0x83); + Serial.write(0x81); + Serial.write(0x81); + + } + else if(codigo==32) { + Serial.write(0x01); + Serial.write(0x83); + Serial.write(0x82); + Serial.write(0x81); + + } + else if(codigo==41) { + Serial.write(0x01); + Serial.write(0x84); + Serial.write(0x81); + Serial.write(0x81); + + } + else if(codigo==42) { + Serial.write(0x01); + Serial.write(0x84); + Serial.write(0x82); + Serial.write(0x81); + + } +} + + +char* kramer_read() { + char* r="\0"; + //while(Serial.available()) { + // Serial.print((char) Serial.read()); + //} +} + + diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_1/RBS_RACK_UNO_1.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_1/RBS_RACK_UNO_1.ino new file mode 100644 index 0000000..2214789 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_1/RBS_RACK_UNO_1.ino @@ -0,0 +1,34 @@ +#include "Device.h" +#include +#include +#include + +Device homeDevice=Device("central-device"); +byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xEC, 0x0F }; +IPAddress ip(192,168,0, 210); +EthernetServer server(80); + +void setup() { + //Serial.begin(115200); + //homeDevice.add("LED", DIGITAL, 6); + //homeDevice.add("relay1", DIGITAL, 6); + //homeDevice.add("relay2", DIGITAL, 7); + //homeDevice.add("light", ANALOG, 3); + //homeDevice.add("temp", ANALOG, 2); + homeDevice.add("teac1", CUSTOM, 3, irSender_read , irSender_write); + //homeDevice.add("teac2", CUSTOM, 3, irSender_read , irSender_write); + homeDevice.add("kramer", CUSTOM, 0, kramer_read, kramer_write); //kramer na serial - TX1/RX1 + //homeDevice.add("polycom", CUSTOM, 0, polycom_read, polycom_write); //polycom na serial2 + + + Ethernet.begin(mac, ip); + server.begin(); +} + +void loop() { + //Para aceitar requisições por Serial + //homeDevice.loop(); + //Para aceitar requisições por TCP/IP + ethernet(); +} + diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_1/TEAC1.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_1/TEAC1.ino new file mode 100644 index 0000000..20e0a7d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_1/TEAC1.ino @@ -0,0 +1,37 @@ +IRsend irsend; +char* irSender_write(char* args) { + int codigo = atoi(args); + if(codigo==0) { + irsend.sendNEC(0x81CEE01F,32); //on off + } + else if(codigo==1) { + irsend.sendNEC(0x81CE807F,32); //Phono + } + else if(codigo==2) { + irsend.sendNEC(0x81CEC03F,32); //FM + } + else if(codigo==3) { + irsend.sendNEC(0x81CE40BF,32); //CD - PC1 + } + else if(codigo==4) { + irsend.sendNEC(0x81CE08F7,32); //AUX - Polycom + } + else if(codigo==5) { + irsend.sendNEC(0x81CE20DF,32); //TAPE MONITOR + } + else if(codigo==6) { + irsend.sendNEC(0x81CE609F,32); //Volume Down + } + else if(codigo==7) { + irsend.sendNEC(0x81CEA05F,32); //Volume UP + } + else if(codigo==8) { + irsend.sendNEC(0x81CE10EF,32); //MUTE + } +} + +//Nao tem leitura de emissor de IR... +char* irSender_read() { + char* r="\0"; +} + diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_2/Ethernet.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_2/Ethernet.ino new file mode 100644 index 0000000..19a6ac7 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_2/Ethernet.ino @@ -0,0 +1,58 @@ +char comando[30]; +char comandoOK[30]; +int contador = 0; + +void ethernet() { + EthernetClient client = server.available(); + if (client) { + contador =0; + // an http request ends with a blank line + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + //Serial.println("aaa"); + comando[contador++]=c; + if(c=='\n') { + ///Serial.print("COMANDO: "); + //Serial.println(comando); + + + contador=0; + for(int x=5;x<30;x++) { + if(comando[x]==' ') break; + comandoOK[contador++]=comando[x]; + //Serial.println(x); + } + limpa(); + + //Serial.print("COMANDO OK: "); + //Serial.println(comandoOK); + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println("Connection: close"); + client.println(); + client.println(homeDevice.execute(comandoOK)); + client.flush(); + break; + + } + + } + + } + // give the web browser time to receive the data + delay(5); + // close the connection: + client.stop(); + //Serial.println("client disonnected"); + + } +} + +void limpa() { + for(int x=0;x<30;x++) { + comando[x]=='\0'; + comandoOK[x]=='\0'; + } +} diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_2/Polycom.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_2/Polycom.ino new file mode 100644 index 0000000..88ffd70 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_2/Polycom.ino @@ -0,0 +1,24 @@ + +/*char* polycom_write(char* args) { + //Serial.println("Iniciando comunicao com Polycom"); + //Serial1.begin(19200); + + + int codigo = atoi(args); + if(codigo==1) { + //Serial1.println("camera near 2"); + } + else if(codigo==2) { + //Serial1.print("reboot\r\n"); + } +} + +char* polycom_read() { + char* r="\0"; + + Serial.println("Recebendo REsposta"); + while(Serial1.available()) { + Serial.print((char) Serial1.read(),DEC); + } +} +*/ diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_2/RBS_RACK_UNO_2.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_2/RBS_RACK_UNO_2.ino new file mode 100644 index 0000000..015088d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_2/RBS_RACK_UNO_2.ino @@ -0,0 +1,28 @@ +#include "Device.h" +#include +#include +#include + +Device homeDevice=Device("central-device"); +byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xEC, 0x0A }; +IPAddress ip(192,168,0, 211); +EthernetServer server(80); + +void setup() { + + homeDevice.add("teac2", CUSTOM, 3, irSender_read , irSender_write); + + //homeDevice.add("polycom", CUSTOM, 0, polycom_read, polycom_write); //polycom ainda nao esta sendo controlado + + + Ethernet.begin(mac, ip); + server.begin(); +} + +void loop() { + //Para aceitar requisições por Serial + //homeDevice.loop(); + //Para aceitar requisições por TCP/IP + ethernet(); +} + diff --git a/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_2/TEAC2.ino b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_2/TEAC2.ino new file mode 100644 index 0000000..20e0a7d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DNTV_RBS/RBS_RACK_UNO_2/TEAC2.ino @@ -0,0 +1,37 @@ +IRsend irsend; +char* irSender_write(char* args) { + int codigo = atoi(args); + if(codigo==0) { + irsend.sendNEC(0x81CEE01F,32); //on off + } + else if(codigo==1) { + irsend.sendNEC(0x81CE807F,32); //Phono + } + else if(codigo==2) { + irsend.sendNEC(0x81CEC03F,32); //FM + } + else if(codigo==3) { + irsend.sendNEC(0x81CE40BF,32); //CD - PC1 + } + else if(codigo==4) { + irsend.sendNEC(0x81CE08F7,32); //AUX - Polycom + } + else if(codigo==5) { + irsend.sendNEC(0x81CE20DF,32); //TAPE MONITOR + } + else if(codigo==6) { + irsend.sendNEC(0x81CE609F,32); //Volume Down + } + else if(codigo==7) { + irsend.sendNEC(0x81CEA05F,32); //Volume UP + } + else if(codigo==8) { + irsend.sendNEC(0x81CE10EF,32); //MUTE + } +} + +//Nao tem leitura de emissor de IR... +char* irSender_read() { + char* r="\0"; +} + diff --git a/arduino/all the sketchs of my life/0sony/DevBot_sensor_distancia_alternativo/DesviarDeObjetos.ino b/arduino/all the sketchs of my life/0sony/DevBot_sensor_distancia_alternativo/DesviarDeObjetos.ino new file mode 100644 index 0000000..bf18b51 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DevBot_sensor_distancia_alternativo/DesviarDeObjetos.ino @@ -0,0 +1,12 @@ +int distancia; +void desviar() { + robot.mudarServo(90); + distancia = robot.sensorDistancia(1); + if(distancia>0 && distancia<15) { + robot.motores.girar(3); + robot.esperar(700); + robot.motores.movimentoAleatorio(3); + robot.esperar(500); + } + robot.motores.frente(3); +} diff --git a/arduino/all the sketchs of my life/0sony/DevBot_sensor_distancia_alternativo/DevBot_sensor_distancia_alternativo.ino b/arduino/all the sketchs of my life/0sony/DevBot_sensor_distancia_alternativo/DevBot_sensor_distancia_alternativo.ino new file mode 100644 index 0000000..f7976b9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DevBot_sensor_distancia_alternativo/DevBot_sensor_distancia_alternativo.ino @@ -0,0 +1,70 @@ +#include "DevBot.h" +#include "Servo.h" +#include "NewPing.h" + +void setup() +{ + robot.configurar(bateria_7_volts); + robot.configurar(motor_6_volts); + robot.configurar(servo_comum); + robot.configurar(programME_v2); + robot.configurar(sensor_distancia_trigecho); + robot.iniciar(); + robot.modo(0, controleRemoto); + robot.modo(1, android); + robot.modo(2, desviar); + robot.modo(3, testes); + robot.modo(4, medoDoEscuro); + robot.mudarServo(90); +} + +void loop() +{ + robot.loop(); +} + +void controleRemoto() { + robot.controleRemoto(); +} + +void testes() { + robot.enviar("distancia "); + robot.enviar(robot.sensorDistancia(1)); + robot.esperar(200); + + /* + robot.enviar("Idle - Parado"); + robot.enviar("Luz"); + robot.enviar(robot.sensorLuz()); + robot.enviar("Temperatura"); + robot.enviar(robot.sensorTemperatura()); + robot.esperar(500); + + robot.enviar("Frente"); + robot.motores.frente(3); + robot.esperar(3000); + robot.motores.parar(); + robot.esperar(2000); + + robot.enviar("Re"); + robot.motores.re(3); + robot.esperar(3000); + robot.motores.parar(); + robot.esperar(2000); + + robot.enviar("Girar Sentido Horario"); + robot.motores.girar(3,0); + robot.esperar(3000); + robot.motores.parar(); + robot.esperar(2000); + + robot.enviar("Girar Sentido Anti-horario"); + robot.motores.girar(3,1); + robot.esperar(3000); + robot.motores.parar(); + robot.esperar(10000); */ + + +} + + diff --git a/arduino/all the sketchs of my life/0sony/DevBot_sensor_distancia_alternativo/android.ino b/arduino/all the sketchs of my life/0sony/DevBot_sensor_distancia_alternativo/android.ino new file mode 100644 index 0000000..c5ca345 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DevBot_sensor_distancia_alternativo/android.ino @@ -0,0 +1,118 @@ +#include + +MeetAndroid meetAndroid; + +int modoAndroid=1; + +void android() { + meetAndroid.registerFunction(androidSensorProximidade, 'A'); + meetAndroid.registerFunction(androidAcelerometro, 'C'); + meetAndroid.registerFunction(androidBussola, 'B'); + meetAndroid.registerFunction(androidMudarModo, 'M'); + + while(!robot.mudouModo()) { + meetAndroid.receive(); + //delay(50); + } +} +void androidMudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modoAndroid = atoi(c); + //if(modoAndroid<0 || modoAndroid>5) modoAndroid=1; +} + +void androidAcelerometro(byte flag, byte numOfValues) { + float acelerometro[3]; + meetAndroid.getFloatValues(acelerometro); + if(modoAndroid==1) { + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + robot.motores.re(map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + robot.motores.frente(map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + robot.motores.parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + robot.motores.girar(map(acelerometro[0],-3,-10,1,5),0); + } + else { + robot.motores.esquerda(3); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + robot.motores.girar(map(acelerometro[0],-3,-10,1,5),1); + } + else { + robot.motores.direita(3); + } + } + } +} + + +void androidSensorProximidade(byte flag, byte numOfValues) { + int state = meetAndroid.getInt(); + if(modoAndroid!=3) return; + + if(state==0) { + for(int x=0;x<3;x++) { + robot.motores.girar(4,0); + delay(250); + robot.motores.girar(4,1); + delay(250); + robot.motores.girar(4,0); + delay(250); + robot.motores.girar(4,1); + delay(250); + + robot.motores.parar(); + } + } +} + +void androidBussola(byte flag, byte numOfValues) { + int bussola = meetAndroid.getInt(); + if(modoAndroid!=2) return; + if(bussola>350 && bussola<360) { + robot.motores.girar(3,1); + delay(80); + robot.motores.parar(); + } + else if(bussola>180 && bussola<350) { + robot.motores.girar(3,1); + delay(200); + robot.motores.parar(); + } + else if(bussola>15 && bussola<180) { + robot.motores.girar(3,0); + delay(200); + robot.motores.parar(); + } + else if(bussola>3 && bussola<15) { + robot.motores.girar(3,0); + delay(80); + robot.motores.parar(); + } + else if(bussola>0 && bussola<3) { + robot.motores.parar(); + } +} + + + diff --git a/arduino/all the sketchs of my life/0sony/DevBot_sensor_distancia_alternativo/medoDoEscuro.ino b/arduino/all the sketchs of my life/0sony/DevBot_sensor_distancia_alternativo/medoDoEscuro.ino new file mode 100644 index 0000000..b07ea72 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/DevBot_sensor_distancia_alternativo/medoDoEscuro.ino @@ -0,0 +1,31 @@ +int escuridao = 700; //quanto menor o numero, maior a iluminacao do ambiente. +int luzAtual; + +boolean estaClaro() { + return luzAtual + +int RECV_PIN = 11; + +IRrecv irrecv(RECV_PIN); +unsigned long botao_1 = 2640478335; +unsigned long botao_4 = 2640453855; +unsigned long botao_2 = 2640462015; + +unsigned long codigo;//variável que recebe o código + +decode_results results; + +void setup() +{ + Serial.begin(115200); + irrecv.enableIRIn(); // Start the receiver +} + +void loop() { + if (irrecv.decode(&results)) { + codigo = results.value; + Serial.println(results.value, DEC); + Serial.println(codigo); + irrecv.resume(); // Receive the next value + } + if(codigo==botao_1){ + pinMode(8, OUTPUT); + Serial.println(codigo); + digitalWrite(8, HIGH); + //delay(500); + //digitalWrite(8, LOW); + codigo=0; + } + else if (codigo==botao_2){ + Serial.println(codigo); + digitalWrite(8, LOW); + //delay(500); + //digitalWrite(8, LOW); + codigo=0; + + } +} diff --git a/arduino/all the sketchs of my life/0sony/IR_POC_jhome/IR_POC_jhome.ino b/arduino/all the sketchs of my life/0sony/IR_POC_jhome/IR_POC_jhome.ino new file mode 100644 index 0000000..4705383 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/IR_POC_jhome/IR_POC_jhome.ino @@ -0,0 +1,63 @@ +/* + * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv + * An IR detector/demodulator must be connected to the input RECV_PIN. + * Version 0.1 July, 2009 + * Copyright 2009 Ken Shirriff + * http://arcfn.com + */ +#include "Device.h" + + +#include + +int RECV_PIN = 11; + +IRrecv irrecv(RECV_PIN); +unsigned long botao_1 = 2640478335; +unsigned long botao_4 = 2640453855; +unsigned long botao_2 = 2640462015; +unsigned long codigo;//variável que recebe o código + +decode_results results; +Device homeDevice=Device("central-device"); + +void setup() +{ + //homeDevice.add("speaker", DIGITAL, 4); + homeDevice.add("relay1", DIGITAL, 8); + //homeDevice.add("relay2", DIGITAL, 9); + homeDevice.add("light", ANALOG, 3); + homeDevice.add("temp", ANALOG, 2); + + //homeDevice.add("pwm-aux1", PWM, 3); + //h/omeDevice.add("pwm-aux2", PWM, 5); + irrecv.enableIRIn(); // Start the receiver + Serial.begin(115200); + +} + +void loop() { + if (irrecv.decode(&results)) { + codigo = results.value; + Serial.println(results.value, DEC); + //Serial.println(results.value, DEC); + irrecv.resume(); // Receive the next value + } + if(codigo==botao_1){ + pinMode(8, OUTPUT); + Serial.println(codigo); + digitalWrite(8, HIGH); + //delay(500); + //digitalWrite(8, LOW); + codigo=0; + } + else if (codigo==botao_2){ + Serial.println(codigo); + digitalWrite(8, LOW); + //delay(500); + //digitalWrite(8, LOW); + codigo=0; + + } + //homeDevice.loop(); +} diff --git a/arduino/all the sketchs of my life/0sony/IR_POC_on_off/IR_POC_on_off.ino b/arduino/all the sketchs of my life/0sony/IR_POC_on_off/IR_POC_on_off.ino new file mode 100644 index 0000000..a99ed3d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/IR_POC_on_off/IR_POC_on_off.ino @@ -0,0 +1,50 @@ +/* + * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv + * An IR detector/demodulator must be connected to the input RECV_PIN. + * Version 0.1 July, 2009 + * Copyright 2009 Ken Shirriff + * http://arcfn.com + */ + +#include + +int RECV_PIN = 11; + +IRrecv irrecv(RECV_PIN); +unsigned long botao_1 = 2640478335; +unsigned long botao_4 = 2640453855; +unsigned long botao_2 = 2640462015; + +unsigned long codigo;//variável que recebe o código + +decode_results results; + +void setup() +{ + Serial.begin(115200); + irrecv.enableIRIn(); // Start the receiver +} + +void loop() { + if (irrecv.decode(&results)) { + codigo = results.value; + Serial.println(results.value, DEC); + irrecv.resume(); // Receive the next value + } + if(codigo==botao_1){ + pinMode(8, OUTPUT); + Serial.println(codigo); + digitalWrite(8, HIGH); + //delay(500); + //digitalWrite(8, LOW); + codigo=0; + } + else if (codigo==botao_2){ + Serial.println(codigo); + digitalWrite(8, LOW); + //delay(500); + //digitalWrite(8, LOW); + codigo=0; + + } +} diff --git a/arduino/all the sketchs of my life/0sony/IR_demo_end/IR_demo_end.ino b/arduino/all the sketchs of my life/0sony/IR_demo_end/IR_demo_end.ino new file mode 100644 index 0000000..6b5a63d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/IR_demo_end/IR_demo_end.ino @@ -0,0 +1,29 @@ +/* + * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend + * An IR LED must be connected to Arduino PWM pin 3. + * Version 0.1 July, 2009 + * Copyright 2009 Ken Shirriff + * http://arcfn.com + */ + +#include + +IRsend irsend; +unsigned long botao_desligar = 33472575; + + +void setup() +{ + Serial.begin(115200); + //irsend.enableIROut(5); +} + +void loop() { + + for(int x=0;x<3;x++) { + irsend.sendNEC(botao_desligar,32); + delay(100); + } + +} + diff --git a/arduino/all the sketchs of my life/0sony/IR_record_send/IR_record_send.ino b/arduino/all the sketchs of my life/0sony/IR_record_send/IR_record_send.ino new file mode 100644 index 0000000..bab580b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/IR_record_send/IR_record_send.ino @@ -0,0 +1,176 @@ +/* + * IRrecord: record and play back IR signals as a minimal + * An IR detector/demodulator must be connected to the input RECV_PIN. + * An IR LED must be connected to the output PWM pin 3. + * A button must be connected to the input BUTTON_PIN; this is the + * send button. + * A visible LED can be connected to STATUS_PIN to provide status. + * + * The logic is: + * If the button is pressed, send the IR code. + * If an IR code is received, record it. + * + * Version 0.11 September, 2009 + * Copyright 2009 Ken Shirriff + * http://arcfn.com + */ + +#include + +int RECV_PIN = 11; +int BUTTON_PIN = 2; +int STATUS_PIN = 13; + +IRrecv irrecv(RECV_PIN); +IRsend irsend; + +decode_results results; + +void setup() +{ + Serial.begin(9600); + irrecv.enableIRIn(); // Start the receiver + pinMode(BUTTON_PIN, INPUT); + pinMode(STATUS_PIN, OUTPUT); +} + +// Storage for the recorded code +int codeType = -1; // The type of code +unsigned long codeValue; // The code value if not raw +unsigned int rawCodes[RAWBUF]; // The durations if raw +int codeLen; // The length of the code +int toggle = 0; // The RC5/6 toggle state + +// Stores the code for later playback +// Most of this code is just logging +void storeCode(decode_results *results) { + codeType = results->decode_type; + int count = results->rawlen; + if (codeType == UNKNOWN) { + Serial.println("Received unknown code, saving as raw"); + codeLen = results->rawlen - 1; + // To store raw codes: + // Drop first value (gap) + // Convert from ticks to microseconds + // Tweak marks shorter, and spaces longer to cancel out IR receiver distortion + for (int i = 1; i <= codeLen; i++) { + if (i % 2) { + // Mark + rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS; + Serial.print(" m"); + } + else { + // Space + rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS; + Serial.print(" s"); + } + Serial.print(rawCodes[i - 1], DEC); + } + Serial.println(""); + } + else { + if (codeType == NEC) { + Serial.print("Received NEC: "); + if (results->value == REPEAT) { + // Don't record a NEC repeat value as that's useless. + Serial.println("repeat; ignoring."); + return; + } + } + else if (codeType == SONY) { + Serial.print("Received SONY: "); + } + else if (codeType == RC5) { + Serial.print("Received RC5: "); + } + else if (codeType == RC6) { + Serial.print("Received RC6: "); + } + else if (codeType == PANASONIC) { + Serial.print("Received Panasonic: "); + } + + else { + Serial.print("Unexpected codeType "); + Serial.print(codeType, DEC); + Serial.println(""); + } + Serial.println(results->value, HEX); + codeValue = results->value; + codeLen = results->bits; + } +} + +void sendCode(int repeat) { + if (codeType == NEC) { + if (repeat) { + irsend.sendNEC(REPEAT, codeLen); + Serial.println("Sent NEC repeat"); + } + else { + irsend.sendNEC(codeValue, codeLen); + Serial.print("Sent NEC "); + Serial.println(codeValue, HEX); + } + } + else if (codeType == SONY) { + irsend.sendSony(codeValue, codeLen); + Serial.print("Sent Sony "); + Serial.println(codeValue, HEX); + } + else if (codeType == RC5 || codeType == RC6) { + if (!repeat) { + // Flip the toggle bit for a new button press + toggle = 1 - toggle; + } + // Put the toggle bit into the code to send + codeValue = codeValue & ~(1 << (codeLen - 1)); + codeValue = codeValue | (toggle << (codeLen - 1)); + if (codeType == RC5) { + Serial.print("Sent RC5 "); + Serial.println(codeValue, HEX); + irsend.sendRC5(codeValue, codeLen); + } + else { + irsend.sendRC6(codeValue, codeLen); + Serial.print("Sent RC6 "); + Serial.println(codeValue, HEX); + } + } + else if (codeType == PANASONIC) { + irsend.sendPanasonic(0x4004, codeValue); + Serial.print("Sent Panasonic "); + Serial.println(codeValue, HEX); + } + else if (codeType == UNKNOWN /* i.e. raw */) { + // Assume 38 KHz + irsend.sendRaw(rawCodes, codeLen, 38); + Serial.println("Sent raw"); + } +} + +int lastButtonState; + +void loop() { + // If button pressed, send the code. + int buttonState = digitalRead(BUTTON_PIN); + if (lastButtonState == HIGH && buttonState == LOW) { + Serial.println("Released"); + irrecv.enableIRIn(); // Re-enable receiver + } + + if (!buttonState) { + Serial.println("Pressed, sending"); + digitalWrite(STATUS_PIN, HIGH); + sendCode(lastButtonState == buttonState); + digitalWrite(STATUS_PIN, LOW); + delay(50); // Wait a bit between retransmissions + } + else if (irrecv.decode(&results)) { + digitalWrite(STATUS_PIN, HIGH); + storeCode(&results); + irrecv.resume(); // resume receiver + digitalWrite(STATUS_PIN, LOW); + } + lastButtonState = buttonState; +} diff --git a/arduino/all the sketchs of my life/0sony/PulseSensorAmped_Arduino_1dot2/Interrupt.ino b/arduino/all the sketchs of my life/0sony/PulseSensorAmped_Arduino_1dot2/Interrupt.ino new file mode 100644 index 0000000..a2386e0 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/PulseSensorAmped_Arduino_1dot2/Interrupt.ino @@ -0,0 +1,109 @@ + + + +volatile int rate[10]; // array to hold last ten IBI values +volatile unsigned long sampleCounter = 0; // used to determine pulse timing +volatile unsigned long lastBeatTime = 0; // used to find IBI +volatile int P =512; // used to find peak in pulse wave, seeded +volatile int T = 512; // used to find trough in pulse wave, seeded +volatile int thresh = 512; // used to find instant moment of heart beat, seeded +volatile int amp = 100; // used to hold amplitude of pulse waveform, seeded +volatile boolean firstBeat = true; // used to seed rate array so we startup with reasonable BPM +volatile boolean secondBeat = false; // used to seed rate array so we startup with reasonable BPM + + +void interruptSetup(){ + // Initializes Timer2 to throw an interrupt every 2mS. + TCCR2A = 0x02; // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE + TCCR2B = 0x06; // DON'T FORCE COMPARE, 256 PRESCALER + OCR2A = 0X7C; // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE + TIMSK2 = 0x02; // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A + sei(); // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED +} + + +// THIS IS THE TIMER 2 INTERRUPT SERVICE ROUTINE. +// Timer 2 makes sure that we take a reading every 2 miliseconds +ISR(TIMER2_COMPA_vect){ // triggered when Timer2 counts to 124 + cli(); // disable interrupts while we do this + Signal = analogRead(pulsePin); // read the Pulse Sensor + sampleCounter += 2; // keep track of the time in mS with this variable + int N = sampleCounter - lastBeatTime; // monitor the time since the last beat to avoid noise + + // find the peak and trough of the pulse wave + if(Signal < thresh && N > (IBI/5)*3){ // avoid dichrotic noise by waiting 3/5 of last IBI + if (Signal < T){ // T is the trough + T = Signal; // keep track of lowest point in pulse wave + } + } + + if(Signal > thresh && Signal > P){ // thresh condition helps avoid noise + P = Signal; // P is the peak + } // keep track of highest point in pulse wave + + // NOW IT'S TIME TO LOOK FOR THE HEART BEAT + // signal surges up in value every time there is a pulse + if (N > 250){ // avoid high frequency noise + if ( (Signal > thresh) && (Pulse == false) && (N > (IBI/5)*3) ){ + Pulse = true; // set the Pulse flag when we think there is a pulse + digitalWrite(blinkPin,HIGH); // turn on pin 13 LED + IBI = sampleCounter - lastBeatTime; // measure time between beats in mS + lastBeatTime = sampleCounter; // keep track of time for next pulse + + if(secondBeat){ // if this is the second beat, if secondBeat == TRUE + secondBeat = false; // clear secondBeat flag + for(int i=0; i<=9; i++){ // seed the running total to get a realisitic BPM at startup + rate[i] = IBI; + } + } + + if(firstBeat){ // if it's the first time we found a beat, if firstBeat == TRUE + firstBeat = false; // clear firstBeat flag + secondBeat = true; // set the second beat flag + sei(); // enable interrupts again + return; // IBI value is unreliable so discard it + } + + + // keep a running total of the last 10 IBI values + word runningTotal = 0; // clear the runningTotal variable + + for(int i=0; i<=8; i++){ // shift data in the rate array + rate[i] = rate[i+1]; // and drop the oldest IBI value + runningTotal += rate[i]; // add up the 9 oldest IBI values + } + + rate[9] = IBI; // add the latest IBI to the rate array + runningTotal += rate[9]; // add the latest IBI to runningTotal + runningTotal /= 10; // average the last 10 IBI values + BPM = 60000/runningTotal; // how many beats can fit into a minute? that's BPM! + QS = true; // set Quantified Self flag + // QS FLAG IS NOT CLEARED INSIDE THIS ISR + } + } + + if (Signal < thresh && Pulse == true){ // when the values are going down, the beat is over + digitalWrite(blinkPin,LOW); // turn off pin 13 LED + Pulse = false; // reset the Pulse flag so we can do it again + amp = P - T; // get amplitude of the pulse wave + thresh = amp/2 + T; // set thresh at 50% of the amplitude + P = thresh; // reset these for next time + T = thresh; + } + + if (N > 2500){ // if 2.5 seconds go by without a beat + thresh = 512; // set thresh default + P = 512; // set P default + T = 512; // set T default + lastBeatTime = sampleCounter; // bring the lastBeatTime up to date + firstBeat = true; // set these to avoid noise + secondBeat = false; // when we get the heartbeat back + } + + sei(); // enable interrupts when youre done! +}// end isr + + + + + diff --git a/arduino/all the sketchs of my life/0sony/PulseSensorAmped_Arduino_1dot2/PulseSensorAmped_Arduino_1dot2.ino b/arduino/all the sketchs of my life/0sony/PulseSensorAmped_Arduino_1dot2/PulseSensorAmped_Arduino_1dot2.ino new file mode 100644 index 0000000..88984e4 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/PulseSensorAmped_Arduino_1dot2/PulseSensorAmped_Arduino_1dot2.ino @@ -0,0 +1,90 @@ + +/* +>> Pulse Sensor Amped 1.2 << +This code is for Pulse Sensor Amped by Joel Murphy and Yury Gitman + www.pulsesensor.com + >>> Pulse Sensor purple wire goes to Analog Pin 0 <<< +Pulse Sensor sample aquisition and processing happens in the background via Timer 2 interrupt. 2mS sample rate. +PWM on pins 3 and 11 will not work when using this code, because we are using Timer 2! +The following variables are automatically updated: +Signal : int that holds the analog signal data straight from the sensor. updated every 2mS. +IBI : int that holds the time interval between beats. 2mS resolution. +BPM : int that holds the heart rate value, derived every beat, from averaging previous 10 IBI values. +QS : boolean that is made true whenever Pulse is found and BPM is updated. User must reset. +Pulse : boolean that is true when a heartbeat is sensed then false in time with pin13 LED going out. + +This code is designed with output serial data to Processing sketch "PulseSensorAmped_Processing-xx" +The Processing sketch is a simple data visualizer. +All the work to find the heartbeat and determine the heartrate happens in the code below. +Pin 13 LED will blink with heartbeat. +If you want to use pin 13 for something else, adjust the interrupt handler +It will also fade an LED on pin fadePin with every beat. Put an LED and series resistor from fadePin to GND. +Check here for detailed code walkthrough: +http://pulsesensor.myshopify.com/pages/pulse-sensor-amped-arduino-v1dot1 + +Code Version 1.2 by Joel Murphy & Yury Gitman Spring 2013 +This update fixes the firstBeat and secondBeat flag usage so that realistic BPM is reported. + +*/ + + +// VARIABLES +int pulsePin = 0; // Pulse Sensor purple wire connected to analog pin 0 +int blinkPin = 13; // pin to blink led at each beat +int fadePin = 5; // pin to do fancy classy fading blink at each beat +int fadeRate = 0; // used to fade LED on with PWM on fadePin + + +// these variables are volatile because they are used during the interrupt service routine! +volatile int BPM; // used to hold the pulse rate +volatile int Signal; // holds the incoming raw data +volatile int IBI = 600; // holds the time between beats, must be seeded! +volatile boolean Pulse = false; // true when pulse wave is high, false when it's low +volatile boolean QS = false; // becomes true when Arduoino finds a beat. + + +void setup(){ + pinMode(blinkPin,OUTPUT); // pin that will blink to your heartbeat! + pinMode(fadePin,OUTPUT); // pin that will fade to your heartbeat! + Serial.begin(115200); // we agree to talk fast! + interruptSetup(); // sets up to read Pulse Sensor signal every 2mS + // UN-COMMENT THE NEXT LINE IF YOU ARE POWERING The Pulse Sensor AT LOW VOLTAGE, + // AND APPLY THAT VOLTAGE TO THE A-REF PIN + analogReference(EXTERNAL); +} + + + +void loop(){ + sendDataToProcessing('S', Signal); // send Processing the raw Pulse Sensor data + if (QS == true){ // Quantified Self flag is true when arduino finds a heartbeat + fadeRate = 255; // Set 'fadeRate' Variable to 255 to fade LED with pulse + sendDataToProcessing('B',BPM); // send heart rate with a 'B' prefix + sendDataToProcessing('Q',IBI); // send time between beats with a 'Q' prefix + QS = false; // reset the Quantified Self flag for next time + } + + ledFadeToBeat(); + + delay(20); // take a break +} + + +void ledFadeToBeat(){ + fadeRate -= 15; // set LED fade value + fadeRate = constrain(fadeRate,0,255); // keep LED fade value from going into negative numbers! + analogWrite(fadePin,fadeRate); // fade LED + } + + +void sendDataToProcessing(char symbol, int data ){ + Serial.print(symbol); // symbol prefix tells Processing what type of data is coming + Serial.println(data); // the data to send culminating in a carriage return + } + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/RBS_PROJETOR_TELA_UNO/Ethernet.ino b/arduino/all the sketchs of my life/0sony/RBS_PROJETOR_TELA_UNO/Ethernet.ino new file mode 100644 index 0000000..a19bf7a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/RBS_PROJETOR_TELA_UNO/Ethernet.ino @@ -0,0 +1,58 @@ +char comando[30]; +char comandoOK[30]; +int contador = 0; + +void ethernet() { + EthernetClient client = server.available(); + if (client) { + contador =0; + // an http request ends with a blank line + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + //Serial.println("aaa"); + comando[contador++]=c; + if(c=='\n') { + Serial.print("COMANDO: "); + Serial.println(comando); + + + contador=0; + for(int x=5;x<30;x++) { + if(comando[x]==' ') break; + comandoOK[contador++]=comando[x]; + //Serial.println(x); + } + limpa(); + + Serial.print("COMANDO OK: "); + Serial.println(comandoOK); + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println("Connection: close"); + client.println(); + client.println(homeDevice.execute(comandoOK)); + client.flush(); + break; + + } + + } + + } + // give the web browser time to receive the data + delay(5); + // close the connection: + client.stop(); + //Serial.println("client disonnected"); + + } +} + +void limpa() { + for(int x=0;x<30;x++) { + comando[x]=='\0'; + comandoOK[x]=='\0'; + } +} diff --git a/arduino/all the sketchs of my life/0sony/RBS_PROJETOR_TELA_UNO/IR.ino b/arduino/all the sketchs of my life/0sony/RBS_PROJETOR_TELA_UNO/IR.ino new file mode 100644 index 0000000..0443845 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/RBS_PROJETOR_TELA_UNO/IR.ino @@ -0,0 +1,37 @@ +IRsend irsend; +char* irSender_write(char* args) { + int codigo = atoi(args); + if(codigo==0) { + irsend.sendNEC(0x81CEE01F,32); //on off + } + else if(codigo==1) { + irsend.sendNEC(0x81CE807F,32); //Phono + } + else if(codigo==2) { + irsend.sendNEC(0x81CEC03F,32); //FM + } + else if(codigo==3) { + irsend.sendNEC(0x81CE40BF,32); //CD + } + else if(codigo==4) { + irsend.sendNEC(0x81CE08F7,32); //AUX + } + else if(codigo==5) { + irsend.sendNEC(0x81CE20DF,32); //TAPE MONITOR + } + else if(codigo==6) { + irsend.sendNEC(0x81CE609F,32); //Volume Down + } + else if(codigo==7) { + irsend.sendNEC(0x81CEA05F,32); //Volume UP + } + else if(codigo==8) { + irsend.sendNEC(0x81CE10EF,32); //MUTE + } +} + +//Nao tem leitura de emissor de IR... +char* irSender_read() { + char* r="\0"; +} + diff --git a/arduino/all the sketchs of my life/0sony/RBS_PROJETOR_TELA_UNO/Panasonic.ino b/arduino/all the sketchs of my life/0sony/RBS_PROJETOR_TELA_UNO/Panasonic.ino new file mode 100644 index 0000000..4ee3a7a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/RBS_PROJETOR_TELA_UNO/Panasonic.ino @@ -0,0 +1,22 @@ +char* rs232_write(char* args) { + Serial.begin(9600); + int codigo = atoi(args); + if(codigo==1) { + Serial.write(0x02); + Serial.write("PON"); + Serial.write(0x03); + } + else if(codigo==2) { + Serial.write(0x02); + Serial.write("POF"); + Serial.write(0x03); + } +} + +char* rs232_read() { + char* r="\0"; + while(Serial.available()) { + Serial.print((char) Serial.read()); + } +} + diff --git a/arduino/all the sketchs of my life/0sony/RBS_PROJETOR_TELA_UNO/RBS_PROJETOR_TELA_UNO.ino b/arduino/all the sketchs of my life/0sony/RBS_PROJETOR_TELA_UNO/RBS_PROJETOR_TELA_UNO.ino new file mode 100644 index 0000000..252c9eb --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/RBS_PROJETOR_TELA_UNO/RBS_PROJETOR_TELA_UNO.ino @@ -0,0 +1,33 @@ +#include "Device.h" +#include +#include +#include + +Device homeDevice=Device("central-device"); +byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xEC, 0x26 }; //Atentar ao MAC unico de cada placa! +IPAddress ip(192,168,0, 201); +EthernetServer server(80); + +void setup() { + Serial.begin(115200); + homeDevice.add("LED", DIGITAL, 13); + //homeDevice.add("relay1", DIGITAL, 6); + //homeDevice.add("relay2", DIGITAL, 7); + //homeDevice.add("light", ANALOG, 3); + //homeDevice.add("temp", ANALOG, 2); + homeDevice.add("ir", CUSTOM, 3, irSender_read , irSender_write); + homeDevice.add("panasonic", CUSTOM, 0, rs232_read, rs232_write); + //homeDevice.add("rs2321", CUSTOM, 0, rs232_read, rs232_write); + + + Ethernet.begin(mac, ip); + server.begin(); +} + +void loop() { + //Para aceitar requisições por Serial + homeDevice.loop(); + //Para aceitar requisições por TCP/IP + ethernet(); +} + diff --git a/arduino/all the sketchs of my life/0sony/RS232_panasonic/RS232_panasonic.ino b/arduino/all the sketchs of my life/0sony/RS232_panasonic/RS232_panasonic.ino new file mode 100644 index 0000000..45afdd8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/RS232_panasonic/RS232_panasonic.ino @@ -0,0 +1,25 @@ +void setup() { + Serial.begin(115200); + Serial1.begin(19200); + Serial1.print("STXPONETX"); + +} + +void flash13() { + digitalWrite(13, HIGH); + delay(100); + digitalWrite(13, LOW); + delay(100); +} + +void loop() { + while(Serial.available()) { + Serial1.write(Serial.read()); + } + Serial1.flush(); + delay(20); + while(Serial1.available()) { + Serial.print((char) Serial1.read()); + } + +} diff --git a/arduino/all the sketchs of my life/0sony/RS232_panasonic_ok/RS232_panasonic_ok.ino b/arduino/all the sketchs of my life/0sony/RS232_panasonic_ok/RS232_panasonic_ok.ino new file mode 100644 index 0000000..3a27cfb --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/RS232_panasonic_ok/RS232_panasonic_ok.ino @@ -0,0 +1,23 @@ +void setup() { + Serial.begin(115200); + Serial1.begin(19200); +} + +void loop() { + if(!Serial.available()) return; + Serial.println("Comeco"); + Serial1.write(0x02); + + while(Serial.available()) { + char c = Serial.read(); + Serial.print(c); + if(c!='\n') Serial1.write(c); + delay(2); + } + Serial1.write(0x03); + Serial1.flush(); + while(Serial1.available()) { + Serial.print((char) Serial1.read()); + } + Serial.println("Fim"); +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR1/Android/AtualizarDisplay.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR1/Android/AtualizarDisplay.pde new file mode 100644 index 0000000..51b700a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR1/Android/AtualizarDisplay.pde @@ -0,0 +1,46 @@ +/*void atualizaDisplay() { + lcd.clear(); + + //atualiza temperatura + //lcd.setCursor(col,row); + lcd.setCursor(8,1); + lcd.print(analogRead(SensorTemperatura)/2); + lcd.print("oC"); + + Serial.print("Temperatura= "); + Serial.println(analogRead(SensorTemperatura)/2); + + //atualiza luminosidade + //lcd.setCursor(col,row); + lcd.setCursor(0,1); + lcd.print(map((analogRead(LDR)), 0, 1023, 100,0)); + lcd.print(" %"); + + Serial.print("Luminosidade= "); + Serial.println(map((analogRead(LDR)), 0, 1023, 100,0)); + Serial.println(" "); + + + //lcd.setCursor(col,row); + lcd.setCursor(0,0); + lcd.print(DistanciaEsquerda); + lcd.print(" cms"); + + //atualiza distancia esquerda + Serial.print("Distancia Esquerda= "); + Serial.println(DistanciaEsquerda); + + //atualiza distancia direita + //lcd.setCursor(col,row); + lcd.setCursor(8,0); + lcd.print(DistanciaDireita); + lcd.print(" cms"); + + Serial.print("Distancia Direita= "); + Serial.println(DistanciaDireita); + + + +} +*/ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR1/Android/Robo_Android.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR1/Android/Robo_Android.pde new file mode 100644 index 0000000..2a5fc9a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR1/Android/Robo_Android.pde @@ -0,0 +1,453 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int SensorTemperatura = 1 ; +int LDR = 5; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo servoV; +Servo servoH; +int modo = 1; +int sentido; + + +void setup() { + Serial.begin(115200); + servoH.attach(10); + servoV.attach(11); + meetAndroid.setSerial(&Serial); + meetAndroid.registerFunction(dedoDuro, 'A'); + meetAndroid.registerFunction(acelera, 'C'); + meetAndroid.registerFunction(encontraNorte, 'B'); + meetAndroid.registerFunction(andar, 'W'); + meetAndroid.registerFunction(leds, 'L'); + meetAndroid.registerFunction(mudarModo, 'M'); + + /* set up the LCD's number of rows and columns: + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Aguardando");*/ + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + pinMode(LED_RED, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + testeLeds(); + +} + +void loop() { + meetAndroid.receive(); + delay(50); + //meetAndroid.send(analogRead(1)); + //testeLeds(); +} +void leds(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + + if(comando[0]=='R') { + pinMode(LED_RED,INPUT); + int ligado = digitalRead(LED_RED); + pinMode(LED_RED,OUTPUT); + digitalWrite(LED_RED,!ligado); + + } + else if(comando[0]=='G') { + pinMode(LED_GREEN,INPUT); + int ligado = digitalRead(LED_GREEN); + pinMode(LED_GREEN,OUTPUT); + digitalWrite(LED_GREEN,!ligado); + } + else if(comando[0]=='B') { + pinMode(LED_BLUE,INPUT); + int ligado = digitalRead(LED_BLUE); + pinMode(LED_BLUE,OUTPUT); + digitalWrite(LED_BLUE,!ligado); + } + +} +void testeLeds() { + digitalWrite(LED_RED, HIGH); + delay(200); + digitalWrite(LED_RED, LOW); + delay(200); + digitalWrite(LED_BLUE, HIGH); + delay(200); + digitalWrite(LED_BLUE, LOW); + delay(200); + digitalWrite(LED_GREEN, HIGH); + delay(200); + digitalWrite(LED_GREEN, LOW); + delay(200); +} +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + testeLeds(); +} + +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + if(modo==4) { + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarTraz(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarFrente(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + } + else if(modo==6){ + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + delay(200); + } +} + + + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=3) return; + + if(comando[0]=='F') { + dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + dance(); + } +} + +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=1) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + testeLeds(); + } + } +} + +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=2) return; + if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + +/*void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } + }*/ + +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + + 28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ +int led_status=0; +void changeServo(int a) { + + digitalWrite(LED_RED, led_status); + led_status = led_status==0 ? 1 : 0; +} + +void dance() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + /*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR1/Android/Wask.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR1/Android/Wask.pde new file mode 100644 index 0000000..19a2ed2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR1/Android/Wask.pde @@ -0,0 +1,273 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 +long duration, inches, cm; +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServoOK(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR1/Avoidance/dojo_solucao.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR1/Avoidance/dojo_solucao.pde new file mode 100644 index 0000000..e22e090 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR1/Avoidance/dojo_solucao.pde @@ -0,0 +1,160 @@ +#include +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define DISTANCIA 1 + +int sentido; +Servo servoV; +Servo servoH; +int contador=0; +long distancia; +long distanciaEsquerda; +long distanciaDireita; + +void setup() { + servoH.attach(11); + servoV.attach(10); + Serial.begin(9600); +} + +int lerPingComMedia() { + int d1,d2,d3; + d1 = analogRead(1); + delay(5); + d2 = analogRead(1); + delay(5); + d3 = analogRead(1); + delay(5); + return (d1 + d2 + d3)/3; +} + +void lerPing() { + distancia = lerPingComMedia(); +} +void lerPingFull() { + servoH.write(30); + delay(200); + distanciaEsquerda = lerPingComMedia(); + servoH.write(100); + delay(200); + distancia = lerPingComMedia(); + servoH.write(150); + delay(200); + distanciaDireita = lerPingComMedia(); + servoH.write(85); +} + +void loop() { + lerPing(); + + while(distancia>25) { + andarFrente(200,3); + lerPing(); + } + while(distancia>15 && distancia<25) { + parar(); + delay(200); + lerPingFull(); + if(distanciaEsquerda>distancia && distanciaEsquerda>distanciaDireita) { + girarNoEixo(300,2,1); + } + if(distanciaDireita>distancia && distanciaDireita>distanciaEsquerda) { + girarNoEixo(300,2,0); + } + lerPing(); + } + while(distancia>5 && distancia<15) { + parar(); + andarTraz(500,2); + girarNoEixo(500,2, random(10)%2==0); + lerPing(); + } + +} + + + + + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarTraz(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarFrente(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR2.zip b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR2.zip new file mode 100644 index 0000000..0d47e9b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/BR2.zip differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Boat_Central/Boat_Central.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Boat_Central/Boat_Central.ino new file mode 100644 index 0000000..bba820e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Boat_Central/Boat_Central.ino @@ -0,0 +1,436 @@ +#include +#include + +#define MODE_GPS_LATLONG 0 +#define MODE_GPS_SPEED 1 +#define MODE_GPS_HEADING 2 +#define MODE_GPS_MANE 3 +#define MODE_AUTOPILOT_COMPASS 4 +#define MODE_AUTOPILOT_ACELEROMETER 5 +#define MODE_DEBUG 6 +#define MODE_MANUALPILOT 7 +#define MOTOR_A 12 +#define MOTOR_B 13 +#define MOTOR_PWM 11 +MeetAndroid meetAndroid; + +String modes[] = { + "Google Earth", "Speedy", "Heading", "Piloto Mane'", "Auto Compass", "Auto Aceler.", "Debug", "Manual Pilot" }; + +LiquidCrystal lcd(4, 9, 57, 56, 55, 54); +char line_gps[300] = ""; + +int autopilot=0; +int contaplot=0; +int byteGPS=-1; +char comandoGPR[7] = "$GPRMC"; +int indices[13]; +int cont=0; +int bien=0; +int conta=0; +char latitude[17]; +char longitude[17]; +char velocidade[17]; +char heading[17]; +int cvelocidade=0, clatitude=0, clongitude=0, cheading=0; +volatile long targetHeading; +volatile int mode; + +long lastDebounce=0; +long debounceDelay=50; +long lcdDelay=1500; +long lcdNextUpdate=0; +long lcdLastUpdate=0; + +String lcdLine1; +String lcdLine2; + +void setup() +{ + //LoL + Serial.begin(9600); + Serial2.begin(115200); + Serial1.begin(4800); + meetAndroid.setSerial(&Serial2); + attachInterrupt(3, buttonPressed, LOW); //PORTA 20, quando estiver subindo + attachInterrupt(2, changeMode, LOW); //PORTA 21, quando estiver subindo + initLCD(); + meetAndroid.registerFunction(autoCompass, 'B'); + meetAndroid.registerFunction(ghostPilot, 'C'); +} + +void setupMotor() { + pinMode(MOTOR_A, OUTPUT); + pinMode(MOTOR_B, OUTPUT); +} + +void loop() +{ + if(mode>=0 && mode<=3) savelocation(); + if(mode==MODE_GPS_MANE) pilotoMane(); + if(mode==MODE_AUTOPILOT_ACELEROMETER) android(); + if(mode==MODE_AUTOPILOT_COMPASS) android(); + if(mode==MODE_DEBUG) debug(); + if(mode==MODE_MANUALPILOT) manualPilot(); + lcdRestore(); +} + +long headings[6]; +int headCount=0; //ahahahah headCount eh bizarro +void pilotoMane() { + //headings[headCount++]=atoi(heading); + //if(headCount==5) headCount=0; + float h = atof(heading); + char c1[10]; + itoa(targetHeading,c1,10); + char c2[10]; + itoa(h,c2,10); + lcdPrint(c1, c2,0); + if(targetHeadingmillis() && mode==MODE_MANUALPILOT) { + itoa(time-millis(),c1,10); + lcdPrint("Manual Pilot in",c1 , 0); + delay(100); + } + if(mode!=MODE_MANUALPILOT) return; + lcdPrint("Manual Pilot On", "Take care!", 0); + autopilot=1; + detachInterrupt(3); //PORTA 18, quando estiver subindo + detachInterrupt(2); //PORTA 18, quando estiver subindo + attachInterrupt(3, motorForward, LOW); //PORTA 20, quando estiver subindo + attachInterrupt(2, motorBackward, LOW); //PORTA 21, quando estiver subindo + +} +void motorForward() { + digitalWrite(MOTOR_A, 0); + digitalWrite(MOTOR_B, 1); + analogWrite(MOTOR_PWM, 250); + while(!digitalRead(20)); + analogWrite(MOTOR_PWM,0); +} +void motorBackward() { + digitalWrite(MOTOR_A, 1); + digitalWrite(MOTOR_B, 0); + analogWrite(MOTOR_PWM, 250); + while(!digitalRead(21)); + analogWrite(MOTOR_PWM,0); +} + +void changeMode() { + if(millis()-lastDebounce>debounceDelay) { + mode = mode== 7 ? 0 : mode + 1; + lastDebounce=millis(); + resetMode(); + lcdPrint("Mode", modes[mode], 2000); + + } + +} + +void buttonPressed() { + char c1[10]; + if(millis()-lastDebounce>debounceDelay) { + targetHeading = targetHeading==360 ? 1 : targetHeading + 5; + lastDebounce=millis(); + itoa(targetHeading,c1,10); + lcdPrint("Target Heading",c1, 500); + + } +} + +void android() { + meetAndroid.receive(); +} + + +void savelocation () +{ + while(Serial1.available()>0) { + + byteGPS=Serial1.read(); // Read a byte of the serial port + line_gps[conta]=byteGPS; // If there is serial port data, it is put in the buffer + conta++; + if (byteGPS==13) + { // If the received byte is = to 13, end of transmission + //Serial.print(line_gps); + cont=0; + bien=0; + for (int i=1;i<7;i++) + { // Verifies if the received command starts with $GPR + if (line_gps[i]==comandoGPR[i-1]) + { + bien++; + } + } + if(bien==6) + { // If yes, continue and process the data + for (int i=0;i<300;i++) + { + if (line_gps[i]==','){ // check for the position of the "," separator + indices[cont]=i; + cont++; + } + if (line_gps[i]=='*') + { // ... and the "*" + indices[12]=i; + cont++; + } + } + Serial2.println(line_gps); + Serial.println(""); // ... and write to the serial port + Serial.println(""); + Serial.println("---------------"); + resetDados(); + for (int i=0;i<12;i++) + { + switch(i){ + case 0 : + Serial.print("Time in UTC (HhMmSs): "); + break; + case 1 : + Serial.print("Status (A=OK,V=KO): "); + break; + case 2 : + Serial.print("Latitude: "); + break; + case 3 : + Serial.print("Direction (N/S): "); + break; + case 4 : + Serial.print("Longitude: "); + break; + case 5 : + Serial.print("Direction (E/W): "); + break; + case 6 : + Serial.print("Velocity in knots: "); + break; + case 7 : + Serial.print("Heading in degrees: "); + break; + case 8 : + Serial.print("Date UTC (DdMmAa): "); + break; + case 9 : + Serial.print("Magnetic degrees: "); + break; + case 10 : + Serial.print("(E/W): "); + break; + case 11 : + Serial.print("Mode: "); + break; + case 12 : + Serial.print("Checksum: "); + break; + } + for (int j=indices[i];j<(indices[i+1]-1);j++) + { + Serial.print(line_gps[j+1]); + if(i==2) { + latitude[clatitude++]=line_gps[j+1]; + } + else if(i==3) { + latitude[clatitude++]=line_gps[j+1]; + } + else if(i==4) { + longitude[clongitude++]=line_gps[j+1]; + } + else if(i==5) { + longitude[clongitude++]=line_gps[j+1]; + } + else if(i==6) { + velocidade[cvelocidade++]=line_gps[j+1]; + } + else if(i==7) { + heading[cheading++]=line_gps[j+1]; + } + } + Serial.println(""); + if(mode==MODE_GPS_LATLONG) lcdPrint(latitude, longitude,0); + else if(mode==MODE_GPS_SPEED) lcdPrint("Speed", velocidade, 0); + else if(mode==MODE_GPS_HEADING) lcdPrint("Heading", heading, 0); + } + } + cvelocidade=0; + clatitude=0; + clongitude=0; + cheading=0; + conta=0; // Reset the buffer + for (int i=0;i<300;i++) + { + line_gps[i]=' '; + } + } + } +} + +void resetDados() { + for( int i=0;i<16;i++) { + latitude[i]=' '; + longitude[i]=' '; + velocidade[i]=' '; + heading[i]=' '; + } +} + +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcdPrint("Eletron Livre", "Tiziu", 0); + delay(2000); +} + + + + + +void lcdPrint(String line1, String line2, long time) { + if(time==0 && lcdNextUpdate>millis()) return; + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print(line1); + lcd.setCursor(0, 1); + lcd.print(line2); + if(time > 0) { //user want to keep last lines... + lcdNextUpdate = millis() + time; + } + else { + lcdLine1=line1; + lcdLine2=line2; + lcdNextUpdate = 0; + } + lcdLastUpdate=millis(); +} + + +void lcdRestore() { + if(lcdNextUpdate!=0 && lcdNextUpdate<=millis()){ + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print(lcdLine1); + lcd.setCursor(0, 1); + lcd.print(lcdLine2); + lcdNextUpdate=0; + } +} + +void debug() { + lcdPrint("Debug", "Avanca", 0); + + digitalWrite(MOTOR_A, 0); + digitalWrite(MOTOR_B, 1); + analogWrite(MOTOR_PWM, 250); + delay(1500); + if(mode!=MODE_DEBUG) return; + + lcdPrint("Debug", "Para", 0); + analogWrite(MOTOR_PWM, 0); + delay(1500); + if(mode!=MODE_DEBUG) return; + + lcdPrint("Debug", "Retro", 0); + digitalWrite(MOTOR_A, 1); + digitalWrite(MOTOR_B, 0); + analogWrite(MOTOR_PWM, 250); + delay(1500); + if(mode!=MODE_DEBUG) return; + + lcdPrint("Debug", "Para", 0); + analogWrite(MOTOR_PWM, 0); + delay(1500); + +} + +void resetMode() { + analogWrite(MOTOR_PWM,0); +} + + +void autoCompass(byte flag, byte numOfValues) { + if(mode!=MODE_AUTOPILOT_COMPASS) return; + int bussola = meetAndroid.getInt(); + char c1[10]; + itoa(bussola,c1,10); + + lcdPrint("Compass", c1, 0); + + +} + +float acelerometro[3]; +void ghostPilot(byte flag, byte numOfValues) { + if(mode!=MODE_AUTOPILOT_ACELEROMETER) return; + meetAndroid.getFloatValues(acelerometro); + + if(acelerometro[0]<-3) { //para esquerda + lcdPrint("Debug", "Retro", 0); + digitalWrite(MOTOR_A, 1); + digitalWrite(MOTOR_B, 0); + analogWrite(MOTOR_PWM, 250); + + } + else if(acelerometro[0]>3) { //para direita + lcdPrint("Debug", "Avanca", 0); + digitalWrite(MOTOR_A, 0); + digitalWrite(MOTOR_B, 1); + analogWrite(MOTOR_PWM, 250); + + } + else { + analogWrite(MOTOR_PWM, 0); + } + //lcdPrint("" + acelerometro[0], "" + acelerometro[1], 0); + +} + + +/*caso 1 + + + heading target command + + 10 0 reward + 0 10 forward + + + */ + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Boat_Central/EletronLCD.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Boat_Central/EletronLCD.ino new file mode 100644 index 0000000..a1593aa --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Boat_Central/EletronLCD.ino @@ -0,0 +1,8 @@ + +class EletronLCD { + private: + + public: + +}; + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Boat_Central/EletronOS.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Boat_Central/EletronOS.ino new file mode 100644 index 0000000..b483304 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Boat_Central/EletronOS.ino @@ -0,0 +1,7 @@ + +class EletronOS { + private: + + public: + +}; diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Boat_Central/ProgramME.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Boat_Central/ProgramME.ino new file mode 100644 index 0000000..aa16572 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Boat_Central/ProgramME.ino @@ -0,0 +1,9 @@ +#define LED_P5 4 + +class ProgramME { + private: + + public: + +}; + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer.zip b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer.zip new file mode 100644 index 0000000..2bf81cb Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer.zip differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/build.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/build.xml new file mode 100644 index 0000000..04a8adb --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project ClientConsole. + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/build/jar/META-INF/MANIFEST.MF b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/build/jar/META-INF/MANIFEST.MF new file mode 100644 index 0000000..1e3875e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/build/jar/META-INF/MANIFEST.MF @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Ant-Version: Apache Ant 1.8.1 +Created-By: 1.6.0_18-b07 (Sun Microsystems Inc.) +X-COMMENT: Main-Class will be added automatically by build +Main-Class: clientconsole.Main + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/build/jar/META-INF/application-client.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/build/jar/META-INF/application-client.xml new file mode 100644 index 0000000..d61dea1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/build/jar/META-INF/application-client.xml @@ -0,0 +1,4 @@ + + + ClientConsole + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/build/jar/gfv3ee6.dpf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/build/jar/gfv3ee6.dpf new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/ant-deploy.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/ant-deploy.xml new file mode 100644 index 0000000..b03100d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/ant-deploy.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/build-impl.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/build-impl.xml new file mode 100644 index 0000000..071e6fc --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/build-impl.xml @@ -0,0 +1,982 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set build.generated.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Main class must be set. Go to ClientConsole project properties -> Run and set the main class there. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. + + + Launching ${browse.url} + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/genfiles.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/genfiles.properties new file mode 100644 index 0000000..6747a25 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=da2f8713 +build.xml.script.CRC32=15c62e87 +build.xml.stylesheet.CRC32=2c379194@1.16.2.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=da2f8713 +nbproject/build-impl.xml.script.CRC32=b080f751 +nbproject/build-impl.xml.stylesheet.CRC32=b21e29a6@1.16.2.1 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/private/private.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/private/private.properties new file mode 100644 index 0000000..94f1d54 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/private/private.properties @@ -0,0 +1,11 @@ +deploy.ant.properties.file=/home/vsenger/.netbeans/6.9/gfv31837373329.properties +j2ee.appclient.tool.jvmoptions=-Djava.endorsed.dirs="/java/glassfish3.1-final/glassfish/lib/endorsed":"/java/glassfish3.1-final/glassfish/modules/endorsed" -javaagent:"/java/glassfish3.1-final/glassfish/modules/gf-client.jar"=mode=acscript,arg=-configxml,arg="/java/glassfish3.1-final/glassfish/domains/domain1/config/sun-acc.xml",client=jar= +j2ee.appclient.tool.jvmoptions.class=-Djava.endorsed.dirs="/java/glassfish-3.0.1/glassfish/lib/endorsed":"/java/glassfish-3.0.1/glassfish/modules/endorsed" -javaagent:"/java/glassfish-3.0.1/glassfish/modules/gf-client.jar"=mode=acscript,arg=-configxml,arg="/java/glassfish-3.0.1/glassfish/domains/domain1/config/sun-acc.xml",client=class= +j2ee.appclient.tool.mainclass=org.glassfish.appclient.client.AppClientFacade +j2ee.appclient.tool.runtime= +j2ee.platform.is.jsr109=true +j2ee.server.home=/java/glassfish3.1-final/glassfish +j2ee.server.instance=[/java/glassfish3.1-final/glassfish]deployer:gfv3ee6:localhost:4848 +source.encoding=UTF-8 +user.properties.file=/home/vsenger/.netbeans/6.9/build.properties +wa.copy.client.jar.from=/java/glassfish3.1-final/glassfish/domains/domain1/generated/xml diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/private/private.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/private/private.xml new file mode 100644 index 0000000..c1f155a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/project.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/project.properties new file mode 100644 index 0000000..522ba2c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/project.properties @@ -0,0 +1,85 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/jar +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.ear.classes.dir=${build.dir}/jar +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.ear.jar=${dist.dir}/${jar.name} +dist.jar=${dist.dir}/${jar.name} +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath=\ + ${libs.javaee-endorsed-api-6.0.classpath} +excludes= +includes=** +j2ee.appclient.mainclass.args=${j2ee.appclient.tool.args} +j2ee.platform=1.6 +j2ee.platform.classpath=${j2ee.server.home}/modules/javax.security.jacc.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.security.auth.message.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxrpc-api-osgi.jar:${j2ee.server.home}/modules/jsf-impl.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.ejb.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.enterprise.deploy.jar:${j2ee.server.home}/modules/javax.jms.jar:${j2ee.server.home}/modules/javax.transaction.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.servlet.jar:${j2ee.server.home}/modules/endorsed/javax.annotation.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee.jar:${j2ee.server.home}/modules/javax.resource.jar:${j2ee.server.home}/modules/jsf-api.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/jstl-impl.jar +j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar +j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar +j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsit.classpath= +j2ee.server.type=gfv3ee6 +jar.compress=false +jar.name=ClientConsole.jar +javac.classpath=\ + ${reference.Coffee-Timer-EJB.dist} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=${javac.classpath} +javac.source=1.6 +javac.target=1.6 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javac.test.processorpath=${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=clientconsole.Main +manifest.file=${meta.inf}/MANIFEST.MF +meta.inf=${source.root}/conf +platform.active=default_platform +project.Coffee-Timer-EJB=../Coffee-Timer-EJB +reference.Coffee-Timer-EJB.dist=${project.Coffee-Timer-EJB}/dist/Coffee-Timer-EJB.jar +resource.dir=setup +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.root=src +src.dir=${source.root}/java +test.src.dir=test diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/project.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/project.xml new file mode 100644 index 0000000..7a4e01b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/nbproject/project.xml @@ -0,0 +1,27 @@ + + + org.netbeans.modules.j2ee.clientproject + + + ClientConsole + 1.6.5 + + + + + + + reference.Coffee-Timer-EJB.dist + + + + Coffee-Timer-EJB + jar + + dist + clean + dist + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/src/conf/MANIFEST.MF b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/src/conf/MANIFEST.MF new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/src/conf/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/src/conf/application-client.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/src/conf/application-client.xml new file mode 100644 index 0000000..d61dea1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/src/conf/application-client.xml @@ -0,0 +1,4 @@ + + + ClientConsole + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/src/java/clientconsole/Main.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/src/java/clientconsole/Main.java new file mode 100644 index 0000000..5cf260c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/ClientConsole/src/java/clientconsole/Main.java @@ -0,0 +1,25 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package clientconsole; + +import java.rmi.RemoteException; +import javax.ejb.EJB; + +/** + * + * @author vsenger + */ +public class Main { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) throws RemoteException { + // TODO code application logic here + //wakeUpBean.agendarTarefa(); + } + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/build.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/build.xml new file mode 100644 index 0000000..b02a2ba --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/build.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + Builds, tests, and runs the project CoffeeTimerEJB. + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/build/classes/META-INF/MANIFEST.MF b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/build/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/build/classes/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/ant-deploy.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/ant-deploy.xml new file mode 100644 index 0000000..b03100d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/ant-deploy.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/build-impl.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/build-impl.xml new file mode 100644 index 0000000..ba7738c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/build-impl.xml @@ -0,0 +1,764 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set main.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/genfiles.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/genfiles.properties new file mode 100644 index 0000000..39d826c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/genfiles.properties @@ -0,0 +1,9 @@ +build.xml.data.CRC32=124b022d +build.xml.script.CRC32=ffa052f7 +build.xml.stylesheet.CRC32=5910fda3@1.22.2 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=124b022d +nbproject/build-impl.xml.script.CRC32=8d3f4e00 +nbproject/build-impl.xml.stylesheet.CRC32=33606734@1.22.2 +nbproject/jaxws-build.xml.stylesheet.CRC32=c57740bd diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/jax-ws.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/jax-ws.xml new file mode 100644 index 0000000..7888689 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/jax-ws.xml @@ -0,0 +1,9 @@ + + + + + br.com.eletronlivre.cofffeetimer.ws.CoffeeSchedullerWS + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/jaxws-build.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/jaxws-build.xml new file mode 100644 index 0000000..75ca966 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/jaxws-build.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/private/private.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/private/private.properties new file mode 100644 index 0000000..e960801 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/private/private.properties @@ -0,0 +1,7 @@ +deploy.ant.properties.file=/home/vsenger/.netbeans/6.9/gfv3-1780747739.properties +j2ee.platform.is.jsr109=true +j2ee.server.home=/java/nb7-glassfish-3.1.1/glassfish +j2ee.server.instance=[/java/nb7-glassfish-3.1.1/glassfish]deployer:gfv3ee6:localhost:4848 +javac.debug=true +javadoc.preview=true +netbeans.user=/home/vsenger/.netbeans/6.9 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/private/private.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/private/private.xml new file mode 100644 index 0000000..0125e76 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/private/private.xml @@ -0,0 +1,9 @@ + + + + + file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/arduino/ArduinoBoard.java + file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java + file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOnBean.java + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/project.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/project.properties new file mode 100644 index 0000000..f05d915 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/project.properties @@ -0,0 +1,80 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form,**/.nbattrs +build.dir=build +build.ear.classes.dir=${build.dir}/classes +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +debug.classpath=${javac.classpath}:${build.classes.dir} +debug.test.classpath=\ + ${run.test.classpath} +dist.dir=dist +dist.ear.jar=${dist.dir}/${jar.name} +dist.jar=${dist.dir}/${jar.name} +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath=\ + ${libs.javaee-endorsed-api-6.0.classpath} +excludes= +file.reference.RXTXcomm.jar=../../../../../../../usr/share/java/RXTXcomm.jar +includes=** +j2ee.compile.on.save=false +j2ee.deploy.on.save=false +j2ee.platform=1.6 +j2ee.platform.classpath=${j2ee.server.home}/modules/javax.security.jacc.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.jms.jar:${j2ee.server.home}/modules/jstl-impl.jar:${j2ee.server.home}/modules/javax.management.j2ee.jar:${j2ee.server.home}/modules/javax.transaction.jar:${j2ee.server.home}/modules/endorsed/javax.annotation.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/jsf-impl.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/jsf-api.jar:${j2ee.server.home}/modules/javax.servlet.jar:${j2ee.server.home}/modules/javax.enterprise.deploy.jar:${j2ee.server.home}/modules/jaxrpc-api-osgi.jar:${j2ee.server.home}/modules/javax.resource.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/jaxr-api-osgi.jar:${j2ee.server.home}/modules/javax.security.auth.message.jar +j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar +j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar +j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsit.classpath= +j2ee.server.type=gfv3ee6 +jar.compress=false +jar.name=CoffeeTimerEJB.jar +javac.classpath=\ + ${file.reference.RXTXcomm.jar}:\ + ${reference.CoffeeTimerInterface.jar} +javac.debug=true +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.6 +javac.target=1.6 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javac.test.processorpath=${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.preview=true +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +meta.inf=${source.root}/conf +meta.inf.excludes=sun-cmp-mappings.xml +platform.active=default_platform +project.CoffeeTimerInterface=../CoffeeTimerInterface +reference.CoffeeTimerInterface.jar=${project.CoffeeTimerInterface}/dist/CoffeeTimerInterface.jar +resource.dir=setup +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +# Space-separated list of JVM arguments used when running a class with a main method or a unit test +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): +runmain.jvmargs=-Dgnu.io.rxtx.SerialPorts=/dev/rfcomm1 +source.encoding=UTF-8 +source.root=src +src.dir=${source.root}/java +test.src.dir=test diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/project.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/project.xml new file mode 100644 index 0000000..d92a8ab --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/nbproject/project.xml @@ -0,0 +1,31 @@ + + + org.netbeans.modules.j2ee.ejbjarproject + + + + + + CoffeeTimerEJB + 1.6.5 + file.reference.RXTXcomm.jar + reference.CoffeeTimerInterface.jar + + + + + + + + + + CoffeeTimerInterface + jar + + jar + clean + jar + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/conf/MANIFEST.MF b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/conf/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOffBean.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOffBean.java new file mode 100644 index 0000000..9d283a4 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOffBean.java @@ -0,0 +1,48 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.eletronlivre.cofffeetimer; + +import br.com.eletronlivre.cofffeetimer.arduino.ArduinoBoard; +import br.com.globalcode.eletronlivre.arduino.serial.Arduino; +import javax.ejb.Timer; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Resource; +import javax.ejb.EJB; +import javax.ejb.SessionContext; +import javax.ejb.Stateless; +import javax.ejb.Timeout; +import javax.ejb.TimerService; + +/** + * + * @author vsenger + */ +@Stateless +public class TurnOffBean { + @EJB + ArduinoBoard board; + + @Resource + TimerService timerService; + @Resource + SessionContext ctx; + + public void agendarTarefa(long tempo) { + TimerService agendador = ctx.getTimerService(); + agendador.createTimer(tempo,null); + } + + @Timeout + private void wakeUp(Timer timer) { + System.out.println("Vamos desligar!"); + try { + //Arduino.enviar("A-B"); + board.enviar("A-B"); + } catch (Exception ex) { + Logger.getLogger(TurnOffBean.class.getName()).log(Level.SEVERE, null, ex); + } + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOnBean.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOnBean.java new file mode 100644 index 0000000..0e6b706 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOnBean.java @@ -0,0 +1,62 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.eletronlivre.cofffeetimer; + +import br.com.eletronlivre.cofffeetimer.arduino.ArduinoBoard; +import br.com.globalcode.eletronlivre.arduino.serial.Arduino; +import javax.ejb.EJB; +import javax.ejb.Timer; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Resource; +import javax.ejb.SessionContext; +import javax.ejb.Stateless; +import javax.ejb.Timeout; +import javax.ejb.TimerService; + +/** + * + * @author vsenger + */ +@Stateless +public class TurnOnBean implements WakeUpScheduler { + + @EJB + private TurnOffBean turnOffBean; + @EJB + private ArduinoBoard board; + + public TurnOnBean() { + } + @Resource + TimerService timerService; + @Resource + SessionContext ctx; + + @Override + public void agendarTarefa(long emQuantoTempo, long porQuantoTempo) { + System.out.println("Serviço agendado!"); + System.out.println("Ligando em " + emQuantoTempo + " por " + porQuantoTempo + " segundos"); + TimerService agendador = ctx.getTimerService(); + board.testando(); + agendador.createTimer(emQuantoTempo, null); + turnOffBean.agendarTarefa(porQuantoTempo + emQuantoTempo); + + } + + + + + @Timeout + public void wakeUp(Timer timer) { + System.out.println("Vamos ligarrr!"); + try { + //Arduino.enviar("A+B"); + board.enviar("A+B"); + } catch (Exception ex) { + Logger.getLogger(TurnOnBean.class.getName()).log(Level.SEVERE, null, ex); + } + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java new file mode 100644 index 0000000..cbbf463 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java @@ -0,0 +1,20 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package br.com.eletronlivre.cofffeetimer; + +import java.rmi.RemoteException; +import javax.ejb.Remote; + +/** + * + * @author vsenger + */ +@Remote +public interface WakeUpScheduler { + + void agendarTarefa(long time, long tt) throws RemoteException; + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/arduino/ArduinoBoard.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/arduino/ArduinoBoard.java new file mode 100644 index 0000000..11e5109 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/arduino/ArduinoBoard.java @@ -0,0 +1,103 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.eletronlivre.cofffeetimer.arduino; + +import gnu.io.CommPortIdentifier; +import gnu.io.SerialPort; +import gnu.io.UnsupportedCommOperationException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Enumeration; +import javax.annotation.PostConstruct; +import javax.ejb.Singleton; +import javax.ejb.LocalBean; + +/** + * + * @author vsenger + */ +@Singleton +@LocalBean +public class ArduinoBoard { + Enumeration portList; + CommPortIdentifier portId; + String messageString = "10"; + SerialPort serialPort; + OutputStream outputStream; + InputStream inputStream; + boolean outputBufferEmptyFlag = false; + String defaultPort = "/dev/rfcomm1"; + int x = 0; + + public SerialPort getSerialPort() { + return serialPort; + } + + public void setSerialPort(SerialPort serialPort) { + this.serialPort = serialPort; + } + + public void testando() { + System.out.println("x++" + x++); + } + + public void delay(long milis) { + try { + Thread.sleep(milis); + } catch (InterruptedException ex) { + } + + } + + @PostConstruct + public void init() { + + portList = CommPortIdentifier.getPortIdentifiers(); + + System.out.println("Iniciando"); + while (portList.hasMoreElements()) { + portId = (CommPortIdentifier) portList.nextElement(); + System.out.println(portId.getName()); + if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { + if (portId.getName().equals(defaultPort)) { + System.out.println("Found port " + defaultPort); + try { + serialPort = + (SerialPort) portId.open("SimpleWriteCOM17", 115200); + } catch (Exception e) { + System.out.println("Port in use."); + continue; + } + + try { + outputStream = serialPort.getOutputStream(); + inputStream = serialPort.getInputStream(); + serialPort.setSerialPortParams(115200, + SerialPort.DATABITS_8, + SerialPort.STOPBITS_1, + SerialPort.PARITY_NONE); + + serialPort.notifyOnOutputEmpty(true); + } catch (UnsupportedCommOperationException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + System.out.println("Error setting event notification"); + System.out.println(e.toString()); + } + } + } + } + } + + public void enviar(String s) throws Exception { + outputStream.write(s.getBytes()); + outputStream.flush(); + } + + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/ws/CoffeeSchedullerWS.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/ws/CoffeeSchedullerWS.java new file mode 100644 index 0000000..3cf2c8b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/ws/CoffeeSchedullerWS.java @@ -0,0 +1,31 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.eletronlivre.cofffeetimer.ws; + +import br.com.eletronlivre.cofffeetimer.WakeUpScheduler; +import java.rmi.RemoteException; +import javax.ejb.EJB; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.ejb.Stateless; + +/** + * + * @author vsenger + */ +@WebService() +@Stateless() +public class CoffeeSchedullerWS { + + @EJB + private WakeUpScheduler ejbRef;// Add business logic below. (Right-click in editor and choose + // "Insert Code > Add Web Service Operation") + + @WebMethod(operationName = "agendarTarefa") + public void agendarTarefa(@WebParam(name = "time") long time, @WebParam(name = "tt") long tt) throws RemoteException { + ejbRef.agendarTarefa(time, tt); + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java new file mode 100644 index 0000000..d1c0ea2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java @@ -0,0 +1,144 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.globalcode.eletronlivre.arduino.serial; + +import gnu.io.CommPortIdentifier; +import gnu.io.SerialPort; +import gnu.io.UnsupportedCommOperationException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Enumeration; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author vsenger + */ +public class Arduino { + + static boolean init = false; + static Enumeration portList; + static CommPortIdentifier portId; + static String messageString = "10"; + static SerialPort serialPort; + static OutputStream outputStream; + static InputStream inputStream; + static boolean outputBufferEmptyFlag = false; + static String defaultPort = "/dev/rfcomm0"; + //static String defaultPort = "/dev/tty.usbserial-A6007W3X"; + //static String defaultPort = "/dev/ttyUSB0"; + public static void begin(int bps) { + if (!init) { + init(); + } + + } + public static void delay(long milis) { + try { + Thread.sleep(milis); + } catch (InterruptedException ex) { + } + + } + + public static void init() { + init = true; + portList = CommPortIdentifier.getPortIdentifiers(); + + System.out.println("Iniciando"); + while (portList.hasMoreElements()) { + portId = (CommPortIdentifier) portList.nextElement(); + System.out.println(portId.getName()); + if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { + if (portId.getName().equals(defaultPort)) { + System.out.println("Found port " + defaultPort); + try { + serialPort = + (SerialPort) portId.open("SimpleWriteCOM17", 115200); + } catch (Exception e) { + System.out.println("Port in use."); + continue; + } + + + try { + outputStream = serialPort.getOutputStream(); + inputStream = serialPort.getInputStream(); + serialPort.setSerialPortParams(115200, + SerialPort.DATABITS_8, + SerialPort.STOPBITS_1, + SerialPort.PARITY_NONE); + + serialPort.notifyOnOutputEmpty(true); + } catch (UnsupportedCommOperationException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + System.out.println("Error setting event notification"); + System.out.println(e.toString()); + } + } + } + } + } + + public static void enviar(String s) throws Exception { + if (!init) { + init(); + } + + outputStream.write(s.getBytes()); + outputStream.flush(); + } + + public static void enviar(float f) throws Exception { + + enviar(new byte[]{(byte) f}); + } + //100, 1, 1024, 1, 9 + public static int map(int val, int minOriginal, int maxOriginal, int minTarget, int maxTarget) { + return val / ((maxOriginal - minOriginal) / (maxTarget - minTarget)); + + + } + public static void main(String[] args) throws Exception{ + enviar("L"); + } + public static void enviar(byte bytes[]) throws Exception { + if (!init) { + init(); + } + + System.out.println("Escrevendo..."); + outputStream.write((int)'B'); //my I2C ID + System.out.println(bytes[0]); + + outputStream.write(bytes[0] ==0 ? 10 : bytes[0] ); + outputStream.flush(); + System.out.println("Esperando..."); + + + } + class BluetoothListener extends Thread { + public void run() { + while(true) { + try { + if (inputStream.available() > 0) { + while(inputStream.available()>0) { + System.out.print(inputStream.read()); + } + } + } catch (IOException ex) { + Logger.getLogger(Arduino.class.getName()).log(Level.SEVERE, null, ex); + } + Arduino.delay(50); + + } + } + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/build.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/build.xml new file mode 100644 index 0000000..2b91f59 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project CoffeeTimerInterface. + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/build/built-jar.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/build/built-jar.properties new file mode 100644 index 0000000..9fa36ae --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/build/built-jar.properties @@ -0,0 +1,3 @@ +#Wed, 28 Sep 2011 12:13:11 -0300 + +/media/Vinicius/EletronLivre/Program-ME/Arduino\ Sketches/CoffeTimer/CoffeeTimerInterface= diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/dist/README.TXT b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/dist/README.TXT new file mode 100644 index 0000000..c254c93 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/dist/README.TXT @@ -0,0 +1,33 @@ +======================== +BUILD OUTPUT DESCRIPTION +======================== + +When you build an Java application project that has a main class, the IDE +automatically copies all of the JAR +files on the projects classpath to your projects dist/lib folder. The IDE +also adds each of the JAR files to the Class-Path element in the application +JAR files manifest file (MANIFEST.MF). + +To run the project from the command line, go to the dist folder and +type the following: + +java -jar "CoffeeTimerInterface.jar" + +To distribute this project, zip up the dist folder (including the lib folder) +and distribute the ZIP file. + +Notes: + +* If two JAR files on the project classpath have the same name, only the first +JAR file is copied to the lib folder. +* Only JAR files are copied to the lib folder. +If the classpath contains other types of files or folders, none of the +classpath elements are copied to the lib folder. In such a case, +you need to copy the classpath elements to the lib folder manually after the build. +* If a library on the projects classpath also has a Class-Path element +specified in the manifest,the content of the Class-Path element has to be on +the projects runtime path. +* To set a main class in a standard Java project, right-click the project node +in the Projects window and choose Properties. Then click Run and enter the +class name in the Main Class field. Alternatively, you can manually type the +class name in the manifest Main-Class element. diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/manifest.mf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/build-impl.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/build-impl.xml new file mode 100644 index 0000000..b93fbb9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/build-impl.xml @@ -0,0 +1,1042 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + Must select one file in the IDE or set profile.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/genfiles.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/genfiles.properties new file mode 100644 index 0000000..b15c5bf --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=68706b55 +build.xml.script.CRC32=edf4fd04 +build.xml.stylesheet.CRC32=28e38971@1.38.2.45 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=68706b55 +nbproject/build-impl.xml.script.CRC32=20404a75 +nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/private/config.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/private/private.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/private/private.properties new file mode 100644 index 0000000..3a89297 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/private/private.properties @@ -0,0 +1,6 @@ +compile.on.save=true +do.depend=false +do.jar=true +javac.debug=true +javadoc.preview=true +user.properties.file=/home/vsenger/.netbeans/6.9/build.properties diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/project.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/project.properties new file mode 100644 index 0000000..f11bd26 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/project.properties @@ -0,0 +1,75 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=CoffeeTimerInterface +application.vendor=vsenger +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/CoffeeTimerInterface.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +jar.compress=false +javac.classpath=\ + ${libs.javaee-api-6.0.classpath} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=coffeetimerinterface.Main +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/project.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/project.xml new file mode 100644 index 0000000..0d53d82 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + CoffeeTimerInterface + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/src/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/src/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java new file mode 100644 index 0000000..cc2e512 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeTimerInterface/src/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java @@ -0,0 +1,21 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package br.com.eletronlivre.cofffeetimer; + +import java.rmi.RemoteException; +import javax.ejb.Remote; + +/** + * + * @author vsenger + */ +@Remote +public interface WakeUpScheduler { + + void agendarTarefa() throws RemoteException; + void agendarTarefa(long time, long tt) throws RemoteException; + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build.xml new file mode 100644 index 0000000..cb35d0d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + Builds, tests, and runs the project CoffeeWebScheduler. + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/META-INF/MANIFEST.MF b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/META-INF/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/classes/.netbeans_automatic_build b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/classes/.netbeans_update_resources b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/sun-web.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/sun-web.xml new file mode 100644 index 0000000..227d849 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/sun-web.xml @@ -0,0 +1,11 @@ + + + + /CoffeeWebScheduler + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/duke.gif b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/duke.gif new file mode 100644 index 0000000..a358362 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/duke.gif differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/index.jsp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/index.jsp new file mode 100644 index 0000000..47b0821 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/build/web/index.jsp @@ -0,0 +1,34 @@ +<%@page import="java.util.Date"%> +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + Cafeteira na Web + + +

Vida além do Java...

+
+ +

Agendar por tempo

+
+ Segundos + Minutos +
+ Em quanto tempo que ligar a cafeteira ?
+ Por quanto tempo quer ligar a cafeteira ?
+ +
+ <% + if (request.getAttribute("horarioAgendado") != null) { + Date horario = (Date) request.getAttribute("horarioAgendado"); + out.println("

Café agendado para "); + out.println(horario); + out.println("

"); + } + %> + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/ant-deploy.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/ant-deploy.xml new file mode 100644 index 0000000..b03100d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/ant-deploy.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/build-impl.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/build-impl.xml new file mode 100644 index 0000000..49f4b6b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/build-impl.xml @@ -0,0 +1,1081 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set build.web.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.war + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + Must select a file in the IDE or set jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. + + + Launching ${browse.url} + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/genfiles.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/genfiles.properties new file mode 100644 index 0000000..e4c2012 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=8dde883d +build.xml.script.CRC32=1f0e6d58 +build.xml.stylesheet.CRC32=651128d4@1.33.1.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=8dde883d +nbproject/build-impl.xml.script.CRC32=66c6dde0 +nbproject/build-impl.xml.stylesheet.CRC32=0cbf5bb7@1.33.1.1 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/private/private.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/private/private.properties new file mode 100644 index 0000000..286ece9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/private/private.properties @@ -0,0 +1,7 @@ +deploy.ant.properties.file=/home/vsenger/.netbeans/6.9/gfv3-1780747739.properties +j2ee.platform.is.jsr109=true +j2ee.server.home=/java/nb7-glassfish-3.1.1/glassfish +j2ee.server.instance=[/java/nb7-glassfish-3.1.1/glassfish]deployer:gfv3ee6:localhost:4848 +javac.debug=true +javadoc.preview=true +user.properties.file=/home/vsenger/.netbeans/6.9/build.properties diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/private/private.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/private/private.xml new file mode 100644 index 0000000..c1f155a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/project.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/project.properties new file mode 100644 index 0000000..3dae937 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/project.properties @@ -0,0 +1,90 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.web.dir}/WEB-INF/classes +build.classes.excludes=**/*.java,**/*.form +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +build.web.dir=${build.dir}/web +build.web.excludes=${build.classes.excludes} +client.urlPart= +compile.jsps=false +conf.dir=${source.root}/conf +debug.classpath=${build.classes.dir}:${javac.classpath} +debug.test.classpath=\ + ${run.test.classpath} +display.browser=true +dist.dir=dist +dist.ear.war=${dist.dir}/${war.ear.name} +dist.javadoc.dir=${dist.dir}/javadoc +dist.war=${dist.dir}/${war.name} +endorsed.classpath=\ + ${libs.javaee-endorsed-api-6.0.classpath} +excludes= +includes=** +j2ee.compile.on.save=true +j2ee.deploy.on.save=true +j2ee.platform=1.6 +j2ee.platform.classpath=${j2ee.server.home}/modules/javax.security.jacc.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.jms.jar:${j2ee.server.home}/modules/jstl-impl.jar:${j2ee.server.home}/modules/javax.management.j2ee.jar:${j2ee.server.home}/modules/javax.transaction.jar:${j2ee.server.home}/modules/endorsed/javax.annotation.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/jsf-impl.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/jsf-api.jar:${j2ee.server.home}/modules/javax.servlet.jar:${j2ee.server.home}/modules/javax.enterprise.deploy.jar:${j2ee.server.home}/modules/jaxrpc-api-osgi.jar:${j2ee.server.home}/modules/javax.resource.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/jaxr-api-osgi.jar:${j2ee.server.home}/modules/javax.security.auth.message.jar +j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar +j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar +j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsit.classpath= +j2ee.server.type=gfv3ee6 +jar.compress=false +javac.classpath=\ + ${reference.CoffeeTimerInterface.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.debug=true +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.6 +javac.target=1.6 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.preview=true +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +lib.dir=${web.docbase.dir}/WEB-INF/lib +persistence.xml.dir=${conf.dir} +platform.active=default_platform +project.CoffeeTimerInterface=../CoffeeTimerInterface +reference.CoffeeTimerInterface.jar=${project.CoffeeTimerInterface}/dist/CoffeeTimerInterface.jar +resource.dir=setup +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +# Space-separated list of JVM arguments used when running a class with a main method or a unit test +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): +runmain.jvmargs=-Dgnu.io.rxtx.SerialPorts=/dev/rfcomm1 +source.encoding=UTF-8 +source.root=src +src.dir=${source.root}/java +test.src.dir=test +war.content.additional= +war.ear.name=CoffeeWebScheduler.war +war.name=CoffeeWebScheduler.war +web.docbase.dir=web +webinf.dir=web/WEB-INF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/project.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/project.xml new file mode 100644 index 0000000..bfe940b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/nbproject/project.xml @@ -0,0 +1,33 @@ + + + org.netbeans.modules.web.project + + + CoffeeWebScheduler + 1.6.5 + + + ${reference.CoffeeTimerInterface.jar} + WEB-INF/lib + + + + + + + + + + + + + CoffeeTimerInterface + jar + + jar + clean + jar + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/src/conf/MANIFEST.MF b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/src/conf/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/src/java/teste/Agendador.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/src/java/teste/Agendador.java new file mode 100644 index 0000000..98af6eb --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/src/java/teste/Agendador.java @@ -0,0 +1,97 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package teste; + +import br.com.eletronlivre.cofffeetimer.WakeUpScheduler; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Calendar; +import javax.ejb.EJB; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author vsenger + */ +@WebServlet(name = "Agendador", urlPatterns = {"/Agendador"}) +public class Agendador extends HttpServlet { + + @EJB + private WakeUpScheduler wakeUpBean; + + /** + * Processes requests for both HTTP GET and POST methods. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + PrintWriter out = response.getWriter(); + try { + int tipo = Integer.parseInt(request.getParameter("tipoValor")); + int emQuantoTempo = Integer.parseInt(request.getParameter("txtEmQuantoTempo")); + int porQuantoTempo = Integer.parseInt(request.getParameter("txtPorQuantoTempo")); + Calendar cal = Calendar.getInstance(); + cal.add(tipo == 2 ? Calendar.MINUTE : Calendar.SECOND, emQuantoTempo); + request.setAttribute("horarioAgendado", cal.getTime()); + + emQuantoTempo *= 1000; + porQuantoTempo *= 1000; + if (tipo == 2) { + emQuantoTempo *= 60; + porQuantoTempo *= 60; + } + wakeUpBean.agendarTarefa(emQuantoTempo, porQuantoTempo); + RequestDispatcher dispatcher = request.getRequestDispatcher("index.jsp"); + dispatcher.forward(request, response); + } finally { + out.close(); + } + } + + // + /** + * Handles the HTTP GET method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/web/WEB-INF/sun-web.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/web/WEB-INF/sun-web.xml new file mode 100644 index 0000000..227d849 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/web/WEB-INF/sun-web.xml @@ -0,0 +1,11 @@ + + + + /CoffeeWebScheduler + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/web/duke.gif b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/web/duke.gif new file mode 100644 index 0000000..a358362 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/web/duke.gif differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/web/index.jsp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/web/index.jsp new file mode 100644 index 0000000..47b0821 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeTimer/CoffeeWebScheduler/web/index.jsp @@ -0,0 +1,34 @@ +<%@page import="java.util.Date"%> +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + Cafeteira na Web + + +

Vida além do Java...

+
+ +

Agendar por tempo

+
+ Segundos + Minutos +
+ Em quanto tempo que ligar a cafeteira ?
+ Por quanto tempo quer ligar a cafeteira ?
+ +
+ <% + if (request.getAttribute("horarioAgendado") != null) { + Date horario = (Date) request.getAttribute("horarioAgendado"); + out.println("

Café agendado para "); + out.println(horario); + out.println("

"); + } + %> + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeeWebInterface/build/web/WEB-INF/sun-web.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeeWebInterface/build/web/WEB-INF/sun-web.xml new file mode 100644 index 0000000..99279a2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/CoffeeWebInterface/build/web/WEB-INF/sun-web.xml @@ -0,0 +1,11 @@ + + + + /CoffeeWebInterface + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/BlueSmirf/BlueSmirf.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/BlueSmirf/BlueSmirf.pde new file mode 100644 index 0000000..77c31bb --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/BlueSmirf/BlueSmirf.pde @@ -0,0 +1,74 @@ +#include +#include + +char comando[16]; +int luz= 0; + +LiquidCrystal lcd(4, 9, 14, 15, 16, 17); +// set up a new serial port + +void setup() +{ + pinMode(3, OUTPUT); + pinMode(4, OUTPUT); + Wire.begin(); + Serial.begin(115200); + initLCD(); +} + +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Mater I2C On"); + lcd.setCursor(0, 1); + lcd.print("Waiting command."); +} + +void loop () +{ + if(Serial.available()>0) { + limpaComando(); + + int counter =0; + while(Serial.available()>0) { + comando[counter++]=Serial.read(); + delay(20); + } + lcd.clear(); + lcd.setCursor(0, 0); + + lcd.print(comando); + executarComando(); + //lcd.print("Aguardando...."); + for(int x=0;x<4;x++) { + digitalWrite(4, HIGH); + delay(30); + digitalWrite(4, LOW); + delay(30); + } + } +} + +void executarComando() { + lcd.setCursor(0, 1); + lcd.print(comando[0]); + lcd.setCursor(2, 1); + lcd.print("commuicated..."); + Wire.beginTransmission(comando[0]); + Wire.send(comando); + Wire.endTransmission(); +} +void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } +} + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/EZ1_Analogica_teste/EZ1_Analogica_teste.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/EZ1_Analogica_teste/EZ1_Analogica_teste.pde new file mode 100644 index 0000000..bbe9c44 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/EZ1_Analogica_teste/EZ1_Analogica_teste.pde @@ -0,0 +1,15 @@ +void setup() { + Serial.begin(9600); + +} + +void loop(){ + + int valor = analogRead(1); + Serial.println(valor); + Serial.println(valor*1.6); + Serial.println("---------------"); + + delay(300); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/FitaLed_ViaSerial/FitaLed_ViaSerial.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/FitaLed_ViaSerial/FitaLed_ViaSerial.pde new file mode 100644 index 0000000..560faf1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/FitaLed_ViaSerial/FitaLed_ViaSerial.pde @@ -0,0 +1,70 @@ +#define Q2 9 +#define Q3 6 +#define Q4 18 + + + +void setup() { + Serial.begin(9600); + pinMode(Q2, OUTPUT); //red + pinMode(Q3, OUTPUT); //green + pinMode(Q4, OUTPUT); +} + +int red; +int green; +int blue; + +void loop() { + + + /*if(Serial.available()>0) + { + red = byte(Serial.read()); + delay(20); + + green = byte(Serial.read()); + delay(20); + blue= byte(Serial.read()); + delay(20); + //red = red = -1 ? 0 : red; + //blue = blue = -1 ? 0 : blue; + //green = green = -1 ? 0 : green; + } + analogWrite(Q2, red); + //analogWrite(Q3, green); + //digitalWrite(Q4, blue); + */ + for(int x=0;x<255;x++) { + analogWrite(Q2, x); + delay(10); + } + for(int x=0;x<255;x++) { + analogWrite(Q3, x); + delay(10); + } + desligar(); + delay(500); + ligar(); + delay(500); + desligar(); + delay(500); + ligar(); + delay(500); + desligar(); + delay(500); + ligar(); + delay(500); + +} +void desligar() { + analogWrite(Q2,0); + analogWrite(Q3,0); +} +void ligar() { + analogWrite(Q2,255); + analogWrite(Q3,255); +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_RGB_Serial_OK/Fita_RGB_Serial_OK.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_RGB_Serial_OK/Fita_RGB_Serial_OK.pde new file mode 100644 index 0000000..87ad6c8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_RGB_Serial_OK/Fita_RGB_Serial_OK.pde @@ -0,0 +1,55 @@ +#define RED 9 +#define GREEN 10 +#define BLUE 11 +#define ABRIDOR 12 + + +void setup() { + Serial.begin(9600); + pinMode(RED, OUTPUT); //red + pinMode(GREEN, OUTPUT); //green + pinMode(BLUE, OUTPUT); + pinMode(ABRIDOR, OUTPUT); + +} + +int red=200; +int green=200; +int blue=200; + +void loop() { + if(Serial.available()>0) + { + lerSerial(); + } + ligarStatus(); + +} +void lerSerial() { + red = byte(Serial.read()); + delay(5); + green = byte(Serial.read()); + delay(5); + blue= byte(Serial.read()); + delay(5); + +} +void ligarStatus() { + analogWrite(RED, red); + analogWrite(GREEN, green); + analogWrite(BLUE, blue); +} +void desligar() { + analogWrite(RED, 0); + analogWrite(GREEN, 0); + analogWrite(BLUE, 0); +} +/* +void ligar() { + analogWrite(Q2,255); + analogWrite(Q3,255); + }*/ + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/Fita_de_LEDs.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/Fita_de_LEDs.pde new file mode 100644 index 0000000..2ddcb1f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/Fita_de_LEDs.pde @@ -0,0 +1,113 @@ +#define BLUE 8 +#define GREEN 9 +#define RED 17 + +void setup() { + pinMode(5, OUTPUT); + pinMode(8, OUTPUT); + pinMode(9, OUTPUT); + pinMode(17, OUTPUT); +} + +void loop() { + int op = random(1,5); + piscaMaluco(20,20); + + switch(op) { + case 1: + piscaMaluco(random(50,100),random(20,50)); + break; + case 2: + ligaG(); + break; + case 3: + desligaG(); + break; + case 4: + liga(); + break; + case 5: + comLDR(); + break; + case 6: + piscaMaluco(random(10,100), random(10,100)); + break; + } + +} +void comLDR() { + + analogWrite(escolheLed(), analogRead(5)); + delay(random(1000,3000)); + +} + +int escolheLed() { + int r = random(1,3); + if(r==1) return 8; + if(r==2) return 9; + if(r==3) return 17; +} +void desligaTudo() { + digitalWrite(RED, LOW); + digitalWrite(GREEN, LOW); + digitalWrite(BLUE, LOW); +} +void liga() { + desligaTudo(); + int l = escolheLed(); + digitalWrite(l,HIGH); + +} + +void pisca(int led, int repeticoes, int d) { + desligaTudo(); + for(int x=0;x-1;x--) { + analogWrite(9, x); + delay(10); + } +} + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/a1.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/a1.pde new file mode 100644 index 0000000..24251d7 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/a1.pde @@ -0,0 +1,5 @@ +int soma(int x, int y) { + return x + y; + +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/applet/Fita_de_LEDs.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/applet/Fita_de_LEDs.cpp new file mode 100644 index 0000000..9ef2bbb --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/applet/Fita_de_LEDs.cpp @@ -0,0 +1,145 @@ +#define BLUE 8 +#define GREEN 9 +#define RED 17 + +#include "WProgram.h" +void setup(); +void loop(); +void comLDR(); +int escolheLed(); +void desligaTudo(); +void liga(); +void pisca(int led, int repeticoes, int d); +void piscaMaluco(int repeticoes, int d); +void ligaG(); +void ligaRB(); +void desligaG(); +int soma(int x, int y); +void setup() { + pinMode(5, OUTPUT); + pinMode(8, OUTPUT); + pinMode(9, OUTPUT); + pinMode(17, OUTPUT); +} + +void loop() { + int op = random(1,5); + piscaMaluco(20,20); + + switch(op) { + case 1: + piscaMaluco(random(50,100),random(20,50)); + break; + case 2: + ligaG(); + break; + case 3: + desligaG(); + break; + case 4: + liga(); + break; + case 5: + comLDR(); + break; + case 6: + piscaMaluco(random(10,100), random(10,100)); + break; + } + +} +void comLDR() { + + analogWrite(escolheLed(), analogRead(5)); + delay(random(1000,3000)); + +} + +int escolheLed() { + int r = random(1,3); + if(r==1) return 8; + if(r==2) return 9; + if(r==3) return 17; +} +void desligaTudo() { + digitalWrite(RED, LOW); + digitalWrite(GREEN, LOW); + digitalWrite(BLUE, LOW); +} +void liga() { + desligaTudo(); + int l = escolheLed(); + digitalWrite(l,HIGH); + +} + +void pisca(int led, int repeticoes, int d) { + desligaTudo(); + for(int x=0;x-1;x--) { + analogWrite(9, x); + delay(10); + } +} + + + + + + + +int soma(int x, int y) { + return x + y; + +} + + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/applet/wiring.c.o new file mode 100644 index 0000000..d7fdf00 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/applet/wiring_pulse.c.o new file mode 100644 index 0000000..985ee90 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/applet/wiring_shift.c.o new file mode 100644 index 0000000..1f193bc Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/exemplo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/exemplo.pde new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Fita_de_LEDs/exemplo.pde @@ -0,0 +1 @@ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/H48C/H48C.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/H48C/H48C.pde new file mode 100644 index 0000000..95e288b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/H48C/H48C.pde @@ -0,0 +1,126 @@ +//// VARS +int CS_pin = 9; +int DIO_pin = 10; +int CLK_pin = 11; + +byte tempLSB = 0; +byte tempMSB = 0; + +int aX = 0; +int aY = 0; +int aZ = 0; + +//// FUNCTIONS +void StartMassurement() { + pinMode(DIO_pin, OUTPUT); + digitalWrite(CS_pin, LOW); + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + digitalWrite(DIO_pin, HIGH); + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + + } + +void ShiftOutNibble(byte DataOutNibble) { + for(int i = 3; i >= 0; i--) { // i = 3 ... 2 ... 1 ... 0 + digitalWrite(CLK_pin, LOW); + // set DIO first + if ((DataOutNibble & (1 << i)) == (1 << i)) { // DataOutNibble AND 1 x 2^i Equals 1 x 2^i ? + digitalWrite(DIO_pin, HIGH); + + } + else { + digitalWrite(DIO_pin, LOW); + + } + // with CLK rising edge the chip reads the DIO from arduino in + digitalWrite(CLK_pin, HIGH); + // data rate is f_clk 2.0 Mhz --> 0,5 micro seeconds + delayMicroseconds(1); // :-) just nothing + } + +} + +void SampleIt() { + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + + pinMode(DIO_pin, INPUT); + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + digitalWrite(CLK_pin, HIGH); + if (digitalRead(DIO_pin)== LOW) { + // Blink LED because ok + } +} + +byte ShiftInNibble() { + byte resultNibble; + resultNibble = 0; + + for(int i = 3 ; i >= 0; i--) { + // The chip Shift out results on falling CLK + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); // :-) just nothing + if( digitalRead(DIO_pin) == HIGH) { + resultNibble += 1 << i; + } + else { + resultNibble += 0 << i; + } + digitalWrite(CLK_pin, HIGH); + } +return resultNibble; +} + +void EndMessurement() { + digitalWrite(CS_pin, HIGH); + digitalWrite(CLK_pin, HIGH); +} + +int GetValue(byte Axis) { // x = B1000, y = 1001, z = B1010 + int Result = 0; + StartMassurement(); + ShiftOutNibble(Axis); + SampleIt(); + Result = (ShiftInNibble() << 8) + (ShiftInNibble() << 4) + ShiftInNibble(); + EndMessurement(); + + return Result; + } + +//// SETUP +void setup() { + Serial.begin(9600); + pinMode(CS_pin, OUTPUT); + pinMode(CLK_pin, OUTPUT); + pinMode(DIO_pin, OUTPUT); + // initialize device & reset + digitalWrite(CS_pin,LOW); + digitalWrite(CLK_pin,LOW); + delayMicroseconds(1); + digitalWrite(CS_pin, HIGH); + digitalWrite(CLK_pin,HIGH); +} + + +//// LOOP +void loop() { + Serial.print("X"); + Serial.print(2048 - GetValue(B1000)); + Serial.print("Y"); + Serial.print(2048 - GetValue(B1001)); + //Serial.print(2048 - GetValue(B1010)); + + + Serial.println(""); + delay(100); +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Hitachi_H48C/Hitachi_H48C.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Hitachi_H48C/Hitachi_H48C.pde new file mode 100644 index 0000000..2cd441d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Hitachi_H48C/Hitachi_H48C.pde @@ -0,0 +1,133 @@ +/* +///////////////////////////////// +Htachi H48C3 Axis Accelerometer +parallax (#28026) + +AUTHOR: kiilo kiilo@kiilo.org +License: http://creativecommons.org/licenses/by-nc-sa/2.5/ch/ + +http://parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/28026/List/1/ProductID/97/Default.aspx?SortField=ProductName%2cProductName +http://sage.medienkunst.ch/tiki-index.php?page=HowTo_Arduino_Parallax_H48C_Accelerometer +http://arduino.cc + +///////////////////////////////// +*/ +//// VARS +int CS_pin = 9; +int CLK_pin = 11; +int DIO_pin = 10; + +int aX = 0; +int aY = 0; +int aZ = 0; + +//// FUNCTIONS +void StartBit() { + pinMode(DIO_pin, OUTPUT); + digitalWrite(CS_pin, LOW); + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + digitalWrite(DIO_pin, HIGH); + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + + } + +void ShiftOutNibble(byte DataOutNibble) { + for(int i = 3; i >= 0; i--) { // i = 3 ... 2 ... 1 ... 0 + digitalWrite(CLK_pin, LOW); + // set DIO first + if ((DataOutNibble & (1 << i)) == (1 << i)) { // DataOutNibble AND 1 x 2^i Equals 1 x 2^i ? + digitalWrite(DIO_pin, HIGH); + } + else { + digitalWrite(DIO_pin, LOW); + } + // with CLK rising edge the chip reads the DIO from arduino in + digitalWrite(CLK_pin, HIGH); + // data rate is f_clk 2.0 Mhz --> 0,5 micro seeconds + delayMicroseconds(1); // :-) just nothing + } +} + +void SampleIt() { + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + + pinMode(DIO_pin, INPUT); + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + digitalWrite(CLK_pin, HIGH); + if (digitalRead(DIO_pin)== LOW) { + // Blink LED because ok + } +} + +byte ShiftInNibble() { + byte resultNibble; + resultNibble = 0; + + for(int i = 3 ; i >= 0; i--) { // from bit 3 to 0 + // The chip Shift out results on falling CLK + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); // :-) just nothing + if( digitalRead(DIO_pin) == HIGH) { // BIT set or not? + resultNibble += 1 << i; // Store 1 x 2^i in our ResultNibble + } + else { + resultNibble += 0 << i; // YES this is alway 0, just for symetry ;-) + } + digitalWrite(CLK_pin, HIGH); + //delayMicroseconds(1); // :-) just nothing + } +return resultNibble; +} + +void EndBit() { + digitalWrite(CS_pin, HIGH); + digitalWrite(CLK_pin, HIGH); +} + +int GetValue(byte Command) { // x = B1000, y = B1001, z = B1010 + int Result = 0; + StartBit(); + ShiftOutNibble(Command); + SampleIt(); + Result = 2048 - ((ShiftInNibble() << 8) + (ShiftInNibble() << 4) + ShiftInNibble()); + EndBit(); + + return Result; + } + +//// SETUP +void setup() { + Serial.begin(115200); + pinMode(CS_pin, OUTPUT); + pinMode(CLK_pin, OUTPUT); + pinMode(DIO_pin, OUTPUT); + // initialize device & reset + digitalWrite(CS_pin,LOW); + digitalWrite(CLK_pin,LOW); + delayMicroseconds(1); + digitalWrite(CS_pin, HIGH); + digitalWrite(CLK_pin,HIGH); +} + + +//// LOOP +void loop() { + + aX = GetValue(B1000); + aY = GetValue(B1010); + aZ = GetValue(B1011); + + Serial.print(aX); + Serial.print(" "); + Serial.print(aY); + Serial.print(" "); + Serial.print(aZ); + Serial.println(" "); + delay(100); // loop every 10 times per sec. +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/Servo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/Servo.pde new file mode 100644 index 0000000..b4553af --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/Servo.pde @@ -0,0 +1,21 @@ +#include + +Servo myservo9; // create servo object to control a servo +Servo myservo10; // create servo object to control a servo + +int pos = 0; // variable to store the servo position + +void setup() +{ + myservo9.attach(11); // attaches the servo on pin 9 to the servo object + myservo10.attach(10); // attaches the servo on pin 10 to the servo object +} + +void loop() +{ + int val = map(analogRead(1), 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) + myservo10.write(val); // sets the servo position according to the scaled value + delay(15); // waits for the servo to get there + +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..dc28a59 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Print.cpp.o new file mode 100644 index 0000000..6205c51 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.cpp new file mode 100644 index 0000000..b53f628 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.cpp @@ -0,0 +1,35 @@ +#include + +#include "WProgram.h" +void setup(); +void loop(); +Servo myservo10; // create servo object to control a servo + +int pos = 0; // variable to store the servo position + +void setup() +{ + myservo10.attach(10); // attaches the servo on pin 10 to the servo object +} + +void loop() +{ + int val = map(analogRead(1), 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) + myservo10.write(val); // sets the servo position according to the scaled value + delay(15); // waits for the servo to get there + +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.cpp.o new file mode 100644 index 0000000..dd8af4e Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.elf new file mode 100644 index 0000000..b57ff8f Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.hex new file mode 100644 index 0000000..76cbef4 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.hex @@ -0,0 +1,125 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C94A5010C948A000C948A000C948A00EC +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C00000004C0111241FBECFEFD8E0DEBFCDBF32 +:1000D00011E0A0E0B1E0E0EBF7E002C005900D9286 +:1000E000A230B107D9F711E0A2E0B1E001C01D9242 +:1000F000A431B107E1F710E0C4ECD0E004C02297CE +:10010000FE010E94D203C23CD107C9F70E949E01A2 +:100110000C94D6030C940000FC0110828FEF8183B5 +:100120000895EF92FF920F931F93CF93DF93EC010B +:100130009B0177FF03C020E030E005C0653B7105FF +:1001400014F024EB30E02983EA806B8170E06E19B3 +:100150007109882777FD8095982F982F872F762F04 +:10016000662730E040E050E00E944D0324EB30E091 +:1001700040E050E00E947F03FF2400E010E0102FD9 +:100180000F2DFE2CEE24E20EF31E041F151FC801D6 +:10019000B70128E030E040E050E00E947F03888112 +:1001A000893029F4309389002093880006C08A3072 +:1001B00021F430938B0020938A00DF91CF911F911F +:1001C0000F91FF90EF900895CF93DF93EC01FB0127 +:1001D000CB010997029710F080E054C0CA0160E19A +:1001E00070E00E946C036A83C90160E170E00E94C4 +:1001F0006C036B83E8838FEF89838E2F60E00E940E +:10020000B702888161E00E949702809102018823F1 +:1002100011F5809103018823F1F42FB7F89482E05F +:10022000809380008AE18093810088EB9BE090932B +:1002300089008093880090938B0080938A0080E4EB +:100240009CE9909387008093860080916F00887F5F +:1002500080936F002FBF8881893041F481E08093C3 +:100260000201809180008F73806809C08A3049F450 +:1002700081E080930301809180008F7C8062809375 +:10028000800081E0DF91CF91089540E252E020E6C6 +:1002900039E00E94E400089584E091E00E948C001F +:1002A0000895AF92BF92CF92DF92EF92FF920F9399 +:1002B0001F9381E00E94790200D000D0AA2797FD09 +:1002C000A095BA2F23EB30E040E050E0EDB7FEB749 +:1002D0002183328343835483BC01CD0120E030E08D +:1002E00040E050E0EFEFEE2EE3E0FE2E012D112D69 +:1002F000AA24BB2465010E9404039B01AC010F905A +:100300000F900F900F9084E091E0B9010E9491004E +:100310006FE070E080E090E00E9415021F910F9165 +:10032000FF90EF90DF90CF90BF90AF90089584E062 +:1003300091E06AE070E00E94450108950E943F024A +:100340000E9497010E945101FDCF1F920F920FB69C +:100350000F9211242F938F939F93AF93BF9380910C +:10036000080190910901A0910A01B0910B01019639 +:10037000A11DB11D8093080190930901A0930A016A +:10038000B0930B0180910C0190910D01A0910E0191 +:10039000B0910F018050904CAF4FBF4F80930C0134 +:1003A00090930D01A0930E01B0930F0127C080918F +:1003B0000C0190910D01A0910E01B0910F01805898 +:1003C0009E43A040B04080930C0190930D01A093F8 +:1003D0000E01B0930F018091100190911101A09135 +:1003E0001201B09113010196A11DB11D809310015E +:1003F00090931101A0931201B093130180910C010D +:1004000090910D01A0910E01B0910F0181589E4372 +:10041000A040B04060F6BF91AF919F918F912F9116 +:100420000F900FBE0F901F901895EF92FF920F93B1 +:100430001F937B018C018FB7F8944091100150916C +:10044000110160911201709113018FBF2FB7F894C1 +:100450008091100190911101A0911201B0911301AE +:100460002FBF841B950BA60BB70BE816F9060A07DE +:100470001B0760F71F910F91FF90EF9008957894FC +:1004800084B5826084BD84B5816084BD85B5826099 +:1004900085BD85B5816085BDEEE6F0E08081816037 +:1004A0008083E1E8F0E080818260808380818160E8 +:1004B0008083E0E8F0E0808181608083E1EBF0E020 +:1004C000808184608083E0EBF0E0808181608083C4 +:1004D000EAE7F0E0808184608083808182608083AD +:1004E0008081816080838081806880831092C100D8 +:1004F00008958770909100019295990F990F907CC3 +:10050000982B90937C0080917A00806480937A008D +:1005100080917A0086FDFCCF20917800409179008F +:10052000942F80E030E0282B392BC9010895282F23 +:1005300030E0C90186569F4FFC0194912A573F4FE6 +:10054000F9018491882391F0E82FF0E0EE0FFF1F6E +:10055000E859FF4FA591B491662329F48C919095A9 +:1005600089238C9308958C91892B8C930895482F1F +:1005700050E0CA0182559F4FFC012491CA01865662 +:100580009F4FFC0194914A575F4FFA0134913323F6 +:10059000D1F1222331F1233021F4809180008F7733 +:1005A00005C0243031F4809180008F7D80938000DD +:1005B00018C0213019F484B58F7704C0223021F49B +:1005C00084B58F7D84BD0DC0263021F48091B000AC +:1005D0008F7705C0273029F48091B0008F7D8093FC +:1005E000B000E32FF0E0EE0FFF1FEE58FF4FA59194 +:1005F000B491662329F48C91909589238C93089566 +:100600008C91892B8C9308952F923F924F925F92F9 +:100610006F927F928F929F92AF92BF92CF92DF9212 +:10062000EF92FF920F931F93DF93CF93CDB7DEB777 +:100630003B014C0119012A016D897E898F89988DB2 +:100640006A197B098C099D09621A730A840A950A42 +:10065000A40193010E944D03E218F308040915094F +:10066000A80197010E947F032A0D3B1D4C1D5D1DB3 +:10067000B901CA01CF91DF911F910F91FF90EF90C7 +:10068000DF90CF90BF90AF909F908F907F906F90B2 +:100690005F904F903F902F900895629FD001739F7D +:1006A000F001829FE00DF11D649FE00DF11D929F0E +:1006B000F00D839FF00D749FF00D659FF00D99274D +:1006C000729FB00DE11DF91F639FB00DE11DF91F71 +:1006D000BD01CF011124089597FB092E07260AD0EA +:1006E00077FD04D027D006D000201AF470956195CC +:1006F0007F4F0895F6F7909581959F4F089597FB4A +:10070000092E05260ED057FD04D028D00AD0001C93 +:1007100038F450954095309521953F4F4F4F5F4F9E +:100720000895F6F790958095709561957F4F8F4F5E +:100730009F4F0895AA1BBB1B51E107C0AA1FBB1FF7 +:10074000A617B70710F0A61BB70B881F991F5A955D +:10075000A9F780959095BC01CD010895A1E21A2ECC +:10076000AA1BBB1BFD010DC0AA1FBB1FEE1FFF1F55 +:10077000A217B307E407F50720F0A21BB30BE40BA5 +:10078000F50B661F771F881F991F1A9469F76095EC +:100790007095809590959B01AC01BD01CF010895A6 +:1007A000EE0FFF1F0590F491E02D0994F894FFCF10 +:0207B000010046 +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.pde new file mode 100644 index 0000000..b4553af --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/Servo.pde @@ -0,0 +1,21 @@ +#include + +Servo myservo9; // create servo object to control a servo +Servo myservo10; // create servo object to control a servo + +int pos = 0; // variable to store the servo position + +void setup() +{ + myservo9.attach(11); // attaches the servo on pin 9 to the servo object + myservo10.attach(10); // attaches the servo on pin 10 to the servo object +} + +void loop() +{ + int val = map(analogRead(1), 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) + myservo10.write(val); // sets the servo position according to the scaled value + delay(15); // waits for the servo to get there + +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/WInterrupts.c.o new file mode 100644 index 0000000..b74dfbb Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/WMath.cpp.o new file mode 100644 index 0000000..4e4cf44 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/core.a new file mode 100644 index 0000000..0cb3dcf Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/pins_arduino.c.o new file mode 100644 index 0000000..c450af7 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring.c.o new file mode 100644 index 0000000..acbd542 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_analog.c.o new file mode 100644 index 0000000..b56797d Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_digital.c.o new file mode 100644 index 0000000..3928ccd Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_pulse.c.o new file mode 100644 index 0000000..525eda2 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_serial.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_serial.c.o new file mode 100644 index 0000000..b8d4c17 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_serial.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_shift.c.o new file mode 100644 index 0000000..8e0db5b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/Servo/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/fita_led_vok/fita_led_vok.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/fita_led_vok/fita_led_vok.pde new file mode 100644 index 0000000..67c60d9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/fita_led_vok/fita_led_vok.pde @@ -0,0 +1,34 @@ +void setup() { + pinMode(6,OUTPUT); //blue + pinMode(9,OUTPUT); //verde + pinMode(18,OUTPUT); //vermelho + +} + +void loop() { + for(int x=0;x<2;x++) { + digitalWrite(9, HIGH); + delay(200); + digitalWrite(9, LOW); + delay(200); + } + + for(int x=0;x<2;x++) { + for(int x=0;x<250;x++) { + analogWrite(9, x); + delay(10); + } + digitalWrite(18, HIGH); + delay(200); + for(int x=250;x>0;x--) { + analogWrite(9, x); + delay(10); + } + + digitalWrite(18, LOW); + delay(200); + } + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/__MACOSX/hrmi_demos/._.DS_Store b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/__MACOSX/hrmi_demos/._.DS_Store new file mode 100644 index 0000000..460d887 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/__MACOSX/hrmi_demos/._.DS_Store differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/__MACOSX/hrmi_demos/._arduino_simple b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/__MACOSX/hrmi_demos/._arduino_simple new file mode 100644 index 0000000..b34a552 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/__MACOSX/hrmi_demos/._arduino_simple differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/__MACOSX/hrmi_demos/arduino_simple/._.DS_Store b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/__MACOSX/hrmi_demos/arduino_simple/._.DS_Store new file mode 100644 index 0000000..460d887 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/__MACOSX/hrmi_demos/arduino_simple/._.DS_Store differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/__MACOSX/hrmi_demos/arduino_simple/._hrmi_funcs.h b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/__MACOSX/hrmi_demos/arduino_simple/._hrmi_funcs.h new file mode 100644 index 0000000..536879d Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/__MACOSX/hrmi_demos/arduino_simple/._hrmi_funcs.h differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/.DS_Store b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/.DS_Store new file mode 100644 index 0000000..2571483 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/.DS_Store differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/arduino_simple/.DS_Store b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/arduino_simple/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/arduino_simple/.DS_Store differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/arduino_simple/arduino_simple.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/arduino_simple/arduino_simple.pde new file mode 100644 index 0000000..108c51b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/arduino_simple/arduino_simple.pde @@ -0,0 +1,95 @@ +/* + * Simple Arduino-based program to read values from the HRMI using the I2C interface + * + * Connections + * Arduino HRMI + * ----------------------- + * +5 +5 (Power for the HRMI) + * GND GND + * Analog In 5 TX (I2C SCL) (recommend 4.7 kOhm pullup) + * Analog In 4 RX (I2C SDA) (recommend 4.7 kOhm pullup) + * + * + * Note: By default the Arduino Wiring library is limited to a maximum + * I2C read of 32 bytes. The Get Heartrate command is limited + * by this code to a maximum of 30 values (for a max I2C packet + * of 32 bytes). + * + */ + +#include "Wire.h" +#include "hrmi_funcs.h" + +/* + * Configuration Information + * + * Change these constants to match your specific configuration. These + * values are the factory default (no OP1-OP7 jumpers installed). Jumper + * OP0 should be installed and jumper SJ1 removed. + * + * HRMI_HOST_BAUDRATE should be set to the baudrate the host will use + * to communicate with the Arduino over the serial interface. + * + * HRMI_I2C_ADDR should be set to the I2C address the HRMI is configured + * with. + */ +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 + + +/* + * Program constants + */ +#define MAX_IN_BUFFSIZE 16 + + +/* + * Global variables + */ +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use + + +/* + * Arduino initialization code segment + */ +void setup() +{ + // Initialize the I2C communication + hrmi_open(); + + // Initialize the serial interface + Serial.begin(HRMI_HOST_BAUDRATE); +} + + +/* + * Arduino main code loop + */ +void loop() +{ + // Request a set of heart rate values + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + + // Get the response from the HRMI + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + // send the results back on the serial interface in ASCII form + Serial.print("Request "); Serial.print(numEntries); Serial.print(" => "); + for (int i=0; i 30) + numEntries = 0; + delay(1000); // Delay 1 second between commands +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/arduino_simple/hrmi_funcs.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/arduino_simple/hrmi_funcs.cpp new file mode 100644 index 0000000..3fae9aa --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/arduino_simple/hrmi_funcs.cpp @@ -0,0 +1,60 @@ +/* + * hrmi_funcs.cpp + * + * Arduino library to communicate with a HRMI using I2C + * + * Written by Dan Julio, www.danjuliodesigns.com + * Version 1.1, 12/28/2008 + * + */ + + #include + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.send(cmd); + Wire.send(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.send(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/hrmi_simple/data/CourierNew36.vlw b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/hrmi_simple/data/CourierNew36.vlw new file mode 100644 index 0000000..9047714 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/hrmi_simple/data/CourierNew36.vlw differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/hrmi_simple/data/Ziggurat-HTF-Black-32.vlw b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/hrmi_simple/data/Ziggurat-HTF-Black-32.vlw new file mode 100644 index 0000000..84c2d4b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/hrmi_simple/data/Ziggurat-HTF-Black-32.vlw differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/hrmi_simple/hrmi_simple.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/hrmi_simple/hrmi_simple.pde new file mode 100644 index 0000000..0ab8bd1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/hrmi_simple/hrmi_simple.pde @@ -0,0 +1,72 @@ +// +// Demonstration program for communicating with the HRMI over a serial interface +// + + +// Include the serial library +import processing.serial.*; + +// Variable declaration +Serial port; // The serial port +byte[] rspCharArray = new byte[32]; // Where we'll put the raw data read from the HRMI device +int[] rspArgArray = new int[3]; // Where we'll put the converted response values +int validData = 0; +int CR = 13; // constant + +void setup() { + // Open a specific serial device (this will change for each HRMI device) + port = new Serial(this, "/dev/tty.usbserial-A9003PDh", 9600); + + // Setup the serialEvent to be called when we receive complete response + // packets from the HRMI device + port.bufferUntil(CR); + +} + +void draw() { + + // Send a command to get a single heart rate value + validData = 0; + port.write('G'); + port.write('1'); + port.write(CR); + + // Wait for a response from the HRMI device + while (validData == 0) { + delay(1000); // Delay 1 second between checks + } + + // Display mode, count and heartrate + if ((rspArgArray[0] & 0x01) == 0x01) + print("Averaged mode "); + else + print("Raw mode "); + print(rspArgArray[1]); print(" "); // Count + println(rspArgArray[2]); // Heart rate +} + +// Catch the event from the serial interface. Make sure there is +// actually data to read before attempting to do any processing. +void serialEvent(Serial port) { + if (port.readBytesUntil(CR, rspCharArray) != 0) { + // Read bytes until we get to the end of the packet converting + // each ASCII digit into a number. We make use of the space + // character between sets of digits to delimit numbers. + // Argument 0: Status Flags + // Argument 1: Second Count + // Argument 2: Heartrate + // + int ArgIndex = 0; + int CharIndex = 0; + for (int i=0; i<3; i++) rspArgArray[i] = 0; + while (rspCharArray[CharIndex] != CR) { + if (rspCharArray[CharIndex] != ((byte) ' ')) { + rspArgArray[ArgIndex] = (rspArgArray[ArgIndex]*10) + (rspCharArray[CharIndex] - ((byte) '0')); + } else { + ArgIndex++; + } + CharIndex++; + } + validData = 1; + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/unix_simple.c b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/unix_simple.c new file mode 100644 index 0000000..d6bec66 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Componentes/hrmi/hrmi_demos/unix_simple.c @@ -0,0 +1,185 @@ +/* + * Demonstration program for communicating with the HRMI over a serial interface + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +// Define a constant specifying the largest response string we could get from the HRMI +#define MAX_RSP_CHARS 140 + + +// Global to hold original serial port attributes +static struct termios gOriginalTTYAttrs; + + +// +// OpenSerialPort: Routine to open and configure the serial prot +// +static int OpenSerialPort(const char *deviceFilePath) +{ + // variables + int fd = -1; // file descriptor for serial port + struct termios options; // serial port configuration options + + // Open the serial port + if ((fd = open(deviceFilePath, O_RDWR | O_NOCTTY )) == -1) { + printf("Error opening serial port %s - %s(%d)\n", + deviceFilePath, strerror(errno), errno); + return(-1); + } + + // Prevent other processes from opening the serial port + if (ioctl(fd, TIOCEXCL) == -1) { + printf("Error setting TIOCEXCL on %s - %s(%d)\n", + deviceFilePath, strerror(errno), errno); + return(-1); + } + + // Get the serial port current options and save them to restore on exit + if (tcgetattr(fd, &gOriginalTTYAttrs) == -1) { + printf("Error getting tty attributes %s - %s(%d)\n", + deviceFilePath, strerror(errno), errno); + return(-1); + } + + // Configure the serial port + options = gOriginalTTYAttrs; + // Set raw input (non-canonical) mode, with reads blocking until either a + // single character has been received or a one second timeout expires + cfmakeraw(&options); + options.c_cc[VMIN] = 1; + options.c_cc[VTIME] = 10; + // Set the baud rate and word length + cfsetspeed(&options, B9600); + options.c_cflag |= (CS8); + // Cause the new options to take effect immediately + if (tcsetattr(fd, TCSANOW, &options) == -1) { + printf("Error setting tty attributes!\n"); + return(-1); + } + + return(fd); +} + + + +// +// CloseSerialPort: Close our connection and restore the original settings +// +void CloseSerialPort(int fd) +{ + // Block until all written output has been sent from the device + if (tcdrain(fd) == -1) { + printf("Error waiting for drain - %s(%d)\n", strerror(errno), errno); + } + + // Reset the serial port back to the state in which we found it + if (tcsetattr(fd, TCSANOW, &gOriginalTTYAttrs) == -1) { + printf("Error restoring tty attributes - %s(%d)\n", strerror(errno), errno); + } + + // Close the port + close(fd); +} + + + +// +// SendGetHeartRate: Function to send a command to get the number of heart rate values +// specified in NumEntries +// +// Returns 1 for success, 0 for failure +// +int SendGetHeartRate(int fd, int NumEntries) +{ + char SendCommand[8]; // Array sized to hold the largest command string + int CmdLength; // Number of characters in the command string + + // Validate NumEntries + if (NumEntries < 0) + NumEntries = 0; + else if (NumEntries > 32) + NumEntries = 32; + + // Build the command string + // Note: "\015" is the carriage return character + CmdLength = sprintf(SendCommand, "G%0d\015", NumEntries); + + // Send the command string + return(write(fd, SendCommand, CmdLength) == CmdLength); +} + + + +// +// GetResponseString: Function to read a response string back from the HRMI +// +int GetResponseString(int fd, char* ResponseString) +{ + char b[2]; + int i = 0; + + do { + int n = read(fd, b, 1); // read a char at a time + if (n == -1) + return(-1); // read failed + if (n == 0) { + usleep(10 * 1000); // wait 10 msec before trying again + continue; + } + + ResponseString[i] = b[0]; // store the character + i++; + + // repeat until we see the character or exceed the buffer + } while ((b[0] != 0x0D) && (i < MAX_RSP_CHARS)); + + ResponseString[i-1] = 0; // null terminate the string (replace the ) + return(0); +} + + + +int main() +{ + int sfd; // serial port file descriptor + int i = 0; // loop counter + char RspBytes[MAX_RSP_CHARS]; // Response string + int numBytes; + + // Open the serial port device associated with the HRMI + if ((sfd = OpenSerialPort("/dev/cu.usbserial-A9003PDh")) == -1) { + return(-1); + } + + // Send a series of Get Heart Rate commands, each time requesting more history buffer + // entries + while (i++ < 33) { + if (SendGetHeartRate(sfd, i) == 0) { + printf("Error: SendGetHeartRate failed!\n"); + break; + } + + if (GetResponseString(sfd, RspBytes) == -1) { + printf("Error: GetResponseString failed!\n"); + break; + } else { + printf("Request %2d => %s\n", i, RspBytes); + } + + sleep(1); + } + + CloseSerialPort(sfd); +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DemoLuzDistanciaJJ/DemoLuzDistanciaJJ.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DemoLuzDistanciaJJ/DemoLuzDistanciaJJ.pde new file mode 100644 index 0000000..6f61fb1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DemoLuzDistanciaJJ/DemoLuzDistanciaJJ.pde @@ -0,0 +1,17 @@ +void setup() { + Serial.begin(9600); +} + +void loop() { + int luz = analogRead(3); + if(luz>700) { + Serial.println("apagada"); + } + else { + Serial.println("acesa"); + } + delay(500); +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_Aranha/DevBot_Aranha.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_Aranha/DevBot_Aranha.ino new file mode 100644 index 0000000..dfbe39d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_Aranha/DevBot_Aranha.ino @@ -0,0 +1,72 @@ +#include "DevBot.h" +#include + +void setup() +{ + robot.configurar(programME_v2); + robot.configurar(bateria_7_volts); + robot.configurar(motor_6_volts); + robot.motores.independente=2; + //robot.configurar(servo_comum); + //robot.configurar(sensor_distancia_parallax); + robot.iniciar(); + + robot.modo(0, comunicacaoPC); + robot.modo(1, sensores); + robot.modo(2, medoDoEscuro); + robot.modo(3, desviar); +} + +void loop() +{ + robot.loop(); +} + +void comunicacaoPC() +{ + robot.controleRemoto(); +} +void sensores() +{ + robot.enviar("Idle - Parado"); + robot.enviar("Luz"); + robot.enviar(robot.sensorLuz()); + robot.enviar("Temperatura"); + robot.enviar(robot.sensorTemperatura()); + robot.enviar("Distancia"); + robot.enviar(robot.sensorDistancia1()); + robot.esperar(500); +} + +void teste() { + robot.mudarServo(90); + robot.enviar("Frente"); + robot.motores.frente(4); + robot.esperar(1000); + robot.motores.parar(); + robot.esperar(1000); + + robot.mudarServo(0); + robot.enviar("Girar"); + robot.motores.girar(4,0); + robot.esperar(300); + robot.motores.parar(); + robot.esperar(1000); + + robot.mudarServo(178); + robot.enviar("Re"); + robot.motores.re(4); + robot.esperar(1000); + robot.motores.parar(); + robot.esperar(1000); + + robot.enviar("Girar"); + robot.motores.girar(4,1); + robot.esperar(300); + robot.motores.parar(); + robot.esperar(5000); + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_Aranha/desviar.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_Aranha/desviar.ino new file mode 100644 index 0000000..1588585 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_Aranha/desviar.ino @@ -0,0 +1,13 @@ +int distancia; +void desviar() { + robot.mudarServo(93); + distancia = robot.sensorDistancia1(); + if(distancia<10) { + robot.motores.girar(4); + robot.esperar(500); + robot.motores.movimentoAleatorio(4); + robot.esperar(500); + } + robot.motores.frente(4); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_Aranha/medoDoEscuro.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_Aranha/medoDoEscuro.ino new file mode 100644 index 0000000..ca07d8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_Aranha/medoDoEscuro.ino @@ -0,0 +1,31 @@ +int escuridao = 800; //quanto menor o numero, maior a iluminacao do ambiente. +int luzAtual; + +boolean estaClaro() { + return luzAtual + +MeetAndroid meetAndroid; + +int modoAndroid=1; + +void android() { + meetAndroid.registerFunction(androidSensorProximidade, 'A'); + meetAndroid.registerFunction(androidAcelerometro, 'C'); + meetAndroid.registerFunction(androidBussola, 'B'); + meetAndroid.registerFunction(androidMudarModo, 'M'); + + while(!robot.mudouModo()) { + meetAndroid.receive(); + //delay(50); + } +} +void androidMudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modoAndroid = atoi(c); + //if(modoAndroid<0 || modoAndroid>5) modoAndroid=1; +} + +void androidAcelerometro(byte flag, byte numOfValues) { + float acelerometro[3]; + meetAndroid.getFloatValues(acelerometro); + if(modoAndroid==1) { + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + robot.motores.re(map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + robot.motores.frente(map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + robot.motores.parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + robot.motores.girar(map(acelerometro[0],-3,-10,1,5),0); + } + else { + robot.motores.esquerda(3); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + robot.motores.girar(map(acelerometro[0],-3,-10,1,5),1); + } + else { + robot.motores.direita(3); + } + } + } +} + + +void androidSensorProximidade(byte flag, byte numOfValues) { + int state = meetAndroid.getInt(); + if(modoAndroid!=3) return; + + if(state==0) { + for(int x=0;x<3;x++) { + robot.motores.girar(4,0); + delay(250); + robot.motores.girar(4,1); + delay(250); + robot.motores.girar(4,0); + delay(250); + robot.motores.girar(4,1); + delay(250); + + robot.motores.parar(); + } + } +} + +void androidBussola(byte flag, byte numOfValues) { + int bussola = meetAndroid.getInt(); + if(modoAndroid!=2) return; + if(bussola>350 && bussola<360) { + robot.motores.girar(3,1); + delay(80); + robot.motores.parar(); + } + else if(bussola>180 && bussola<350) { + robot.motores.girar(3,1); + delay(200); + robot.motores.parar(); + } + else if(bussola>15 && bussola<180) { + robot.motores.girar(3,0); + delay(200); + robot.motores.parar(); + } + else if(bussola>3 && bussola<15) { + robot.motores.girar(3,0); + delay(80); + robot.motores.parar(); + } + else if(bussola>0 && bussola<3) { + robot.motores.parar(); + } +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first/medoDoEscuro.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first/medoDoEscuro.ino new file mode 100644 index 0000000..b07ea72 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first/medoDoEscuro.ino @@ -0,0 +1,31 @@ +int escuridao = 700; //quanto menor o numero, maior a iluminacao do ambiente. +int luzAtual; + +boolean estaClaro() { + return luzAtual + +void setup() +{ + robot.configurar(programME_v2); + robot.configurar(bateria_7_volts); + robot.configurar(motor_6_volts); + //robot.configurar(servo_comum); + //robot.configurar(sensor_distancia_parallax); + robot.iniciar(); + + robot.modo(0, comunicacaoPC); + robot.modo(1, sensores); + robot.modo(2, medoDoEscuro); + robot.modo(3, desviar); +} + +void loop() +{ + robot.loop(); +} + +void comunicacaoPC() +{ + robot.controleRemoto(); +} +void sensores() +{ + robot.enviar("Idle - Parado"); + robot.enviar("Luz"); + robot.enviar(robot.sensorLuz()); + robot.enviar("Temperatura"); + robot.enviar(robot.sensorTemperatura()); + robot.enviar("Distancia"); + robot.enviar(robot.sensorDistancia1()); + robot.esperar(500); +} + +void teste() { + robot.mudarServo(90); + robot.enviar("Frente"); + robot.motores.frente(4); + robot.esperar(1000); + robot.motores.parar(); + robot.esperar(1000); + + robot.mudarServo(0); + robot.enviar("Girar"); + robot.motores.girar(4,0); + robot.esperar(300); + robot.motores.parar(); + robot.esperar(1000); + + robot.mudarServo(178); + robot.enviar("Re"); + robot.motores.re(4); + robot.esperar(1000); + robot.motores.parar(); + robot.esperar(1000); + + robot.enviar("Girar"); + robot.motores.girar(4,1); + robot.esperar(300); + robot.motores.parar(); + robot.esperar(5000); + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first_Servo/desviar.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first_Servo/desviar.ino new file mode 100644 index 0000000..504f813 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first_Servo/desviar.ino @@ -0,0 +1,13 @@ +int distancia; +void desviar() { + robot.mudarServo(90); + distancia = robot.sensorDistancia1(); + if(distancia<10) + robot.motores.girar(4); + robot.esperar(500); + robot.motores.movimentoAleatorio(4); + robot.esperar(500); + } + robot.motores.andar(4); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first_Servo/medoDoEscuro.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first_Servo/medoDoEscuro.ino new file mode 100644 index 0000000..ca07d8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first_Servo/medoDoEscuro.ino @@ -0,0 +1,31 @@ +int escuridao = 800; //quanto menor o numero, maior a iluminacao do ambiente. +int luzAtual; + +boolean estaClaro() { + return luzAtual + +void setup() +{ + robot.configurar(bateria_7_volts); + robot.configurar(motor_6_volts); + robot.configurar(programME_v2); + robot.configurar(sensor_distancia_parallax); + robot.iniciar(); + robot.modo(0, comunicacaoPC); + robot.modo(1, sensores); + robot.modo(2, medoDoEscuro); + robot.modo(3, desviar); +} + +void loop() +{ + robot.loop(); +} + +void comunicacaoPC() +{ + robot.controleRemoto(); +} +void sensores() +{ + robot.enviar("Idle - Parado"); + robot.enviar("Luz"); + robot.enviar(robot.sensorLuz()); + robot.enviar("Temperatura"); + robot.enviar(robot.sensorTemperatura()); + robot.enviar("Distancia"); + robot.enviar(robot.sensorDistancia1()); + robot.esperar(500); +} + +void teste() { + robot.mudarServo(90); + robot.enviar("Frente"); + robot.motores.frente(4); + robot.esperar(1000); + robot.motores.parar(); + robot.esperar(1000); + + robot.mudarServo(0); + robot.enviar("Girar"); + robot.motores.girar(4,0); + robot.esperar(300); + robot.motores.parar(); + robot.esperar(1000); + + robot.mudarServo(178); + robot.enviar("Re"); + robot.motores.re(4); + robot.esperar(1000); + robot.motores.parar(); + robot.esperar(1000); + + robot.enviar("Girar"); + robot.motores.girar(4,1); + robot.esperar(300); + robot.motores.parar(); + robot.esperar(5000); + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first_sonar/desviar.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first_sonar/desviar.ino new file mode 100644 index 0000000..ff3b8ba --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first_sonar/desviar.ino @@ -0,0 +1,16 @@ +int distancia; +void desviar() { + distancia = robot.sensorDistancia1(); + //esta claro + /*while(estaClaro()) { + robot.motores.frente(4); + robot.esperar(100); + if(robot.mudouModo()) return; //metodo de libertacao do while se o robo mudar de modo + luzAtual = robot.sensorLuz(); + }*/ + robot.motores.girar(4); + robot.esperar(500); + robot.motores.movimentoAleatorio(4); + robot.esperar(500); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first_sonar/medoDoEscuro.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first_sonar/medoDoEscuro.ino new file mode 100644 index 0000000..ca07d8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/DevBot_first_sonar/medoDoEscuro.ino @@ -0,0 +1,31 @@ +int escuridao = 800; //quanto menor o numero, maior a iluminacao do ambiente. +int luzAtual; + +boolean estaClaro() { + return luzAtual-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarTraz(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarFrente(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + +} + + + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=ANDAR) return; + + if(comando[0]=='F') { + //dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + //dance(); + } +} + +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=DEDO_DURO) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + //testeLeds(); + } + } +} + +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=ENCONTRAR_NORTE) return; + //if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + //else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/Devbot_Android_teste/Devbot_Android_teste.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/Devbot_Android_teste/Devbot_Android_teste.ino new file mode 100644 index 0000000..e38d3ef --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/Devbot_Android_teste/Devbot_Android_teste.ino @@ -0,0 +1,74 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +boolean DEBUG_LIGADO = false; + +int modo=1; +boolean calibrado = false; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; + +Servo servoV; +Servo servoH; + +#define IDLE 0 +#define DEDO_DURO 1 +#define ENCONTRAR_NORTE 2 +#define ANDAR 3 +#define ACELEROMETRO 4 +#define SEGUIR_LINHA 5 + +void setup(){ + setupMotor(); + delay(500); + Serial.begin(115200); + //meetAndroid.setSerial(&Serial); + meetAndroid.registerFunction(dedoDuro, 'A'); + meetAndroid.registerFunction(encontraNorte, 'B'); + meetAndroid.registerFunction(acelera, 'C'); + meetAndroid.registerFunction(mudarModo, 'M'); + meetAndroid.registerFunction(andar, 'W'); + modo=IDLE; +} + +void loop(){ + meetAndroid.receive(); + delay(50); + //if(modo==SEGUIR_LINHA) seguirLinha2(); + if(modo==IDLE) modoZero(); + +} +int direita; +int centro; +int esquerda; + + + + +void modoZero() { + digitalWrite(13, HIGH); + delay(1000); + digitalWrite(13, LOW); + delay(1000); +} + +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + calibrado = false; //para recalibrar quando ligar seguidor de linha novamente +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/Devbot_Android_teste/Motores.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/Devbot_Android_teste/Motores.ino new file mode 100644 index 0000000..30330d3 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/DevBot/Devbot_Android_teste/Motores.ino @@ -0,0 +1,95 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + + +int sentido=0; +void setupMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Dimmer_JL_Final.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Dimmer_JL_Final.pde new file mode 100644 index 0000000..5075b90 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Dimmer_JL_Final.pde @@ -0,0 +1,129 @@ +#include +#include +//define portas associadas ao display 7seg +//int displaySeg[] = {a, b, c, d, e, f, g, pd}; +int displaySeg[] = {6, 9, 17, 15, 14, 5, 18, 12}; +//int displayPorts[] = {Anodo1, Anodo2, Anodo3}; +int displayPort[] = {7, 4, 3}; + +// define padroes do display 7SEG, de 0 - 9 e apagado +// 1 = segmento apagado, 0 = segmento aceso +byte seven_seg_digits[11][8] = { + { 0,0,0,0,0,0,1,1 }, // = 0 + { 1,0,0,1,1,1,1,1 }, // = 1 + { 0,0,1,0,0,1,0,1 }, // = 2 + { 0,0,0,0,1,1,0,1 }, // = 3 + { 1,0,0,1,1,0,0,1 }, // = 4 + { 0,1,0,0,1,0,0,1 }, // = 5 + { 0,1,0,0,0,0,0,1 }, // = 6 + { 0,0,0,1,1,1,1,1 }, // = 7 + { 0,0,0,0,0,0,0,1 }, // = 8 + { 0,0,0,1,1,0,0,1 }, // = 9 + { 1,1,1,1,1,1,1,1 } // = blank +}; + +int sensorDistancia = 2; // porta associada ao sensor distancia IR +int triacGatePin = 10 ; // porta associada ao gate do TRIAC + +int distancia = 0 ; // variavel para armazenar distancia +int power= 0 ; //inicializa variavel que controla potencia na lampada com 0 (lampada apagada) +int centena = 10 ; // armazena informacao a ser apresentada no display de centena (inicializa com 10 = apagado) +int dezena = 10 ; // armazena informacao a ser apresentada no display de dezena (inicializa com 10 = apagado) +int unidade = 10 ; // armazena informacao a ser apresentada no display de unidade (inicializa com 10 = apagado) + +void setup() { + Serial.begin(19200); + pinMode(triacGatePin, OUTPUT); + for (int i=0 ; i<=3 ; i++) { + pinMode(displayPort[i], OUTPUT); + } + for (int j=0 ; j<=7 ; j++) { + pinMode(displaySeg[j], OUTPUT); + } + attachInterrupt(0, zeroCrossInterrupt, CHANGE); //associa interrupcao INT0 com funcao "zeroCrossInterrupt" + + MsTimer2::set(200, leSensor); // inicializa Timer2 com 200 milisegundos (tempo entre leituras do sensor de dintancia) + MsTimer2::start(); // start do timer2 +} + +void loop() { + atualizaDisplay(unidade, dezena, centena); // atualiza informacoes nos displays de 7 segmentos +//* + //verifica se veio comando remoto pela serial + if (Serial.available() > 0) { + power = Serial.read(); + Serial.print(power, BYTE); + } + //finaliza aqui a verificacao de dados na serial + +} + +void atualizaDisplay(int uni, int dez, int cen) { + for (int k = 0; k < 8; ++k) { + digitalWrite(displaySeg[k], seven_seg_digits[uni][k]); + } + digitalWrite(displayPort[2], HIGH); + delay (1); + digitalWrite(displayPort[2], LOW); + + for (int k = 0; k < 8; ++k) { + digitalWrite(displaySeg[k], seven_seg_digits[dez][k]); + } + digitalWrite(displayPort[1], HIGH); + delay (1); + digitalWrite(displayPort[1], LOW); + + for (int k = 0; k < 8; ++k) { + digitalWrite(displaySeg[k], seven_seg_digits[cen][k]); + } + digitalWrite(displayPort[0], HIGH); + delay (1); + digitalWrite(displayPort[0], LOW); + +} + +void zeroCrossInterrupt(){ // trata interrupcao INT0 + if(power > 0) { + long dimtime = int(map(power,0,100,8000,150)); // calcula o tempo de delay para o disparo do TRIAC + Timer1.initialize (dimtime); // inicializa o TIMER1 com o delay calculado + Timer1.attachInterrupt(gateTRIAC); //associa a funcao gateTRIAC com Interrupcao do TIMER1 + Timer1.start(); // inicia contagem TIMER1 + } else { + digitalWrite(triacGatePin, LOW); // mantem gate do TRIAC desativado. + Timer1.stop(); + } +} + +void gateTRIAC () { // trata interrupcao do TIMER1 gerando pulso no gate do TRIAC + digitalWrite(triacGatePin, HIGH); // dispara o Triac + delayMicroseconds(15); // aguarda 15 microsegundos para garantir disparo do TRIAC + digitalWrite(triacGatePin, LOW); // desabibilta gate do TRIAC + Timer1.stop(); +} + +void leSensor() { + distancia = analogRead(sensorDistancia); // le sensor de distancia + //Serial.println(distancia); + distancia = map(distancia,70,600,120,0); // mapeia distancia lida para uma faixa de potencia entre 0 e 120 + if (distancia < 0) { + distancia = 0; + } + + if (distancia >=0 && distancia <= 100) { // se distancia <= a 100 atualiza potencia + power=distancia; + } + + + + centena = int(power / 100); // atualiza variaveis que contem informacoes dos displays + dezena = int((power - (centena*100)) / 10); + unidade = int(power - (centena*100)-(dezena*10)); + if (centena == 0 && dezena == 0){ + centena = 10; + dezena = 10; + } + if (centena == 0){ + centena = 10; + } +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Dimmer_JL_Final/Dimmer_JL_Final.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Dimmer_JL_Final/Dimmer_JL_Final.pde new file mode 100644 index 0000000..5075b90 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Dimmer_JL_Final/Dimmer_JL_Final.pde @@ -0,0 +1,129 @@ +#include +#include +//define portas associadas ao display 7seg +//int displaySeg[] = {a, b, c, d, e, f, g, pd}; +int displaySeg[] = {6, 9, 17, 15, 14, 5, 18, 12}; +//int displayPorts[] = {Anodo1, Anodo2, Anodo3}; +int displayPort[] = {7, 4, 3}; + +// define padroes do display 7SEG, de 0 - 9 e apagado +// 1 = segmento apagado, 0 = segmento aceso +byte seven_seg_digits[11][8] = { + { 0,0,0,0,0,0,1,1 }, // = 0 + { 1,0,0,1,1,1,1,1 }, // = 1 + { 0,0,1,0,0,1,0,1 }, // = 2 + { 0,0,0,0,1,1,0,1 }, // = 3 + { 1,0,0,1,1,0,0,1 }, // = 4 + { 0,1,0,0,1,0,0,1 }, // = 5 + { 0,1,0,0,0,0,0,1 }, // = 6 + { 0,0,0,1,1,1,1,1 }, // = 7 + { 0,0,0,0,0,0,0,1 }, // = 8 + { 0,0,0,1,1,0,0,1 }, // = 9 + { 1,1,1,1,1,1,1,1 } // = blank +}; + +int sensorDistancia = 2; // porta associada ao sensor distancia IR +int triacGatePin = 10 ; // porta associada ao gate do TRIAC + +int distancia = 0 ; // variavel para armazenar distancia +int power= 0 ; //inicializa variavel que controla potencia na lampada com 0 (lampada apagada) +int centena = 10 ; // armazena informacao a ser apresentada no display de centena (inicializa com 10 = apagado) +int dezena = 10 ; // armazena informacao a ser apresentada no display de dezena (inicializa com 10 = apagado) +int unidade = 10 ; // armazena informacao a ser apresentada no display de unidade (inicializa com 10 = apagado) + +void setup() { + Serial.begin(19200); + pinMode(triacGatePin, OUTPUT); + for (int i=0 ; i<=3 ; i++) { + pinMode(displayPort[i], OUTPUT); + } + for (int j=0 ; j<=7 ; j++) { + pinMode(displaySeg[j], OUTPUT); + } + attachInterrupt(0, zeroCrossInterrupt, CHANGE); //associa interrupcao INT0 com funcao "zeroCrossInterrupt" + + MsTimer2::set(200, leSensor); // inicializa Timer2 com 200 milisegundos (tempo entre leituras do sensor de dintancia) + MsTimer2::start(); // start do timer2 +} + +void loop() { + atualizaDisplay(unidade, dezena, centena); // atualiza informacoes nos displays de 7 segmentos +//* + //verifica se veio comando remoto pela serial + if (Serial.available() > 0) { + power = Serial.read(); + Serial.print(power, BYTE); + } + //finaliza aqui a verificacao de dados na serial + +} + +void atualizaDisplay(int uni, int dez, int cen) { + for (int k = 0; k < 8; ++k) { + digitalWrite(displaySeg[k], seven_seg_digits[uni][k]); + } + digitalWrite(displayPort[2], HIGH); + delay (1); + digitalWrite(displayPort[2], LOW); + + for (int k = 0; k < 8; ++k) { + digitalWrite(displaySeg[k], seven_seg_digits[dez][k]); + } + digitalWrite(displayPort[1], HIGH); + delay (1); + digitalWrite(displayPort[1], LOW); + + for (int k = 0; k < 8; ++k) { + digitalWrite(displaySeg[k], seven_seg_digits[cen][k]); + } + digitalWrite(displayPort[0], HIGH); + delay (1); + digitalWrite(displayPort[0], LOW); + +} + +void zeroCrossInterrupt(){ // trata interrupcao INT0 + if(power > 0) { + long dimtime = int(map(power,0,100,8000,150)); // calcula o tempo de delay para o disparo do TRIAC + Timer1.initialize (dimtime); // inicializa o TIMER1 com o delay calculado + Timer1.attachInterrupt(gateTRIAC); //associa a funcao gateTRIAC com Interrupcao do TIMER1 + Timer1.start(); // inicia contagem TIMER1 + } else { + digitalWrite(triacGatePin, LOW); // mantem gate do TRIAC desativado. + Timer1.stop(); + } +} + +void gateTRIAC () { // trata interrupcao do TIMER1 gerando pulso no gate do TRIAC + digitalWrite(triacGatePin, HIGH); // dispara o Triac + delayMicroseconds(15); // aguarda 15 microsegundos para garantir disparo do TRIAC + digitalWrite(triacGatePin, LOW); // desabibilta gate do TRIAC + Timer1.stop(); +} + +void leSensor() { + distancia = analogRead(sensorDistancia); // le sensor de distancia + //Serial.println(distancia); + distancia = map(distancia,70,600,120,0); // mapeia distancia lida para uma faixa de potencia entre 0 e 120 + if (distancia < 0) { + distancia = 0; + } + + if (distancia >=0 && distancia <= 100) { // se distancia <= a 100 atualiza potencia + power=distancia; + } + + + + centena = int(power / 100); // atualiza variaveis que contem informacoes dos displays + dezena = int((power - (centena*100)) / 10); + unidade = int(power - (centena*100)-(dezena*10)); + if (centena == 0 && dezena == 0){ + centena = 10; + dezena = 10; + } + if (centena == 0){ + centena = 10; + } +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Diversos/dojo_go/dojo_go.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Diversos/dojo_go/dojo_go.pde new file mode 100644 index 0000000..601d300 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Diversos/dojo_go/dojo_go.pde @@ -0,0 +1,134 @@ +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define DISTANCIA 1 +int sentido; +/* + + Duplas: + - Reinaldo e Fernando + - Marcelo e Bruno + - Fred e Natany + - Felipe e Andressa + - Fernando e Tiago +*/ + +int girar = 0; +int andar = 0; // ciclos andando pra frente +int ultimoGirar = 0; + +void setup() { + Serial.begin(9600); + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + servo +} +int lerDistancia() { + return analogRead(DISTANCIA); + //define preferencia direita +} +void loop() { + //vai para frente ate distancia 40 + if(lerDistancia()>30){ + andarFrente(1000,2); + } else{ + if(ultimoGirar == 0){ + while(lerDistancia()<30){ + girarNoEixo(100,2,1); + } + ultimoGirar = 1; + } else{ + while(lerDistancia()<30){ + girarNoEixo(100,2,0); + } + ultimoGirar = 0; + } + } + +} + + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarTraz(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarFrente(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Diversos/dojo_ms/dojo_ms.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Diversos/dojo_ms/dojo_ms.pde new file mode 100644 index 0000000..e366757 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Diversos/dojo_ms/dojo_ms.pde @@ -0,0 +1,87 @@ +#define MOTOR1_P 12 +#define MOTOR1_N 11 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 6 + +#define FRENTE 1 +#define RE 0 +#define LUZRGB 9 +#define DIREITA 1 +#define ESQUERDA 0 + +void setup() { + pinMode(MOTOR1_P,OUTPUT); + pinMode(MOTOR2_P,OUTPUT); + pinMode(MOTOR1_N,OUTPUT); + pinMode(MOTOR2_N,OUTPUT); +} + +void girar(int intensidade,int direcao) +{ + if(direcao==DIREITA) { + + + digitalWrite(MOTOR1_P,FRENTE); + digitalWrite(MOTOR1_N,!FRENTE); + digitalWrite(MOTOR2_P,RE); + digitalWrite(MOTOR2_N,!RE); + analogWrite(MOTOR1_PWM, intensidade * 50); + analogWrite(MOTOR2_PWM, intensidade * 50); + delay(1000); + + } + else if(direcao==ESQUERDA) +{ + + + digitalWrite(MOTOR1_P,RE); + digitalWrite(MOTOR1_N,!RE); + digitalWrite(MOTOR2_P,FRENTE); + digitalWrite(MOTOR2_N,!FRENTE); + analogWrite(MOTOR1_PWM, intensidade * 50); + analogWrite(MOTOR2_PWM, intensidade * 50); + delay(1000); + + } +} + +void piscar(int vezes) { + for(int x=0;x +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define DISTANCIA 1 + +int sentido; +Servo servoV; +Servo servoH; +int contador=0; +long distancia; +long distanciaEsquerda; +long distanciaDireita; + +void setup() { + servoH.attach(11); + servoV.attach(10); + Serial.begin(9600); +} + +int lerPingComMedia() { + int d1,d2,d3; + d1 = analogRead(1); + delay(5); + d2 = analogRead(1); + delay(5); + d3 = analogRead(1); + delay(5); + return (d1 + d2 + d3)/3; +} + +void lerPing() { + distancia = lerPingComMedia(); +} +void lerPingFull() { + servoH.write(30); + delay(200); + distanciaEsquerda = lerPingComMedia(); + servoH.write(100); + delay(200); + distancia = lerPingComMedia(); + servoH.write(150); + delay(200); + distanciaDireita = lerPingComMedia(); + servoH.write(85); +} + +void loop() { + lerPing(); + if(random(0,1)) { + } + else { + } + while(distancia<20) { + andarTraz(200,5); + parar(); + lerPing(); + } + while(distancia>20) { + andarFrente(200,5); + lerPing(); + } + +} + + + + + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarTraz(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarFrente(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Diversos/dojo_sjrp/dojo_sjrp.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Diversos/dojo_sjrp/dojo_sjrp.pde new file mode 100644 index 0000000..485072a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Diversos/dojo_sjrp/dojo_sjrp.pde @@ -0,0 +1,111 @@ +#include +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define DISTANCIA 1 + +int sentido; +Servo servoV; +Servo servoH; +int contador=0; +int direcaoServo=0; + +void setup() { + servoH.attach(11); + servoV.attach(10); + Serial.begin(9600); + servoH.write(1); + delay(1500); + servoH.write(180); + delay(1500); + servoH.write(90); + delay(1500); + +} +void loop() { + Serial.println(analogRead(1)); + delay(10); +} + + + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarTraz(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarFrente(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Diversos/dojo_solucao/dojo_solucao.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Diversos/dojo_solucao/dojo_solucao.pde new file mode 100644 index 0000000..e22e090 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Diversos/dojo_solucao/dojo_solucao.pde @@ -0,0 +1,160 @@ +#include +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define DISTANCIA 1 + +int sentido; +Servo servoV; +Servo servoH; +int contador=0; +long distancia; +long distanciaEsquerda; +long distanciaDireita; + +void setup() { + servoH.attach(11); + servoV.attach(10); + Serial.begin(9600); +} + +int lerPingComMedia() { + int d1,d2,d3; + d1 = analogRead(1); + delay(5); + d2 = analogRead(1); + delay(5); + d3 = analogRead(1); + delay(5); + return (d1 + d2 + d3)/3; +} + +void lerPing() { + distancia = lerPingComMedia(); +} +void lerPingFull() { + servoH.write(30); + delay(200); + distanciaEsquerda = lerPingComMedia(); + servoH.write(100); + delay(200); + distancia = lerPingComMedia(); + servoH.write(150); + delay(200); + distanciaDireita = lerPingComMedia(); + servoH.write(85); +} + +void loop() { + lerPing(); + + while(distancia>25) { + andarFrente(200,3); + lerPing(); + } + while(distancia>15 && distancia<25) { + parar(); + delay(200); + lerPingFull(); + if(distanciaEsquerda>distancia && distanciaEsquerda>distanciaDireita) { + girarNoEixo(300,2,1); + } + if(distanciaDireita>distancia && distanciaDireita>distanciaEsquerda) { + girarNoEixo(300,2,0); + } + lerPing(); + } + while(distancia>5 && distancia<15) { + parar(); + andarTraz(500,2); + girarNoEixo(500,2, random(10)%2==0); + lerPing(); + } + +} + + + + + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarTraz(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarFrente(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ElectronKernel_Sample1/ElectronKernel_Sample1.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ElectronKernel_Sample1/ElectronKernel_Sample1.ino new file mode 100644 index 0000000..53a0123 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ElectronKernel_Sample1/ElectronKernel_Sample1.ino @@ -0,0 +1,47 @@ +#include "ElectronKernel.h" + +#include +Servo servo; + +void setup() +{ + Serial.begin(9600); + setupMotor(); + //servo.attach(5); + Kernel.setup(INTERRUPTION); + Kernel.registerMode("idle"); + Kernel.registerTask(idle); + Kernel.registerMode("test"); + Kernel.registerTask(test); + Kernel.registerMode("avoidance"); + Kernel.registerTask(avoidance); +} + +void loop() +{ + + Kernel.loop(); +} + +void idle() { + //Serial.println("blink mode"); + Kernel.wait(300); + +} + +void test() { + /*for(int x=20;x<255;x++) { + andarFrente(2000,x); + Serial.println(x); + }*/ + for(int x=0;x<6;x++) { + andarFrente(2000,x); + Serial.println(x); + } +} + +void avoidance() { Serial.println("play music mode"); +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ElectronKernel_Sample1/Motores.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ElectronKernel_Sample1/Motores.ino new file mode 100644 index 0000000..dcb64d2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ElectronKernel_Sample1/Motores.ino @@ -0,0 +1,97 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + +int sentido=0; + + + +void setupMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTras(int tempo,int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Display/GPS_Display.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Display/GPS_Display.pde new file mode 100644 index 0000000..2f7bf4d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Display/GPS_Display.pde @@ -0,0 +1,56 @@ +#include +#include +//amarelo = 2 - azul = 3 +SoftwareSerial GPS = SoftwareSerial(2, 3); +LiquidCrystal lcd(4, 9, 17, 16, 15, 14); +char linea[32] = ""; +int byteGPS = -1; +int conta = 0; + +void setup() { + Serial.begin(9600); + GPS.begin(4800); + initLCD(); + +} +void resetLinha() { + + for (int i=0;i<300;i++) + { + linea[i]=' '; + } +} + +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Master I2C On"); + lcd.setCursor(0, 1); + lcd.print("Waiting command."); +} + +void loop(){ + byteGPS = GPS.read(); + if (byteGPS == -1) + { + delay(100); + } + else { + linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer + conta++; + if (byteGPS==13 || conta==32) { + lcd.clear(); + lcd.setCursor(0,0); + lcd.print(linea); + Serial.println(linea); + resetLinha(); + conta=0; + } + } +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Mega/GPS_Mega.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Mega/GPS_Mega.pde new file mode 100644 index 0000000..934d154 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Mega/GPS_Mega.pde @@ -0,0 +1,312 @@ +#include + +#define MODE_GPS_LATLONG 0 +#define MODE_GPS_SPEED 1 +#define MODE_GPS_HEADING 2 +#define MODE_AUTOPILOT_COMPASS 3 +#define MODE_AUTOPILOT_ACELEROMETOR 4 +#define MODE_DEBUG 5 + +#define MOTOR_A 12 +#define MOTOR_B 13 +#define MOTOR_PWM 11 + +String modes[] = { + "Lat. Longe.", "Speedy", "Heading", "Auto Compass", "Auto Aceler.", "Debug" }; + +LiquidCrystal lcd(4, 9, 57, 56, 55, 54); +char linea[300] = ""; + +int contaplot=0; +int byteGPS=-1; +//char linha[300]; +char comandoGPR[7] = "$GPRMC"; +int indices[13]; +int cont=0; +int bien=0; +int conta=0; +char latitude[17]; +char longitude[17]; +char velocidade[17]; +char heading[17]; +int cvelocidade=0, clatitude=0, clongitude=0, cheading=0; +volatile int targetHeading; +volatile int mode; + +long lastDebounce=0; +long debounceDelay=50; +long lcdDelay=1500; +long lcdNextUpdate=0; +long lcdLastUpdate=0; + +String lcdLine1; +String lcdLine2; + +void setup() +{ + //LoL + Serial.begin(9600); + Serial2.begin(115200); + Serial1.begin(4800); + attachInterrupt(3, buttonPressed, LOW); //PORTA 18, quando estiver subindo + attachInterrupt(2, changeMode, LOW); //PORTA 18, quando estiver subindo + initLCD(); + // resetLinha(); + //resetDados(); +} + +void setupMotor() { + pinMode(MOTOR_A, OUTPUT); + pinMode(MOTOR_B, OUTPUT); +} + +void loop() +{ + if(mode>=0 && mode<=2) savelocation(); + if(mode==3 || mode==4) android(); + if(mode==MODE_DEBUG) debug(); + lcdRestore(); +} + +void changeMode() { + if(millis()-lastDebounce>debounceDelay) { + mode = mode== 5 ? 0 : mode + 1; + lastDebounce=millis(); + resetMode(); + lcdPrint("Mode", modes[mode], 2000); + + } + +} + +void buttonPressed() { + if(millis()-lastDebounce>debounceDelay) { + targetHeading = targetHeading==360 ? 1 : targetHeading + 1; + lastDebounce=millis(); + lcdPrint("Target Heading", targetHeading, 2000); + + } +} + +void android() { + + if(Serial2.available()>0) + { + char l = Serial2.read(); + // byteGPS=Serial2.read(); // Read a byte of the serial port + + linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer + conta++; + if (byteGPS==13) + { // If the received byte is = to 13, end of transmission + Serial.print(linea); + conta=0; + } + } + /*else { + lcdPrint("Android BT", "No data!", 0); + }*/ + +} + + +void savelocation () +{ + if(Serial1.available()>0) { + + byteGPS=Serial1.read(); // Read a byte of the serial port + linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer + conta++; + if (byteGPS==13) + { // If the received byte is = to 13, end of transmission + Serial.print(linea); + cont=0; + bien=0; + for (int i=1;i<7;i++) + { // Verifies if the received command starts with $GPR + if (linea[i]==comandoGPR[i-1]) + { + bien++; + } + } + if(bien==6) + { // If yes, continue and process the data + for (int i=0;i<300;i++) + { + if (linea[i]==','){ // check for the position of the "," separator + indices[cont]=i; + cont++; + } + if (linea[i]=='*') + { // ... and the "*" + indices[12]=i; + cont++; + } + } + Serial2.println(linea); + Serial.println(""); // ... and write to the serial port + Serial.println(""); + Serial.println("---------------"); + resetDados(); + for (int i=0;i<12;i++) + { + switch(i){ + case 0 : + Serial.print("Time in UTC (HhMmSs): "); + break; + case 1 : + Serial.print("Status (A=OK,V=KO): "); + break; + case 2 : + Serial.print("Latitude: "); + break; + case 3 : + Serial.print("Direction (N/S): "); + break; + case 4 : + Serial.print("Longitude: "); + break; + case 5 : + Serial.print("Direction (E/W): "); + break; + case 6 : + Serial.print("Velocity in knots: "); + break; + case 7 : + Serial.print("Heading in degrees: "); + break; + case 8 : + Serial.print("Date UTC (DdMmAa): "); + break; + case 9 : + Serial.print("Magnetic degrees: "); + break; + case 10 : + Serial.print("(E/W): "); + break; + case 11 : + Serial.print("Mode: "); + break; + case 12 : + Serial.print("Checksum: "); + break; + } + for (int j=indices[i];j<(indices[i+1]-1);j++) + { + Serial.print(linea[j+1]); + if(i==2) { + latitude[clatitude++]=linea[j+1]; + } + else if(i==3) { + latitude[clatitude++]=linea[j+1]; + } + else if(i==4) { + longitude[clongitude++]=linea[j+1]; + } + else if(i==5) { + longitude[clongitude++]=linea[j+1]; + } + else if(i==6) { + velocidade[cvelocidade++]=linea[j+1]; + } + else if(i==7) { + heading[cheading++]=linea[j+1]; + } + } + Serial.println(""); + if(mode==MODE_GPS_LATLONG) lcdPrint(latitude, longitude,0); + else if(mode==MODE_GPS_SPEED) lcdPrint("Speed", velocidade, 0); + else if(mode==MODE_GPS_HEADING) lcdPrint("Heading", heading, 0); + } + } + cvelocidade=0; + clatitude=0; + clongitude=0; + cheading=0; + conta=0; // Reset the buffer + for (int i=0;i<300;i++) + { + linea[i]=' '; + } + } + } +} + +void resetDados() { + for( int i=0;i<16;i++) { + latitude[i]=' '; + longitude[i]=' '; + velocidade[i]=' '; + heading[i]=' '; + } +} + +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcdPrint("Eletron Livre", "Tiziu", 0); + delay(2000); +} + + +void lcdPrint(String line1, String line2, long time) { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print(line1); + lcd.setCursor(0, 1); + lcd.print(line2); + if(time > 0) { //user want to keep last lines... + lcdNextUpdate = millis() + time; + } + else { + + lcdLine1=line1; + lcdLine2=line2; + lcdNextUpdate = 0; + } + lcdLastUpdate=millis(); + +} + + +void lcdRestore() { + if(lcdNextUpdate!=0 && lcdNextUpdate<=millis()){ + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print(lcdLine1); + lcd.setCursor(0, 1); + lcd.print(lcdLine2); + lcdNextUpdate=0; + } +} + +void debug() { + lcdPrint("Debug", "Avanca", 0); + + digitalWrite(MOTOR_A, 0); + digitalWrite(MOTOR_B, 1); + analogWrite(MOTOR_PWM, 250); + delay(1500); + if(mode!=MODE_DEBUG) return; + + lcdPrint("Debug", "Para", 0); + analogWrite(MOTOR_PWM, 0); + delay(1500); + if(mode!=MODE_DEBUG) return; + + lcdPrint("Debug", "Retro", 0); + digitalWrite(MOTOR_A, 1); + digitalWrite(MOTOR_B, 0); + analogWrite(MOTOR_PWM, 250); + delay(1500); + if(mode!=MODE_DEBUG) return; + + lcdPrint("Debug", "Para", 0); + analogWrite(MOTOR_PWM, 0); + delay(1500); + +} + +void resetMode() { + analogWrite(MOTOR_PWM,0); +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Sample_Web/GPS_Sample_Web.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Sample_Web/GPS_Sample_Web.pde new file mode 100644 index 0000000..2380a2a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Sample_Web/GPS_Sample_Web.pde @@ -0,0 +1,131 @@ +#include +#include +#include + +int ledPin=13; +int byteGPS=-1; +char linea[300] = ""; +char comandoGPR[7] = "$GPRMC"; +int cont=0; +int bien=0; +int conta=0; +int indices[13]; + +SoftwareSerial GPS = SoftwareSerial(2, 3); + +void setup() +{ + pinMode(ledPin, OUTPUT); // Initialize LED pin + Serial.begin(9600); + GPS.begin(4800); + for (int i=0;i<300;i++) + { // Initialize a buffer for received data + linea[i]=' '; + } +} + +void loop() +{ + savelocation (); +} + +void savelocation () +{ +digitalWrite(ledPin, HIGH); + byteGPS=GPS.read(); // Read a byte of the serial port + if (byteGPS == -1) + { // See if the port is empty yet + delay(100); + } + else { + linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer + conta++; + if (byteGPS==13) + { // If the received byte is = to 13, end of transmission + digitalWrite(ledPin, LOW); + cont=0; + bien=0; + for (int i=1;i<7;i++) + { // Verifies if the received command starts with $GPR + if (linea[i]==comandoGPR[i-1]) + { + bien++; + } + } + if(bien==6) + { // If yes, continue and process the data + for (int i=0;i<300;i++) + { + if (linea[i]==','){ // check for the position of the "," separator + indices[cont]=i; + cont++; + } + if (linea[i]=='*') + { // ... and the "*" + indices[12]=i; + cont++; + } + } + Serial.println(""); // ... and write to the serial port + Serial.println(""); + Serial.println("---------------"); + for (int i=0;i<12;i++) + { + switch(i){ + case 0 : + Serial.print("Time in UTC (HhMmSs): "); + break; + case 1 : + Serial.print("Status (A=OK,V=KO): "); + break; + case 2 : + Serial.print("Latitude: "); + break; + case 3 : + Serial.print("Direction (N/S): "); + break; + case 4 : + Serial.print("Longitude: "); + break; + case 5 : + Serial.print("Direction (E/W): "); + break; + case 6 : + Serial.print("Velocity in knots: "); + break; + case 7 : + Serial.print("Heading in degrees: "); + break; + case 8 : + Serial.print("Date UTC (DdMmAa): "); + break; + case 9 : + Serial.print("Magnetic degrees: "); + break; + case 10 : + Serial.print("(E/W): "); + break; + case 11 : + Serial.print("Mode: "); + break; + case 12 : + Serial.print("Checksum: "); + break; + } + for (int j=indices[i];j<(indices[i+1]-1);j++) + { + Serial.print(linea[j+1]); + } + Serial.println(""); + } + } + conta=0; // Reset the buffer + for (int i=0;i<300;i++) + { + linea[i]=' '; + } + } + } +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Simples/GPS_Simples.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Simples/GPS_Simples.pde new file mode 100644 index 0000000..1d39542 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Simples/GPS_Simples.pde @@ -0,0 +1,41 @@ +#include +#include + +SoftwareSerial GPS = SoftwareSerial(2, 3); +LiquidCrystal lcd(4, 9, 17, 16, 15, 14); + +byte GPSByte; + +void setup() +{ + GPS.begin(4800); + Serial.begin(9600); + //initLCD(); +} +int x=0,y=0; +void loop() +{ + // Get the GPS data + GPSByte = GPS.read(); + // Print GPS data + lcd.setCursor(x,y); + lcd.print(GPSByte); + x++; + if(x==16 && y==0) { + x=0; y=1; + } + else if(x==16 && y==1) { + x=0; y=0; + } + Serial.print(GPSByte); +} + +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Master I2C On"); + lcd.setCursor(0, 1); + lcd.print("Waiting command."); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Simples_OK/GPS_Simples_OK.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Simples_OK/GPS_Simples_OK.pde new file mode 100644 index 0000000..e9628c1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GPS/GPS_Simples_OK/GPS_Simples_OK.pde @@ -0,0 +1,47 @@ +#include + +//LiquidCrystal lcd(4, 9, 17, 16, 15, 14); +LiquidCrystal lcd(4, 9, 57, 56, 55, 54); + + +void setup() +{ + Serial1.begin(4800); + Serial.begin(9600); + initLCD(); +} + + +int x=0,y=0; +byte GPSByte; + +void loop() +{ + while(Serial1.available()>0) { + GPSByte = Serial1.read(); + Serial.print(GPSByte); + lcd.setCursor(x,y); + lcd.print(GPSByte); + x++; + if(x==16 && y==0) { + x=0; + y=1; + } + else if(x==16 && y==1) { + x=0; + y=0; + } + + } +} + +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Master I2C On"); + lcd.setCursor(0, 1); + lcd.print("Waiting command."); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/Acelerometro.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/Acelerometro.pde new file mode 100644 index 0000000..0ec5a49 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/Acelerometro.pde @@ -0,0 +1,96 @@ +//SOBRE O EIXO X - vertical +// frente ele vai de 255 at 190 e depois 190 ate 255 +// tras ele vai de 0 a 64 + +//SOBRE O EIXO Y - horizontal +// plano 233, inclinando para esquerda 172 +// plano 233, inclinando para direita 255, 0, 46 + +//SOBRE O EIXO Z - +#include + +#define ACCELEROMETER 0x1D //Address for Accelerometer + +//REGISTERS +#define MODE_CONTROL 0x16 //Mode control register +#define PULSE_DET 0x1B //Pulse detection threshold limit value +#define X_OUT 0x06 //8 bit register containing value for X +#define Y_OUT 0x07 //8 bit register containing value for Y +#define Z_OUT 0x08 //8 bit register containing value for Z +#define DETECTION 0x0A //Detection source register + +//VALUES +#define Z_PULSE 0x40 //Pulse detected on Z-axis +#define SENSEVALUE 0x25 //Default sensitivity level + +void setupAcelerometro() { + Wire.begin(); + accWrite(MODE_CONTROL, SENSEVALUE); + +} + +//function to write byte data into a register +void accWrite(byte address, byte data) { + Wire.beginTransmission(ACCELEROMETER); + Wire.send(address); + Wire.send(data); + Wire.endTransmission(); +} + +//function to read byte data from a register +byte accRead(byte address){ + byte val = 0x00; + Wire.beginTransmission(ACCELEROMETER); + Wire.send(address); + Wire.endTransmission(); + Wire.requestFrom(ACCELEROMETER, 1); + if(Wire.available() > 0) { + val = Wire.receive(); + } + Wire.endTransmission(); + return val; +} + +void debugAcelerometro() { + Serial.print("X:"); + Serial.println((unsigned int)accRead(X_OUT)); + Serial.print("Y:"); + Serial.println((unsigned int)accRead(Y_OUT)); + Serial.print("Z:"); + Serial.println((unsigned int)accRead(Z_OUT)); + delay(100); +} +byte eixoXparaAngulo(int valor) { + if(valor>=190 && valor<=255) { + return map(valor,255,192,0,90); + } + else if(valor>=0 && valor<=64) { + return map(valor,0,64,1,90)*-1; + } + else { + return 0; + } +} + +int lerEixoX() { + return (int)accRead(X_OUT); +} +byte eixoYparaAngulo(int valor) { + if(valor>=172 && valor<=233) { + return map(valor,172,233,90,0); + } + else if((valor>=0 && valor<=46) || valor>233 && valor<=255 ) { + valor = valor > 233 ? valor = 256-valor : 23+valor; + + return map(valor,0,69,1,90)*-1; + } + else { + return 0; + } +} +int lerEixoZ() { + return (int)accRead(Z_OUT); +} +int lerEixoY() { + return (int)accRead(Y_OUT); +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/GoHorse_v1.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/GoHorse_v1.pde new file mode 100644 index 0000000..ef473d9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/GoHorse_v1.pde @@ -0,0 +1,104 @@ +#include + +// SD chip select pin +const uint8_t chipSelect = SS_PIN; +#define LED_ERROR 4 +#define LED_OK 7 +// file system object +// store error strings in flash to save RAM +#define error(s) sd.errorHalt_P(PSTR(s)) + +SdFat sd; +volatile int mode=0; + +long lastDebounce=0; +long debounceDelay=50; + +void setup() { + Serial.begin(9600); + attachInterrupt(0, changeMode, LOW); //PORTA 21, quando estiver subindo + + pinMode(4, OUTPUT); + pinMode(7, OUTPUT); + setupAcelerometro(); + digitalWrite(LED_OK, HIGH); + delay(100); + digitalWrite(LED_OK, LOW); +} + +//2805020000 +void loop() { + if(mode==1) coletar(); + else if(mode==0) idle(); + + //Serial.print('x'); + //Serial.print(eixoXparaAngulo(lerEixoX())); + //cout << endl << "Done" << endl; + + //debugAcelerometro(); + //delay(100); +} + +void changeMode() { + if(millis()-lastDebounce>debounceDelay) { + mode = mode== 1 ? 0 : 1; + lastDebounce=millis(); + } +} +void idle() { + digitalWrite(LED_OK, HIGH); + delay(2000); + digitalWrite(LED_OK, LOW); + delay(2000); +} + +void coletar() { + if(mode!=1) return; + char name[] = "APPEND.TXT"; + + // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with + // breadboards. use SPI_FULL_SPEED for better performance. + if (!sd.init(SPI_HALF_SPEED, chipSelect)) sd.initErrorHalt(); + + ofstream sdout(name, ios::out | ios::app); + if (!sdout) { + //error("open failed"); + digitalWrite(LED_ERROR, HIGH); + delay(500); + digitalWrite(LED_ERROR, LOW); + delay(500); + } + // use int() so byte will print as decimal number + sdout << "x: " << lerEixoX(); + sdout << " millis = " << millis() << endl; + digitalWrite(LED_OK, HIGH); + delay(20); + digitalWrite(LED_OK, LOW); + delay(20); + // close the stream + sdout.close(); + /*if (!sdout) { + digitalWrite(LED_ERROR, HIGH); + delay(500); + digitalWrite(LED_ERROR, LOW); + delay(500); + //error("append data failed"); + } + else { + digitalWrite(LED_ERROR, HIGH); + digitalWrite(LED_OK, HIGH); + delay(500); + digitalWrite(LED_ERROR, LOW); + digitalWrite(LED_OK, LOW); + delay(500); + }*/ + + + +} + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/Polar.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/Polar.pde new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/SDCard.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/SDCard.pde new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/SDCard.pde @@ -0,0 +1 @@ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/Visual/Visual.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/Visual/Visual.pde new file mode 100644 index 0000000..cddd7d2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/GoHorse_v1/Visual/Visual.pde @@ -0,0 +1,50 @@ +/** + * Simple Read + * + * Read data from the serial port and change the color of a rectangle + * when a switch connected to a Wiring or Arduino board is pressed and released. + * This example works with the Wiring / Arduino program that follows below. + */ + + +import processing.serial.*; + +Serial myPort; // Create object from Serial class +int val; // Data received from the serial port + +void setup() +{ + size(200,200,P3D); + String portName = Serial.list()[0]; + myPort = new Serial(this, portName, 9600); +} + +int valCorrigido = 0; +void draw() +{ + if ( myPort.available() > 0) { + val = myPort.read(); + if(val=='x') { + val = myPort.read(); + + if(val>0 && val<=90) valCorrigido=val; + else valCorrigido = val-256; + } + + } + + float t = map(valCorrigido,-90.0,+90.0, 0.0, 200.0); + + background(255); + stroke(0); + fill(175); + translate(width/2, height/2); + rotateX(PI*t/height); + System.out.println(t); + rectMode(CENTER); + rect(0,0,100,100); +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/nbactions.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/nbactions.xml new file mode 100644 index 0000000..2dfca28 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/nbactions.xml @@ -0,0 +1,47 @@ + + + + run + + package + org.codehaus.mojo:exec-maven-plugin:1.1.1:exec + + + -Dfelix.system.properties=file:"${project.build.directory}/run.properties" -cp "${project.build.directory}/felix.jar" org.apache.felix.main.Main + java + + + run-on-felix + + + + debug + + package + org.codehaus.mojo:exec-maven-plugin:1.1.1:exec + + + -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Dfelix.system.properties=file:"${project.build.directory}/run.properties" -cp "${project.build.directory}/felix.jar" org.apache.felix.main.Main + java + true + + + run-on-felix + + + + profile + + package + org.codehaus.mojo:exec-maven-plugin:1.1.1:exec + + + ${profiler.args} -Dfelix.system.properties=file:"${project.build.directory}/run.properties" -cp "${project.build.directory}/felix.jar" org.apache.felix.main.Main + ${profiler.java} + profile + + + run-on-felix + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/pom.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/pom.xml new file mode 100644 index 0000000..699056f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/pom.xml @@ -0,0 +1,135 @@ + + + + 4.0.0 + br.com.eletronlivre.arduino + ArduinoModule + 1.0-SNAPSHOT + bundle + ArduinoServiceImpl OSGi Bundle + + + org.apache.felix + org.osgi.core + 1.4.0 + + + br.com.eletronlivre.arduino + ArduinoService + 1.0-SNAPSHOT + + + + + + + org.apache.felix + maven-bundle-plugin + 2.0.1 + true + + + br.com.eletronlivre.arduino.osgi.ArduinoActivator + + + + + + + + + + run-on-felix + + + org.apache.felix + org.apache.felix.main + 2.0.2 + provided + + + org.apache.felix.gogo + org.apache.felix.gogo.commands + 0.2.2 + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.3 + + + compile + compile + + run + + + + + + + + + + + + + + + + + + + + + + + + + + felix.auto.install=${urls} + felix.auto.start=${main.bundle.url} + org.osgi.framework.storage=${project.build.url}/felix-cache + org.osgi.framework.bootdelegation=* + + + + felix.auto.install="${bundles}" + felix.auto.start=file:modules/${project.artifactId}-${project.version}.jar + + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2-beta-5 + + + create-executable-jar + package + + single + + + + ${basedir}/src/main/assembly/felix.xml + + ${project.artifactId}-${project.version} + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/src/main/assembly/felix.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/src/main/assembly/felix.xml new file mode 100644 index 0000000..956d093 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/src/main/assembly/felix.xml @@ -0,0 +1,37 @@ + + + all + + zip + + + + false + modules + + org.apache.felix:org.apache.felix.main + + + + false + + + org.apache.felix:org.apache.felix.main + + + + + + ${project.build.directory}/${project.artifactId}-${project.version}.jar + modules + + + ${project.build.directory}/felix.jar + bin + + + ${project.build.directory}/config.properties + conf + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/src/main/java/br/com/eletronlivre/arduino/osgi/ArduinoActivator.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/src/main/java/br/com/eletronlivre/arduino/osgi/ArduinoActivator.java new file mode 100644 index 0000000..325ba0b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/src/main/java/br/com/eletronlivre/arduino/osgi/ArduinoActivator.java @@ -0,0 +1,23 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.eletronlivre.arduino.osgi; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +/** + * + * @author vsenger + */ +public class ArduinoActivator implements BundleActivator { + + public void start(BundleContext context) throws Exception { + //TODO add activation code here + } + + public void stop(BundleContext context) throws Exception { + //TODO add deactivation code here + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/src/main/java/br/com/eletronlivre/arduino/osgi/ArduinoImpl.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/src/main/java/br/com/eletronlivre/arduino/osgi/ArduinoImpl.java new file mode 100644 index 0000000..8f99fe9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/src/main/java/br/com/eletronlivre/arduino/osgi/ArduinoImpl.java @@ -0,0 +1,18 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package br.com.eletronlivre.arduino.osgi; + +/** + * + * @author vsenger + */ +public class ArduinoImpl implements Arduino { + + public void send(byte[] b) { + System.out.println("UIA!"); + } + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/ArduinoModule-1.0-SNAPSHOT-all.zip b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/ArduinoModule-1.0-SNAPSHOT-all.zip new file mode 100644 index 0000000..a67e40e Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/ArduinoModule-1.0-SNAPSHOT-all.zip differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/classes/META-INF/MANIFEST.MF b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000..ffc48c2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/classes/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Export-Package: br.com.eletronlivre.arduino.osgi;uses:="org.osgi.frame + work" +Built-By: vsenger +Tool: Bnd-0.0.357 +Bundle-Name: ArduinoServiceImpl OSGi Bundle +Created-By: Apache Maven Bundle Plugin +Bundle-Version: 1.0.0.SNAPSHOT +Build-Jdk: 1.6.0_18 +Bnd-LastModified: 1305319842063 +Bundle-ManifestVersion: 2 +Bundle-Activator: br.com.eletronlivre.arduino.osgi.ArduinoActivator +Import-Package: br.com.eletronlivre.arduino.osgi,org.osgi.framework;ve + rsion="1.5" +Bundle-SymbolicName: br.com.eletronlivre.arduino.ArduinoModule + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/config.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/config.properties new file mode 100644 index 0000000..4153dd7 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/config.properties @@ -0,0 +1,2 @@ +felix.auto.install="file:modules/classes file:modules/org.osgi.core-1.4.0.jar file:modules/org.apache.felix.gogo.commands-0.2.2.jar file:modules/org.apache.felix.gogo.runtime-0.2.2.jar" + felix.auto.start=file:modules/ArduinoModule-1.0-SNAPSHOT.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle0/bundle.id b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle0/bundle.id new file mode 100644 index 0000000..7813681 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle0/bundle.id @@ -0,0 +1 @@ +5 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.id b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.id new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.id @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.lastmodified b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.lastmodified new file mode 100644 index 0000000..8a8ceef --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.lastmodified @@ -0,0 +1 @@ +1305317235983 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.location b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.location new file mode 100644 index 0000000..846636b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.location @@ -0,0 +1 @@ +file:/home/vsenger/.m2/repository/org/apache/felix/org.osgi.core/1.4.0/org.osgi.core-1.4.0.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.startlevel b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.startlevel new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.startlevel @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/version0.0/revision.location b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/version0.0/revision.location new file mode 100644 index 0000000..846636b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/version0.0/revision.location @@ -0,0 +1 @@ +file:/home/vsenger/.m2/repository/org/apache/felix/org.osgi.core/1.4.0/org.osgi.core-1.4.0.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.id b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.id new file mode 100644 index 0000000..d8263ee --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.id @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.lastmodified b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.lastmodified new file mode 100644 index 0000000..d2a75ad --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.lastmodified @@ -0,0 +1 @@ +1305317236005 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.location b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.location new file mode 100644 index 0000000..558bbb7 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.location @@ -0,0 +1 @@ +file:/home/vsenger/.m2/repository/org/apache/felix/gogo/org.apache.felix.gogo.commands/0.2.2/org.apache.felix.gogo.commands-0.2.2.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.startlevel b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.startlevel new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.startlevel @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/version0.0/revision.location b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/version0.0/revision.location new file mode 100644 index 0000000..558bbb7 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/version0.0/revision.location @@ -0,0 +1 @@ +file:/home/vsenger/.m2/repository/org/apache/felix/gogo/org.apache.felix.gogo.commands/0.2.2/org.apache.felix.gogo.commands-0.2.2.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.id b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.id new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.id @@ -0,0 +1 @@ +3 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.lastmodified b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.lastmodified new file mode 100644 index 0000000..86190a8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.lastmodified @@ -0,0 +1 @@ +1305317236026 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.location b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.location new file mode 100644 index 0000000..82c2f56 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.location @@ -0,0 +1 @@ +file:/home/vsenger/.m2/repository/org/apache/felix/gogo/org.apache.felix.gogo.runtime/0.2.2/org.apache.felix.gogo.runtime-0.2.2.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.startlevel b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.startlevel new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.startlevel @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/version0.0/revision.location b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/version0.0/revision.location new file mode 100644 index 0000000..82c2f56 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/version0.0/revision.location @@ -0,0 +1 @@ +file:/home/vsenger/.m2/repository/org/apache/felix/gogo/org.apache.felix.gogo.runtime/0.2.2/org.apache.felix.gogo.runtime-0.2.2.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.id b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.id new file mode 100644 index 0000000..bf0d87a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.id @@ -0,0 +1 @@ +4 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.lastmodified b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.lastmodified new file mode 100644 index 0000000..4bfc08e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.lastmodified @@ -0,0 +1 @@ +1305317236041 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.location b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.location new file mode 100644 index 0000000..72ba808 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.location @@ -0,0 +1 @@ +file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/JavaEEArduino/ArduinoModule/target/ArduinoModule-1.0-SNAPSHOT.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.startlevel b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.startlevel new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.startlevel @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.state b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.state new file mode 100644 index 0000000..6811ae8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.state @@ -0,0 +1 @@ +active \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/version0.0/revision.location b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/version0.0/revision.location new file mode 100644 index 0000000..72ba808 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/version0.0/revision.location @@ -0,0 +1 @@ +file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/JavaEEArduino/ArduinoModule/target/ArduinoModule-1.0-SNAPSHOT.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/run.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/run.properties new file mode 100644 index 0000000..aedd4fb --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoModule/target/run.properties @@ -0,0 +1,4 @@ +felix.auto.install=file:/home/vsenger/.m2/repository/org/apache/felix/org.osgi.core/1.4.0/org.osgi.core-1.4.0.jar file:/home/vsenger/.m2/repository/org/apache/felix/gogo/org.apache.felix.gogo.commands/0.2.2/org.apache.felix.gogo.commands-0.2.2.jar file:/home/vsenger/.m2/repository/org/apache/felix/gogo/org.apache.felix.gogo.runtime/0.2.2/org.apache.felix.gogo.runtime-0.2.2.jar + felix.auto.start=file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/JavaEEArduino/ArduinoModule/target/ArduinoModule-1.0-SNAPSHOT.jar + org.osgi.framework.storage=/media/Vinicius/EletronLivre/Program-ME/Arduino Sketches/JavaEEArduino/ArduinoModule/target/felix-cache + org.osgi.framework.bootdelegation=* \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/pom.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/pom.xml new file mode 100644 index 0000000..4ee2a5d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + br.com.eletronlivre.arduino + ArduinoService + bundle + 1.0-SNAPSHOT + ArduinoService + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/src/main/java/br/com/eletronlivre/arduino/osgi/Arduino.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/src/main/java/br/com/eletronlivre/arduino/osgi/Arduino.java new file mode 100644 index 0000000..f217406 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/src/main/java/br/com/eletronlivre/arduino/osgi/Arduino.java @@ -0,0 +1,14 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package br.com.eletronlivre.arduino.osgi; + +/** + * + * @author vsenger + */ +public interface Arduino { + public void send(byte[] b); +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/src/test/java/br/com/eletronlivre/arduino/arduinoservice/AppTest.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/src/test/java/br/com/eletronlivre/arduino/arduinoservice/AppTest.java new file mode 100644 index 0000000..58b590b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/src/test/java/br/com/eletronlivre/arduino/arduinoservice/AppTest.java @@ -0,0 +1,38 @@ +package br.com.eletronlivre.arduino.arduinoservice; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/target/maven-archiver/pom.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/target/maven-archiver/pom.properties new file mode 100644 index 0000000..ec693b8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Fri May 13 17:26:35 BRT 2011 +version=1.0-SNAPSHOT +groupId=br.com.eletronlivre.arduino +artifactId=ArduinoService diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/target/surefire-reports/TEST-br.com.eletronlivre.arduino.arduinoservice.AppTest.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/target/surefire-reports/TEST-br.com.eletronlivre.arduino.arduinoservice.AppTest.xml new file mode 100644 index 0000000..cc51b36 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/target/surefire-reports/TEST-br.com.eletronlivre.arduino.arduinoservice.AppTest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/target/surefire-reports/br.com.eletronlivre.arduino.arduinoservice.AppTest.txt b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/target/surefire-reports/br.com.eletronlivre.arduino.arduinoservice.AppTest.txt new file mode 100644 index 0000000..a63dfda --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ArduinoService/target/surefire-reports/br.com.eletronlivre.arduino.arduinoservice.AppTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: br.com.eletronlivre.arduino.arduinoservice.AppTest +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.083 sec diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build.xml new file mode 100644 index 0000000..3bd178d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build.xml @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project exemplo. + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/classes/exemplo/Bundle.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/classes/exemplo/Bundle.properties new file mode 100644 index 0000000..00d1841 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/classes/exemplo/Bundle.properties @@ -0,0 +1 @@ +OpenIDE-Module-Name=Exemplo diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/cluster/.lastModified b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/cluster/.lastModified new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/cluster/config/Modules/exemplo.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/cluster/config/Modules/exemplo.xml new file mode 100644 index 0000000..3d09a05 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/cluster/config/Modules/exemplo.xml @@ -0,0 +1,10 @@ + + + + false + false + true + modules/exemplo.jar + false + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/cluster/update_tracking/exemplo.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/cluster/update_tracking/exemplo.xml new file mode 100644 index 0000000..d868237 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/cluster/update_tracking/exemplo.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/no-license.txt b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/no-license.txt new file mode 100644 index 0000000..201dea1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/build/no-license.txt @@ -0,0 +1 @@ +[NO LICENSE SPECIFIED] \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/manifest.mf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/manifest.mf new file mode 100644 index 0000000..8f4f19a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/manifest.mf @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Bundle-Localization: exemplo/Bundle +Bundle-Name: %OpenIDE-Module-Name +Bundle-SymbolicName: exemplo +Bundle-Version: 1.0 + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/build-impl.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/build-impl.xml new file mode 100644 index 0000000..80852e5 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/build-impl.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/genfiles.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/genfiles.properties new file mode 100644 index 0000000..1a350dd --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=ae010660 +build.xml.script.CRC32=22fcf54e +build.xml.stylesheet.CRC32=a56c6a5b@1.42.2 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=ae010660 +nbproject/build-impl.xml.script.CRC32=bf763f61 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.42.2 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/platform.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/platform.properties new file mode 100644 index 0000000..8705226 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/platform.properties @@ -0,0 +1,20 @@ +cluster.path=\ + ${nbplatform.active.dir}/javafx:\ + ${nbplatform.active.dir}/dlight:\ + ${nbplatform.active.dir}/ruby:\ + ${nbplatform.active.dir}/enterprise:\ + ${nbplatform.active.dir}/groovy:\ + ${nbplatform.active.dir}/java:\ + ${nbplatform.active.dir}/ergonomics:\ + ${nbplatform.active.dir}/ide:\ + ${nbplatform.active.dir}/identity:\ + ${nbplatform.active.dir}/apisupport:\ + ${nbplatform.active.dir}/cnd:\ + ${nbplatform.active.dir}/profiler:\ + ${nbplatform.active.dir}/platform:\ + ${nbplatform.active.dir}/harness:\ + ${nbplatform.active.dir}/mobility:\ + ${nbplatform.active.dir}/websvccommon:\ + ${nbplatform.active.dir}/php:\ + ${nbplatform.active.dir}/nb +nbplatform.active=default diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/private/platform-private.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/private/platform-private.properties new file mode 100644 index 0000000..29920de --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/private/platform-private.properties @@ -0,0 +1 @@ +user.properties.file=/home/vsenger/.netbeans/6.9/build.properties diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/private/private.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/private/private.xml new file mode 100644 index 0000000..528803d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/private/private.xml @@ -0,0 +1,6 @@ + + + + file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/JavaEEArduino/Exemplo/build/classes/exemplo/Bundle.properties + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/project.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/project.properties new file mode 100644 index 0000000..17255ba --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/project.properties @@ -0,0 +1,2 @@ +javac.source=1.6 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/project.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/project.xml new file mode 100644 index 0000000..a4fac88 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/nbproject/project.xml @@ -0,0 +1,18 @@ + + + org.netbeans.modules.apisupport.project + + + exemplo + + + + org.netbeans.libs.osgi + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/src/exemplo/Bundle.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/src/exemplo/Bundle.properties new file mode 100644 index 0000000..00d1841 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/Exemplo/src/exemplo/Bundle.properties @@ -0,0 +1 @@ +OpenIDE-Module-Name=Exemplo diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/build.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/build.xml new file mode 100644 index 0000000..a0ee456 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/build.xml @@ -0,0 +1,69 @@ + + + + + + Builds, tests, and runs the project ScalaApplication1. + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/manifest.mf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/build-impl.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/build-impl.xml new file mode 100644 index 0000000..a7a2b44 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/build-impl.xml @@ -0,0 +1,710 @@ + + + + + + + + + + + + + + + + + + + You must set SCALA_HOME or environment property and append "-J-Dscala.home=scalahomepath" + property to the end of "netbeans_default_options" in NetBeansInstallationPath/etc/netbeans.conf to point to + Scala installation directory. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/genfiles.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/genfiles.properties new file mode 100644 index 0000000..463d13c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=eeb8aeb7 +build.xml.script.CRC32=83c78a1c +build.xml.stylesheet.CRC32=ca9d572e@1.5 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=eeb8aeb7 +nbproject/build-impl.xml.script.CRC32=63812ea2 +nbproject/build-impl.xml.stylesheet.CRC32=5220179f@1.5 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/private/private.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/private/private.properties new file mode 100644 index 0000000..121c208 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/private/private.properties @@ -0,0 +1 @@ +user.properties.file=/home/vsenger/.netbeans/7.0/build.properties diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/project.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/project.properties new file mode 100644 index 0000000..85f477f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/project.properties @@ -0,0 +1,64 @@ +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form,**/*.scala +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ScalaApplication1.jar +dist.javadoc.dir=${dist.dir}/scaladoc +excludes= +includes=** +jar.compress=false +java.platform.active=java_default_platform +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=scalaapplication1.Main +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +# Space-separated list of extra scalac options +scalac.compilerargs= +scalac.deprecation=no +scalac.unchecked=no +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/project.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/project.xml new file mode 100644 index 0000000..c136834 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/nbproject/project.xml @@ -0,0 +1,16 @@ + + + org.netbeans.modules.scala.project + + + ScalaApplication1 + 1.6.5 + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/src/scalaapplication1/Main.scala b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/src/scalaapplication1/Main.scala new file mode 100644 index 0000000..460f4d5 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/ScalaApplication1/src/scalaapplication1/Main.scala @@ -0,0 +1,17 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package scalaapplication1 + +object Main { + + /** + * @param args the command line arguments + */ + def main(args: Array[String]): Unit = { + println("Hello, world!") + } + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/pom.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/pom.xml new file mode 100644 index 0000000..f3d90f9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/pom.xml @@ -0,0 +1,101 @@ + + + 4.0.0 + br.com.eletronlivre.webscheduler + WebScheduler + war + 1.0-SNAPSHOT + WebScheduler Java EE 6 Webapp + http://maven.apache.org + + + java.net2 + Repository hosting the jee6 artifacts + http://download.java.net/maven/2 + + + + + javax + javaee-web-api + 6.0 + provided + + + + junit + junit + 3.8.2 + test + + + br.com.eletronlivre.arduino + ArduinoService + 1.0-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.6 + 1.6 + + + + org.apache.maven.plugins + maven-war-plugin + 2.1-beta-1 + + false + + + + WebScheduler + + + + endorsed + + + sun.boot.class.path + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + + + ${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar${path.separator}${sun.boot.class.path} + + + + + javax + javaee-endorsed-api + 6.0 + + + + + + + + + gfv3ee6 + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/profiles.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/profiles.xml new file mode 100644 index 0000000..895de51 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/profiles.xml @@ -0,0 +1,18 @@ + + + + + netbeans-private + + + netbeans.execution + true + + + + [/java/glassfish3.1-final/glassfish]deployer:gfv3ee6:localhost:4848 + + + + \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/src/main/java/br/com/eletronlivre/webscheduler/TesteOSGi.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/src/main/java/br/com/eletronlivre/webscheduler/TesteOSGi.java new file mode 100644 index 0000000..eec4e4a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/src/main/java/br/com/eletronlivre/webscheduler/TesteOSGi.java @@ -0,0 +1,84 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.eletronlivre.webscheduler; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author vsenger + */ +@WebServlet(name = "TesteOSGi", urlPatterns = {"/TesteOSGi"}) +public class TesteOSGi extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST methods. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + PrintWriter out = response.getWriter(); + try { + /* TODO output your page here + out.println(""); + out.println(""); + out.println("Servlet TesteOSGi"); + out.println(""); + out.println(""); + out.println("

Servlet TesteOSGi at " + request.getContextPath () + "

"); + out.println(""); + out.println(""); + */ + } finally { + out.close(); + } + } + + // + /** + * Handles the HTTP GET method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/src/main/webapp/WEB-INF/sun-web.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/src/main/webapp/WEB-INF/sun-web.xml new file mode 100644 index 0000000..7ea918d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/src/main/webapp/WEB-INF/sun-web.xml @@ -0,0 +1,11 @@ + + + + /WebScheduler + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/src/main/webapp/index.jsp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/src/main/webapp/index.jsp new file mode 100644 index 0000000..ab292c3 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/src/main/webapp/index.jsp @@ -0,0 +1,13 @@ +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + JSP Page + + +

Hello World!

+ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/target/WebScheduler/WEB-INF/sun-web.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/target/WebScheduler/WEB-INF/sun-web.xml new file mode 100644 index 0000000..7ea918d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/target/WebScheduler/WEB-INF/sun-web.xml @@ -0,0 +1,11 @@ + + + + /WebScheduler + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/target/WebScheduler/index.jsp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/target/WebScheduler/index.jsp new file mode 100644 index 0000000..ab292c3 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/target/WebScheduler/index.jsp @@ -0,0 +1,13 @@ +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + JSP Page + + +

Hello World!

+ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/target/maven-archiver/pom.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/target/maven-archiver/pom.properties new file mode 100644 index 0000000..5854004 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Fri May 13 17:51:54 BRT 2011 +version=1.0-SNAPSHOT +groupId=br.com.eletronlivre.webscheduler +artifactId=WebScheduler diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/target/war/work/webapp-cache.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/target/war/work/webapp-cache.xml new file mode 100644 index 0000000..e928c35 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/JavaEEArduino/WebScheduler/target/war/work/webapp-cache.xml @@ -0,0 +1,51 @@ + + + + currentBuild + + + index.jsp + WEB-INF/sun-web.xml + WEB-INF/classes/br/com/eletronlivre/webscheduler/TesteOSGi.class + WEB-INF/lib/ArduinoService-1.0-SNAPSHOT.jar + + + + + + + + javax + javaee-web-api + 6.0 + jar + provided + + false + + + + + junit + junit + 3.8.2 + jar + test + + false + + + + + br.com.eletronlivre.arduino + ArduinoService + 1.0-SNAPSHOT + jar + compile + + false + + ArduinoService-1.0-SNAPSHOT.jar + + + \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/MMA7455/MMA7455.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/MMA7455/MMA7455.pde new file mode 100644 index 0000000..3a0bab1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/MMA7455/MMA7455.pde @@ -0,0 +1,89 @@ +/* + Accelerometer + + A Program which takes input from an accelerometer and outputs the + data to the serial port + + Hardware: Parallax MMA7455 + Concept Usage: Games controller + */ + +#include + +#define ACCELEROMETER 0x1D //Address for Accelerometer + +//REGISTERS +#define MODE_CONTROL 0x16 //Mode control register +#define PULSE_DET 0x1B //Pulse detection threshold limit value +#define X_OUT 0x06 //8 bit register containing value for X +#define Y_OUT 0x07 //8 bit register containing value for Y +#define Z_OUT 0x08 //8 bit register containing value for Z +#define DETECTION 0x0A //Detection source register + +//VALUES +#define Z_PULSE 0x40 //Pulse detected on Z-axis +#define SENSEVALUE 0x25 //Default sensitivity level + +//required setup function +void setup() { + Wire.begin(); + Serial.begin(9600); + accWrite(MODE_CONTROL, SENSEVALUE); +} + +void loop() { + int eixoX = (int)accRead(X_OUT); + Serial.print("X:"); + Serial.println(eixoX); + Serial.print("Angulo X:"); + Serial.println(eixoXparaAngulo); + + //Serial.print("Y:"); + //Serial.println((unsigned int)accRead(Y_OUT)); + //Serial.print("Z:"); + //Serial.println((unsigned int)accRead(Z_OUT)); + delay(100); +} + +//function to write byte data into a register +void accWrite(byte address, byte data) { + Wire.beginTransmission(ACCELEROMETER); + Wire.send(address); + Wire.send(data); + Wire.endTransmission(); +} + +//function to read byte data from a register +byte accRead(byte address){ + byte val = 0x00; + Wire.beginTransmission(ACCELEROMETER); + Wire.send(address); + Wire.endTransmission(); + Wire.requestFrom(ACCELEROMETER, 1); + if(Wire.available() > 0) { + val = Wire.receive(); + } + Wire.endTransmission(); + return val; +} + +byte eixoXparaAngulo(int valor) { + if(valor>=190 && valor<=255) { + return map(valor,255,190,0,90); + } + else if(valor>=0 && valor<=64) { + return map(valor,0,64,0,-90); + } +} + +//SOBRE O EIXO X - vertical +// frente ele vai de 255 at 190 e depois 190 ate 255 +// tras ele vai de 0 a 64 + +//SOBRE O EIXO X - horizontal +// plano 233, inclinando para esquerda 172 +// plano 233, inclinando para direita 255, 0, 46 + +//SOBRE O EIXO Z - + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Motores/MotorPassoBipolar/MotorPassoBipolar.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Motores/MotorPassoBipolar/MotorPassoBipolar.pde new file mode 100644 index 0000000..8d4e3df --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Motores/MotorPassoBipolar/MotorPassoBipolar.pde @@ -0,0 +1,66 @@ +#define MOTOR1_P 3 +#define MOTOR1_N 4 +#define MOTOR1_PWM 5 + +#define MOTOR2_P 7 +#define MOTOR2_N 8 +#define MOTOR2_PWM 6 + +void setup() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + + digitalWrite(MOTOR1_PWM, HIGH); + + digitalWrite(MOTOR2_PWM, HIGH); +} + +void loop() { + step1(); + + delay(2); + + step2(); + + delay(2); + + step3(); + + delay(2); + + step4(); + + delay(2); + + +} +void step1() { + digitalWrite(MOTOR1_P, HIGH); + digitalWrite(MOTOR2_P, HIGH); + digitalWrite(MOTOR1_N, LOW); + digitalWrite(MOTOR2_N, LOW); +} + +void step2() { + digitalWrite(MOTOR1_P, LOW); + digitalWrite(MOTOR2_P, HIGH); + digitalWrite(MOTOR1_N, HIGH); + digitalWrite(MOTOR2_N, LOW); +} + +void step3() { + digitalWrite(MOTOR1_P, LOW); + digitalWrite(MOTOR2_P, LOW); + digitalWrite(MOTOR1_N, HIGH); + digitalWrite(MOTOR2_N, HIGH); +} +void step4() { + digitalWrite(MOTOR1_P, HIGH); + digitalWrite(MOTOR2_P, LOW); + digitalWrite(MOTOR1_N, LOW); + digitalWrite(MOTOR2_N, HIGH); +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Motores/MotorPassoUnipolarWaveDrive/MotorPassoUnipolarWaveDrive.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Motores/MotorPassoUnipolarWaveDrive/MotorPassoUnipolarWaveDrive.pde new file mode 100644 index 0000000..e47e49b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Motores/MotorPassoUnipolarWaveDrive/MotorPassoUnipolarWaveDrive.pde @@ -0,0 +1,71 @@ +#define Q2 9 +#define Q3 6 +#define Q4 18 +#define Q5 17 +#define NUM_PASSOS 4 + +void setup() { + Serial.begin(9600); + pinMode(Q2, OUTPUT); + pinMode(Q3, OUTPUT); + pinMode(Q4, OUTPUT); + pinMode(Q5, OUTPUT); + escreve_motor(false,false,false,false); +} + +void loop(){ + Serial.println("passo 0"); + seleciona_passo(0); + delay(50); + + Serial.println("passo 1"); + seleciona_passo(1); + delay(50); + Serial.println("passo 2"); + seleciona_passo(2); + delay(50); + Serial.println("passo 3"); + seleciona_passo(3); + delay(50); + + +} +void escreve_motor (boolean b_q2, boolean b_q3, boolean b_q4, boolean b_q5) { + digitalWrite(Q2, b_q2); + digitalWrite(Q3, b_q3); + digitalWrite(Q4, b_q4); + digitalWrite(Q5, b_q5); +} +void seleciona_passo (int passo){ + boolean b_q2, b_q3, b_q4, b_q5; + switch (passo) { + case 0: + b_q2 = true; + b_q3 = false; + b_q4 = false; + b_q5 = false; + break; + case 1: + b_q2 = false; + b_q3 = true; + b_q4 = false; + b_q5 = false; + break; + case 2: + b_q2 = false; + b_q3 = false; + b_q4 = true; + b_q5 = false; + break; + case 3: + b_q2 = false; + b_q3 = false; + b_q4 = false; + b_q5 = true; + break; + } + escreve_motor (b_q2, b_q3, b_q4, b_q5); +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Motores/MotorPassoUnipolar_FullDrive/MotorPassoUnipolar_FullDrive.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Motores/MotorPassoUnipolar_FullDrive/MotorPassoUnipolar_FullDrive.pde new file mode 100644 index 0000000..b184db7 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Motores/MotorPassoUnipolar_FullDrive/MotorPassoUnipolar_FullDrive.pde @@ -0,0 +1,71 @@ +#define Q2 9 +#define Q3 6 +#define Q4 18 +#define Q5 17 +#define NUM_PASSOS 4 + +void setup() { + Serial.begin(9600); + pinMode(Q2, OUTPUT); + pinMode(Q3, OUTPUT); + pinMode(Q4, OUTPUT); + pinMode(Q5, OUTPUT); + escreve_motor(false,false,false,false); +} + +void loop(){ + Serial.println("passo 0"); + seleciona_passo(0); + delay(5); + + Serial.println("passo 1"); + seleciona_passo(1); + delay(5); + Serial.println("passo 2"); + seleciona_passo(2); + delay(5); + Serial.println("passo 3"); + seleciona_passo(3); + delay(5); + + +} +void escreve_motor (boolean b_q2, boolean b_q3, boolean b_q4, boolean b_q5) { + digitalWrite(Q2, b_q2); + digitalWrite(Q3, b_q3); + digitalWrite(Q4, b_q4); + digitalWrite(Q5, b_q5); +} +void seleciona_passo (int passo){ + boolean b_q2, b_q3, b_q4, b_q5; + switch (passo) { + case 0: + b_q2 = true; + b_q3 = false; + b_q4 = false; + b_q5 = true; + break; + case 1: + b_q2 = true; + b_q3 = false; + b_q4 = true; + b_q5 = false; + break; + case 2: + b_q2 = false; + b_q3 = true; + b_q4 = true; + b_q5 = false; + break; + case 3: + b_q2 = false; + b_q3 = true; + b_q4 = false; + b_q5 = true; + break; + } + escreve_motor (b_q2, b_q3, b_q4, b_q5); +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Motores/StepperMotorUnipolar/StepperMotorUnipolar.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Motores/StepperMotorUnipolar/StepperMotorUnipolar.pde new file mode 100644 index 0000000..3f0112e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Motores/StepperMotorUnipolar/StepperMotorUnipolar.pde @@ -0,0 +1,71 @@ +#define Q2 9 +#define Q3 6 +#define Q4 18 +#define Q5 17 +#define NUM_PASSOS 4 + +void setup() { + Serial.begin(9600); + pinMode(Q2, OUTPUT); + pinMode(Q3, OUTPUT); + pinMode(Q4, OUTPUT); + pinMode(Q5, OUTPUT); + escreve_motor(false,false,false,false); +} + +void loop(){ + Serial.println("passo 0"); + seleciona_passo(0); + delay(10); + + Serial.println("passo 1"); + seleciona_passo(1); + delay(10); + Serial.println("passo 2"); + seleciona_passo(2); + delay(10); + Serial.println("passo 3"); + seleciona_passo(3); + delay(10); + + +} +void escreve_motor (boolean b_q2, boolean b_q3, boolean b_q4, boolean b_q5) { + digitalWrite(Q2, b_q2); + digitalWrite(Q3, b_q3); + digitalWrite(Q4, b_q4); + digitalWrite(Q5, b_q5); +} +void seleciona_passo (int passo){ + boolean b_q2, b_q3, b_q4, b_q5; + switch (passo) { + case 0: + b_q2 = true; + b_q3 = false; + b_q4 = false; + b_q5 = true; + break; + case 1: + b_q2 = true; + b_q3 = false; + b_q4 = true; + b_q5 = false; + break; + case 2: + b_q2 = false; + b_q3 = true; + b_q4 = true; + b_q5 = false; + break; + case 3: + b_q2 = false; + b_q3 = true; + b_q4 = false; + b_q5 = true; + break; + } + escreve_motor (b_q2, b_q3, b_q4, b_q5); +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Multimodonamao/Multimodonamao.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Multimodonamao/Multimodonamao.pde new file mode 100644 index 0000000..6625bb0 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Multimodonamao/Multimodonamao.pde @@ -0,0 +1,31 @@ +#include + +void setup() +{ + Kernel.setup(); + Kernel.registerMode("blink"); + Kernel.registerTask(blinkLeds); + Kernel.registerMode("readSensor"); + Kernel.registerTask(blinkLeds); + Kernel.registerMode("playMusic"); + Kernel.registerTask(blinkLeds); + +} + +void loop() +{ + Kernel.loop; +} + +void blinkLeds() { + //... +} + +void readSensor() { + //... +} + +void playMusic() { + //... +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/PingParallax/PingParallax.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/PingParallax/PingParallax.pde new file mode 100644 index 0000000..6efd40f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/PingParallax/PingParallax.pde @@ -0,0 +1,41 @@ +#define PING_PIN 13 +long duration, inches, cm; + +void setup() { + Serial.begin(9600); +} + +void loop() { + readPing(); + delay(500); +} +void readPing() +{ + + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Pololu_Seguidor_Linha_Debug/Pololu_Seguidor_Linha_Debug.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Pololu_Seguidor_Linha_Debug/Pololu_Seguidor_Linha_Debug.pde new file mode 100644 index 0000000..bf7778c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Pololu_Seguidor_Linha_Debug/Pololu_Seguidor_Linha_Debug.pde @@ -0,0 +1,31 @@ +#include +#include + +#define NUM_SENSORS 3 // number of sensors used +#define TIMEOUT 2500 // waits for 2500 us for sensor outputs to go low +#define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2 + +unsigned int last_proportional = 0; +long integral = 0; + +// sensores 1 a 5 estao conectados nas portas digitais 5, 9, 2, 3 e 4, respectivamente +PololuQTRSensorsRC qtrrc((unsigned char[]) {2, 3, 4}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); +unsigned int sensorValues[NUM_SENSORS]; + +boolean calibrado = false; + +void setup(){ + Serial.begin(115200); + Serial.println("Heelooo"); + delay(20); +} + +void loop(){ + seguirLinha(); + delay(100); + + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Pololu_Seguidor_Linha_Debug/SeguidorLinha.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Pololu_Seguidor_Linha_Debug/SeguidorLinha.pde new file mode 100644 index 0000000..469f443 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Pololu_Seguidor_Linha_Debug/SeguidorLinha.pde @@ -0,0 +1,94 @@ +void calibrarSensorDeLinha() { + int i; + // Auto-calibration: turn right and left while calibrating the sensors. + for (i = 0; i < 155; i++) { // make the calibration take about 10 seconds + if (i < 40 || i > 110); + //setSpeeds(60, -60); + else; + //setSpeeds(-60, 60); + qtrrc.calibrate(); // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call) + } + //setSpeeds(0, 0); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMinimumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMaximumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + //Serial.println(); + calibrado=true; +} + +void seguirLinha() { + if(!calibrado) calibrarSensorDeLinha(); + unsigned int position = qtrrc.readLine(sensorValues); // Get the position of the line. + int proportional = (int)position - 2000;// The "proportional" term should be 0 when we are on the line. + //Serial.print("proportional: "); + //Serial.println(proportional); + int derivative = proportional - last_proportional; // Compute the derivative (change) of the position. + //Serial.print("derivative: "); + //Serial.println(derivative); + integral += proportional; // Compute the integral (sum) of the position. + //Serial.print("integral: "); + //Serial.println(integral); + last_proportional = proportional; // Remember the last position. + + // Compute the difference between the two motor power settings, + // m1 - m2. If this is a positive number the robot will turn + // to the right. If it is a negative number, the robot will + // turn to the left, and the magnitude of the number determines + // the sharpness of the turn. You can adjust the constants by which + // the proportional, integral, and derivative terms are multiplied to + // improve performance. + int power_difference = proportional/20 + integral/10000 + derivative*3/2; + + // Compute the actual motor settings. We never set either motor + // to a negative value. + const int maximum = 120; + if (power_difference > maximum) + power_difference = maximum; + if (power_difference < -maximum) + power_difference = -maximum; + // Serial.print("power diference: "); + // Serial.println(power_difference); + //setSpeeds(70,70); + if (power_difference < 0){ + //setSpeeds(maximum + power_difference, maximum); + // Serial.print("motores: "); + // Serial.println(maximum + power_difference); + // Serial.print(" : "); + // Serial.println(maximum); + } + else{ + //setSpeeds(maximum, maximum - power_difference); + // Serial.print("motores: "); + // Serial.print(maximum); + // Serial.print(" : "); + // Serial.println(maximum - power_difference); + // Serial.println(" "); + } + //Ler sensor distancia + //Se tiver objeto na frente, parar + //Andar um pouco pra traz + //Programacao do desvio de pista + + //delay(1000); + Serial.print("position: "); + Serial.println(position); + Serial.println("sensor values: "); + for(int x=0;x40) { + Serial.println("longe"); + } + else { + Serial.println("perto"); + digitalWrite(4, HIGH); + delay(100); + digitalWrite(4, LOW); + + } + delay(500); +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/AvoidanceModo/AvoidanceModo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/AvoidanceModo/AvoidanceModo.pde new file mode 100644 index 0000000..af7b0ce --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/AvoidanceModo/AvoidanceModo.pde @@ -0,0 +1,82 @@ +#include + +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +Servo servoV; +Servo servoH; +long distancia; +long distanciaEsquerda; +long distanciaDireita; + +void setup(){ + setupMotor(); + servoH.attach(5); + servoV.attach(6); + +} + +void loop() { + lerPing(); + + while(distancia>25) { + andarFrente(200,3); + lerPing(); + } + while(distancia>15 && distancia<25) { + parar(); + delay(200); + lerPingFull(); + if(distanciaEsquerda>distancia && distanciaEsquerda>distanciaDireita) { + girarNoEixo(300,2,1); + } + if(distanciaDireita>distancia && distanciaDireita>distanciaEsquerda) { + girarNoEixo(300,2,0); + } + lerPing(); + } + while(distancia>5 && distancia<15) { + parar(); + andarTraz(500,2); + girarNoEixo(500,2, random(10)%2==0); + lerPing(); + } + +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/AvoidanceModo/LibMotor.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/AvoidanceModo/LibMotor.pde new file mode 100644 index 0000000..6720533 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/AvoidanceModo/LibMotor.pde @@ -0,0 +1,92 @@ +int sentido=0; + +void setupMotor() { + pinMode(MOTOR1_A, OUTPUT); + pinMode(MOTOR1_B, OUTPUT); + pinMode(MOTOR2_A, OUTPUT); + pinMode(MOTOR2_B, OUTPUT); +} + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido1); + digitalWrite(MOTOR1_B,!sentido1); + digitalWrite(MOTOR2_A,!sentido1); + digitalWrite(MOTOR2_B,sentido1); + delay(tempo); +} + + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); + digitalWrite(MOTOR1_A,0); + digitalWrite(MOTOR1_B,0); + digitalWrite(MOTOR2_A,0); + digitalWrite(MOTOR2_B,0); + +} +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_A,!sentido); + digitalWrite(MOTOR1_B,sentido); + digitalWrite(MOTOR2_A,!sentido); + digitalWrite(MOTOR2_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,!sentido); + digitalWrite(MOTOR1_B,sentido); + digitalWrite(MOTOR2_A,!sentido); + digitalWrite(MOTOR2_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/AvoidanceModo/LibPing.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/AvoidanceModo/LibPing.pde new file mode 100644 index 0000000..1d89b8b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/AvoidanceModo/LibPing.pde @@ -0,0 +1,28 @@ + +int lerPingComMedia() { + int d1,d2,d3; + d1 = analogRead(1); + delay(5); + d2 = analogRead(1); + delay(5); + d3 = analogRead(1); + delay(5); + return (d1 + d2 + d3)/3; +} + +void lerPing() { + distancia = lerPingComMedia(); +} +void lerPingFull() { + servoH.write(30); + delay(200); + distanciaEsquerda = lerPingComMedia(); + servoH.write(100); + delay(200); + distancia = lerPingComMedia(); + servoH.write(150); + delay(200); + distanciaDireita = lerPingComMedia(); + servoH.write(85); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/DemoDefault/DemoDefault.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/DemoDefault/DemoDefault.pde new file mode 100644 index 0000000..9bcf736 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/DemoDefault/DemoDefault.pde @@ -0,0 +1,69 @@ +#include + + + +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +int leds[] = { + 13, 12, 8, 7, 4}; + +void setup() { + Serial.begin(9600); + for(int x=0;x<5;x++) { + pinMode(leds[x], OUTPUT); + } +} + + +void loop() { + + Serial.println("Sensor: "); + Serial.println(analogRead(SENSOR_LUZ)); + int numeroLedsALigar = map(analogRead(SENSOR_LUZ), 300, 900, 0, 4); + Serial.println(numeroLedsALigar); + for(int x=0;x<=numeroLedsALigar;x++) { + digitalWrite(leds[x], HIGH); + delay(100); + } + for(int x=numeroLedsALigar;x>-1;x--) { + digitalWrite(leds[x], LOW); + delay(100); + } +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/DemoDefault_Kernel/DemoDefault_Kernel.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/DemoDefault_Kernel/DemoDefault_Kernel.pde new file mode 100644 index 0000000..633d904 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/DemoDefault_Kernel/DemoDefault_Kernel.pde @@ -0,0 +1,104 @@ +#include + +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +int leds[] = { + 13, 12, 8, 7, 4}; + +void setup() { + Serial.begin(9600); + Kernel.setup(INTERRUPTION); + + Kernel.registerChangeModeListener(beep); + Kernel.registerMode("Modo 1", modo1_setup); + Kernel.registerTask(modo1_loop); + Kernel.registerMode("Modo 2", modo1_setup); + Kernel.registerTask(modo2_loop); + +} + +void beep() { + Serial.println("Mudou modo"); + pinMode(4, OUTPUT); + digitalWrite(4, HIGH); + delay(5); + digitalWrite(4, LOW); +} + +void modo1_setup() { + for(int x=0;x<5;x++) { + pinMode(leds[x], OUTPUT); + } +} + +void modo1_loop(){ + Serial.println("Sensor modo1 : "); + Serial.println(analogRead(SENSOR_LUZ)); + int numeroLedsALigar = map(analogRead(SENSOR_LUZ), 300, 900, 0, 4); + Serial.println(numeroLedsALigar); + + for(int x=0;x<=numeroLedsALigar;x++) { + digitalWrite(leds[x], HIGH); + Kernel.wait(100); + } + for(int x=numeroLedsALigar;x>-1;x--) { + digitalWrite(leds[x], LOW); + Kernel.wait(100); + } +} + +void modo2_loop(){ + Serial.println("Sensor modo 2: "); + Serial.println(analogRead(SENSOR_LUZ)); + int numeroLedsALigar = map(analogRead(SENSOR_LUZ), 300, 900, 0, 4); + Serial.println(numeroLedsALigar); + for(int x=numeroLedsALigar;x>=-1;x--) { + digitalWrite(leds[x], HIGH); + delay(100); + } + for(int x=0;x<=numeroLedsALigar;x++) { + digitalWrite(leds[x], LOW); + delay(100); + } +} + +void loop() { + Kernel.loop(); +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/ExemploServo/ExemploServo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/ExemploServo/ExemploServo.pde new file mode 100644 index 0000000..44f5baa --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/ExemploServo/ExemploServo.pde @@ -0,0 +1,22 @@ +#include + +Servo myservo1; // create servo object to control a servo + +void setup() +{ + myservo1.attach(5); // attaches the servo on pin 9 to the servo object + Serial.begin(9600); +} + +void loop() +{ + int distancia = analogRead(1); + Serial.println(distancia); + int posicaoServo = map(distancia, 10, 30, 1, 170); + myservo1.write(posicaoServo); + + + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/LCD_I2C/LCD_I2C.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/LCD_I2C/LCD_I2C.pde new file mode 100644 index 0000000..0173589 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/LCD_I2C/LCD_I2C.pde @@ -0,0 +1,16 @@ +#include +#include +LiquidCrystal_I2C lcd(0x27,16,2); + +void setup() { + lcd.init(); + lcd.backlight(); + lcd.setCursor(0, 1); + lcd.print("Program-ME v2"); + +} + + +void loop() {} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/MotorComPonteH/LibMotor.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/MotorComPonteH/LibMotor.ino new file mode 100644 index 0000000..6720533 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/MotorComPonteH/LibMotor.ino @@ -0,0 +1,92 @@ +int sentido=0; + +void setupMotor() { + pinMode(MOTOR1_A, OUTPUT); + pinMode(MOTOR1_B, OUTPUT); + pinMode(MOTOR2_A, OUTPUT); + pinMode(MOTOR2_B, OUTPUT); +} + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido1); + digitalWrite(MOTOR1_B,!sentido1); + digitalWrite(MOTOR2_A,!sentido1); + digitalWrite(MOTOR2_B,sentido1); + delay(tempo); +} + + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); + digitalWrite(MOTOR1_A,0); + digitalWrite(MOTOR1_B,0); + digitalWrite(MOTOR2_A,0); + digitalWrite(MOTOR2_B,0); + +} +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_A,!sentido); + digitalWrite(MOTOR1_B,sentido); + digitalWrite(MOTOR2_A,!sentido); + digitalWrite(MOTOR2_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,!sentido); + digitalWrite(MOTOR1_B,sentido); + digitalWrite(MOTOR2_A,!sentido); + digitalWrite(MOTOR2_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/MotorComPonteH/MotorComPonteH.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/MotorComPonteH/MotorComPonteH.ino new file mode 100644 index 0000000..e6e33c8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/MotorComPonteH/MotorComPonteH.ino @@ -0,0 +1,61 @@ +#include + +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +Servo servoV; +Servo servoH; + +void setup(){ + setupMotor(); + servoH.attach(5); + servoV.attach(6); + +} + +void loop() { + andarFrente(1000,2); + parar(); + andarTraz(1000,2); + parar(); + girarNoEixo(1000,2,0); + parar(); + girarNoEixo(1000,2,1); + parar(); + return; +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/MotoresPWM/MotoresPWM.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/MotoresPWM/MotoresPWM.pde new file mode 100644 index 0000000..9031897 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/MotoresPWM/MotoresPWM.pde @@ -0,0 +1,56 @@ +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +int leds[] = { + 13, 12, 8, 7, 4}; + +void setup() { + Serial.begin(9600); + for(int x=0;x<5;x++) { + pinMode(leds[x], OUTPUT); + } +} + + +void loop() { + int luz = analogRead(SENSOR_LUZ); + int val = map(luz, 700,1023,255, 0); + analogWrite(9, val); + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/PiscaLeds/PiscaLeds.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/PiscaLeds/PiscaLeds.pde new file mode 100644 index 0000000..1afb3aa --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/PiscaLeds/PiscaLeds.pde @@ -0,0 +1,18 @@ +int leds[] = { + 13, 12, 8, 7, 4}; + +void setup() { + Serial.begin(9600); + for(int x=0;x<5;x++) { + pinMode(leds[x], OUTPUT); + } +} + +void loop() { + for(int x=0;x<=4;x++) { + digitalWrite(leds[x], HIGH); + delay(100); + digitalWrite(leds[x], LOW); + delay(100); + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/Servo_LDR/Servo_LDR.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/Servo_LDR/Servo_LDR.pde new file mode 100644 index 0000000..aa8991d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2/Servo_LDR/Servo_LDR.pde @@ -0,0 +1,22 @@ +// Controlling a servo position using a potentiometer (variable resistor) +// by Michal Rinott + +#include + +Servo myservo; // create servo object to control a servo + +int potpin = 0; // analog pin used to connect the potentiometer +int val; // variable to read the value from the analog pin + +void setup() +{ + myservo.attach(5); // attaches the servo on pin 9 to the servo object +} + +void loop() +{ + val = analogRead(3); // reads the value of the potentiometer (value between 0 and 1023) + val = map(val, 700, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) + myservo.write(val); // sets the servo position according to the scaled value + delay(100); // waits for the servo to get there +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2_Luz/ProgramMEV2_Luz.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2_Luz/ProgramMEV2_Luz.pde new file mode 100644 index 0000000..66a1b9d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/ProgramMEV2_Luz/ProgramMEV2_Luz.pde @@ -0,0 +1,65 @@ +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +int leds[] = { + 13, 12, 8, 7, 4}; + +void setup() { + Serial.begin(9600); + for(int x=0;x<5;x++) { + pinMode(leds[x], OUTPUT); + } +} + + +void loop() { + + Serial.println("Sensor: "); + Serial.println(analogRead(SENSOR_LUZ)); + int numeroLedsALigar = map(analogRead(SENSOR_LUZ), 300, 900, 0, 4); + Serial.println(numeroLedsALigar); + for(int x=0;x<=numeroLedsALigar;x++) { + digitalWrite(leds[x], HIGH); + delay(100); + } + for(int x=numeroLedsALigar;x>-1;x--) { + digitalWrite(leds[x], LOW); + delay(100); + } +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/AHD_Serial1/AHD_Serial1.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/AHD_Serial1/AHD_Serial1.pde new file mode 100644 index 0000000..60140d3 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/AHD_Serial1/AHD_Serial1.pde @@ -0,0 +1,32 @@ +int leds[] = {14,1,2,3,4,5,8,6,13}; +int ledsStatus[9]; + +void setup() { + Serial.begin(9600); + for(int x=0;x<10;x++){ + ledsStatus[x]=0; + pinMode(leds[x], OUTPUT); + + } + +} + +void loop() { + if(Serial.available()>0) + { + lerSerial(); + } +} + +void lerSerial() { + while(Serial.available()>0) { + byte incoming = Serial.read(); + delay(20); + ledsStatus[incoming] = !ledsStatus[incoming]; + digitalWrite(leds[incoming], ledsStatus[incoming]); + + } +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ALM/ALM.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ALM/ALM.pde new file mode 100644 index 0000000..03e7715 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ALM/ALM.pde @@ -0,0 +1,16 @@ +void setup() { + Serial.begin(9600); + pinMode(7, OUTPUT); +} + +void loop() { + if(Serial.available() >0) { + byte incoming=Serial.read(); + if(incoming==65) { + digitalWrite(7, HIGH); + delay(5000); + digitalWrite(7, LOW); + } + } +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/ArduinoSunSpotV2.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/ArduinoSunSpotV2.pde new file mode 100644 index 0000000..cf12436 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/ArduinoSunSpotV2.pde @@ -0,0 +1,73 @@ +#include + +#define MOTOR1_P 4 +#define MOTOR1_N 5 +#define MOTOR1_PWM 11 + +#define MOTOR2_P 6 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 9 +#define SERVO_H 10 +#define SERVO_V 11 + +#define MODE_BUTTON 19 //5 anal�gica lida como digital... + +#define MODE_DEMO 2 +#define MODE_WALK 3 +#define MODE_SUNSPOT 1 +#define MODE_STOP 0 +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=0; +Servo servoHorizontal; // create servo object to control a servo +Servo servoVertical; // create servo object to control a servo + + +void setup() { + setupEngines(); + setupSunSpot(); + servoHorizontal.attach(SERVO_H); + //servoVertical.attach(SERVO_V); + Serial.begin(9600); +} + + +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + +} + +void loop(){ + + if(digitalRead(MODE_BUTTON)==0) { + while(digitalRead(MODE_BUTTON)==0); + mode++; + if(mode==4) mode=0; + } + if(mode==MODE_DEMO) { + Demo(); + } + else if(mode==MODE_WALK) { + Walk(); + } + else if(mode==MODE_SUNSPOT) { + SunSpot(); + } + +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/Demo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/Demo.pde new file mode 100644 index 0000000..3da8371 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/Demo.pde @@ -0,0 +1,195 @@ +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); +3145-2230 + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/SunSpot.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/SunSpot.pde new file mode 100644 index 0000000..9623884 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/SunSpot.pde @@ -0,0 +1,118 @@ +#define SUN_SPOT 8 +#define SUN_SPOT_ACK 12 +#define SUN_SPOT_INTERRUPT 0 //PORTA digital 2 + +volatile int data; +volatile boolean bit_array[16]; +volatile int contador; +int x; +int y; + +void SunSpot() { + if(x==0 && y==0) { + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + } + if(x==100 && y==100) { + digitalWrite(9, HIGH); + delay(500); + digitalWrite(9, LOW); + delay(200); + return; + } + if(x==101) { + changeServo(y); + delay(200); + return; + } + + if(y>0) sentido = 0; //Para FRENTE + else if(y<0) sentido = 1;// Para Traz + //Configurando o sentido do trem.. quero dizer do robot + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + if(y!=0 && x!=0) { //Curva frente ou traz... + int coeficientePotencia = map(x<0 ? x*-1 : x,0,30,0,255); + analogWrite(MOTOR1_PWM, x< 0 ? coeficientePotencia : coeficientePotencia/2); + analogWrite(MOTOR2_PWM, x< 0 ? coeficientePotencia/2 : coeficientePotencia); + } + else { //reto + analogWrite(MOTOR1_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + analogWrite(MOTOR2_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + } + //Girando no eixo + if(y==0 && x!=0) { + sentido = x<0; + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_N,sentido); + if(x>0) { + Serial.print("Girando x>0"); + Serial.println(map(x,0,30,40,255)); + analogWrite(MOTOR1_PWM, map(x,0,30,40,255) ); + analogWrite(MOTOR2_PWM , map(x,0,30,40,255) ); + } + else { + Serial.print("Girando <0"); + Serial.println(map(x>0 ? x : x*-1,0,30,40,255)); + + analogWrite(MOTOR2_PWM, map(x*-1,0,30,40,255) ); + analogWrite(MOTOR1_PWM, map(x*-1,0,30,40,255) ); + } + } + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + delay(200); +} +void setupSunSpot() { + attachInterrupt(0, receiveSunSpot, RISING); + pinMode(SUN_SPOT,INPUT); + pinMode(SUN_SPOT_ACK,OUTPUT); +} + +void receiveSunSpot() { + digitalWrite(SUN_SPOT_ACK,LOW); + bit_array[contador++]=digitalRead(SUN_SPOT); + digitalWrite(SUN_SPOT_ACK,HIGH); + if(contador==16) { + Serial.println("Chegou Novos 2 bytes"); + contador=0; + x = BtoI(0,7,bit_array); + + y = BtoI(8,15,bit_array); + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + for(int clean=0;clean<16;clean++) bit_array[clean]=false; + + } +} + +int BtoI(int start,int end, volatile boolean bits[]){ + boolean negative=bits[start]; + start++; + unsigned long integer=0; + unsigned long mask=1; + int r; + for (int i = end; i >= start; i--) { + if(negative) { + if (!bits[i]) integer |= mask; + } + else { + if (bits[i]) integer |= mask; + } + mask = mask << 1; + } + r = (int) integer; + if(negative) r= ~r; + return r; +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/Walk.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/Walk.pde new file mode 100644 index 0000000..b141bbe --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/Walk.pde @@ -0,0 +1,277 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServo(int servoPos) { + servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.cpp new file mode 100644 index 0000000..8c6a8f5 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.cpp @@ -0,0 +1,648 @@ +#include + +#define MOTOR1_P 4 +#define MOTOR1_N 5 +#define MOTOR1_PWM 11 + +#define MOTOR2_P 6 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 13 +#define SERVO_1 10 +#define MODE_BUTTON 19 //5 anal\u00f3gica lida como digital... + +#define MODE_DEMO 3 +#define MODE_WALK 2 +#define MODE_SUNSPOT 1 +#define MODE_STOP 0 +#include "WProgram.h" +void setup(); +void setupEngines(); +void loop(); +void Demo(); +void SunSpot(); +void setupSunSpot(); +void receiveSunSpot(); +int BtoI(int start,int end, volatile boolean bits[]); +void changeServo(int servoPos); +void fullScan(); +byte getLongestPosition(); +void partialScan(); +void Walk(); +void processPing(); +void girarNoEixo(int tempo, int intensidade, int sentido1); +void readPress(); +void parar(); +void andarFrente(int tempo, int intensidade); +void andarTraz(int tempo,int intensidade); +void virarEsquerda(int tempo,int intensidade); +void virarDireita(int tempo,int intensidade); +void readPing(); +long microsecondsToInches(long microseconds); +long microsecondsToCentimeters(long microseconds); +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=0; +Servo myservo10; // create servo object to control a servo + + +void setup() { + setupEngines(); + setupSunSpot(); + myservo10.attach(10); // attaches the servo on pin 10 to the servo object + Serial.begin(9600); +} +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void loop(){ + if(digitalRead(MODE_BUTTON)==0) { + while(digitalRead(MODE_BUTTON)==0); + mode++; + if(mode==4) mode=0; + } + if(mode==MODE_DEMO) { + Demo(); + } + else if(mode==MODE_WALK) { + Walk(); + } + else if(mode==MODE_SUNSPOT) { + SunSpot(); + } + +} + + + +/* + if(y>0) { + sentido = 1; + analogWrite(MOTOR1_PWM,(y == 10 ? 85 : y==20 ? 170 : 255)); + analogWrite(MOTOR2_PWM,(y == 10 ? 85 : y==20 ? 170 : 255)); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + } + else if(y<0){ //para traz + sentido = 0; + analogWrite(MOTOR1_PWM,(y == -10 ? 85 : y==-20 ? 170 : 255)); + analogWrite(MOTOR2_PWM,(y == -10 ? 85 : y==-20 ? 170 : 255)); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + } + */ + +/* + + + */ + + + +/* +1.5' 3.2' + C E Am + Fa\u00e7o c\u00f3digo como c\u00e3o;Maldito bug, que n\u00e3o encontro n\u00e3o; + 5.5' 8' com breque + Vem o prazo e o chef\u00e3o, o redeploy n\u00e3o da certo n\u00c3o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc\u00ea come\u00e7a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J\u00e1 estou penando aqui + 38' 41' + C E Am + Fa\u00e7o o download de um jar grand\u00e3o, mas tamb\u00e9m n\u00e3o 42' + funciona n\u00e3o + 43' 45' 48' + Chamo o arquiteto bacan\u00e3o, mas no fundo \u00e9 um man\u00e9z\u00e3o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N\u00e3o me sinto up-to-date, eu estou \u00e9 \u201cdeprecate\u201d + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa\u00e7o c\u00f3digo como c\u00e3o;Maldito bug, que n\u00e3o encontro n\u00e3o; + 5.5' 8' com breque + Vem o prazo e o chef\u00e3o, o redeploy n\u00e3o da certo n\u00c3o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc\u00ea come\u00e7a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb\u00e9m n\u00e3o funciona n\u00e3o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo \u00e9 um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + + +#define SUN_SPOT 8 +#define SUN_SPOT_ACK 12 +#define SUN_SPOT_INTERRUPT 0 //PORTA digital 2 + +volatile int data; +volatile boolean bit_array[16]; +volatile int contador; +int x; +int y; + +void SunSpot() { + if(x==0 && y==0) { + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + } + if(y>0) sentido = 0; //Para FRENTE + else if(y<0) sentido = 1;// Para Traz + //Configurando o sentido do trem.. quero dizer do robot + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + if(y!=0 && x!=0) { //Curva frente ou traz... + int coeficientePotencia = map(x<0 ? x*-1 : x,0,30,0,255); + analogWrite(MOTOR1_PWM, x< 0 ? coeficientePotencia : coeficientePotencia/2); + analogWrite(MOTOR2_PWM, x< 0 ? coeficientePotencia/2 : coeficientePotencia); + } + else { //reto + analogWrite(MOTOR1_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + analogWrite(MOTOR2_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + } + //Girando no eixo + if(y==0 && x!=0) { + sentido = x<0; + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_N,sentido); + if(x>0) { + Serial.print("Girando x>0"); + Serial.println(map(x,0,30,40,255)); + analogWrite(MOTOR1_PWM, map(x,0,30,40,255) ); + analogWrite(MOTOR2_PWM , map(x,0,30,40,255) ); + } + else { + Serial.print("Girando <0"); + Serial.println(map(x>0 ? x : x*-1,0,30,40,255)); + + analogWrite(MOTOR2_PWM, map(x*-1,0,30,40,255) ); + analogWrite(MOTOR1_PWM, map(x*-1,0,30,40,255) ); + } + } + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + delay(200); +} +void setupSunSpot() { + attachInterrupt(0, receiveSunSpot, RISING); + pinMode(SUN_SPOT,INPUT); + pinMode(SUN_SPOT_ACK,OUTPUT); +} + +void receiveSunSpot() { + digitalWrite(SUN_SPOT_ACK,LOW); + bit_array[contador++]=digitalRead(SUN_SPOT); + digitalWrite(SUN_SPOT_ACK,HIGH); + if(contador==16) { + Serial.println("Chegou Novos 2 bytes"); + contador=0; + x = BtoI(0,7,bit_array); + + y = BtoI(8,15,bit_array); + + for(int clean=0;clean<16;clean++) bit_array[clean]=false; + + } +} + +int BtoI(int start,int end, volatile boolean bits[]){ + boolean negative=bits[start]; + start++; + unsigned long integer=0; + unsigned long mask=1; + int r; + for (int i = end; i >= start; i--) { + if(negative) { + if (!bits[i]) integer |= mask; + } + else { + if (bits[i]) integer |= mask; + } + mask = mask << 1; + } + r = (int) integer; + if(negative) r= ~r; + return r; +} + +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int move_count = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + readPing(); + processPing(); + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,50*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.cpp.o new file mode 100644 index 0000000..1b1deed Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.elf new file mode 100644 index 0000000..ce28498 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.hex new file mode 100644 index 0000000..8d91bec --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.hex @@ -0,0 +1,560 @@ +:100000000C9463000C942C0D0C94590D0C948B00E3 +:100010000C948B000C948B000C948B000C948B0034 +:100020000C948B000C948B000C948B000C948B0024 +:100030000C948B000C948B000C948B000C948B0014 +:100040000C94860D0C948B000C94050B0C948B0077 +:100050000C948B000C948B000C948B000C948B00F4 +:100060000C948B000C948B000000000024002700EF +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000E901BE0B11241FBECFEFD4E0DEBF5C +:1000D000CDBF11E0A0E0B1E0E2E9F2E202C005909C +:1000E0000D92AC34B107D9F712E0ACE4B1E001C035 +:1000F0001D92A032B107E1F710E0C6ECD0E004C0D9 +:100100002297FE010E940C11C23CD107C9F70E9440 +:10011000FE0A0C9447110C940000A0E0B0E0E3E963 +:10012000F0E00C941811EC01A880B980CA80DB8043 +:10013000A114B104C104D10441F484E2A82E89EDD4 +:10014000B82E8BE5C82E87E0D82EC601B5012DE16B +:1001500033EF41E050E00E94DB1027EA31E440E059 +:1001600050E00E9487107B018C01C601B5012DE192 +:1001700033EF41E050E00E94DB10CA01B9012CEEE0 +:1001800034EF4FEF5FEF0E9487106E0D7F1D801FD1 +:10019000911F97FF04C06150704080409048688371 +:1001A00079838A839B839B01AC015F77B901CA0184 +:1001B000CDB7DEB7EAE00C9434110E948D000895AB +:1001C00081E491E00E948D00089560934101709355 +:1001D000420180934301909344010895FC011082F1 +:1001E0008FEF81830895EF92FF920F931F93CF9328 +:1001F000DF93EC019B0177FF03C020E030E005C0F6 +:10020000653B710514F024EB30E02983EA806B81B3 +:1002100070E06E197109882777FD8095982F982FC7 +:10022000872F762F662730E040E050E00E9487104D +:1002300024EB30E040E050E00E94DB10FF2400E0BF +:1002400010E0102F0F2DFE2CEE24E20EF31E041FE3 +:10025000151FC801B70128E030E040E050E00E94DF +:10026000DB108881893029F430938900209388003D +:1002700006C08A3021F430938B0020938A00DF91EE +:10028000CF911F910F91FF90EF900895CF93DF933F +:10029000EC01FB01CB010997029710F080E054C0FC +:1002A000CA0160E170E00E94A6106A83C90160E1A2 +:1002B00070E00E94A6106B83E8838FEF89838E2FF6 +:1002C00060E00E94E10E888161E00E94C10E809191 +:1002D0004C01882311F580914D018823F1F42FB74B +:1002E000F89482E0809380008AE18093810088EB1B +:1002F0009BE0909389008093880090938B0080937B +:100300008A0080E49CE99093870080938600809126 +:100310006F00887F80936F002FBF8881893041F400 +:1003200081E080934C01809180008F73806809C0C8 +:100330008A3049F481E080934D01809180008F7C68 +:1003400080628093800081E0DF91CF91089540E248 +:1003500052E020E639E00E9446010895EF92FF92B4 +:100360000F931F93CF93DF93EC01FA01E80FF91F6E +:10037000E081DA01A60FB71F20E030E040E050E056 +:1003800091E0E92EF12C012D112D14C0EE2321F066 +:100390008C91882341F403C08C91882321F02E296D +:1003A0003F29402B512BEE0CFF1C001F111F6150E9 +:1003B00070401197C617D7074CF3EE2311F0209524 +:1003C0003095C901DF91CF911F910F91FF90EF9070 +:1003D00008958EE591E00E94EE00089584E061E0CA +:1003E0000E94C10E85E061E00E94C10E86E061E0DE +:1003F0000E94C10E87E061E00E94C10E8BE061E0C7 +:100400000E94C10E83E061E00E94C10E0895EF9248 +:10041000FF920F931F938DE061E00E94C10E8DE06B +:1004200060E00E94E10E82E090E00E94200E8DE0EC +:1004300061E00E94E10E85E090E00E94200E8DE0D8 +:1004400060E00E94E10E8DE060E00E94C10E8DE050 +:1004500061E020E432E44FE050E00E947D0F162F6F +:10046000072FF82EE92E609350017093510180936D +:1004700052019093530124E930E040E050E00E94A3 +:10048000DB10209354013093550140935601509353 +:100490005701612F702F8F2D9E2D2AE330E040E011 +:1004A00050E00E94DB10BA012093580130935901AB +:1004B00040935A0170935B018EEF91E0A9010E9475 +:1004C000EE0C1F910F91FF90EF9008958BE060E08C +:1004D00070E00E94680E83E060E070E00E94680EA9 +:1004E00008950F931F93CF93DF93EC018B01660F59 +:1004F000771FC80123E0880F991F2A95E1F7680F3D +:10050000791F8BE00E94680E82E390E0089FB001A3 +:10051000099F700D189F700D112483E00E94680ED2 +:1005200084E060914E010E94E10E60E080914E01F6 +:1005300090914F01892B09F461E085E00E94E10E62 +:1005400086E060914E010E94E10E60E080914E01D4 +:1005500090914F01892B09F461E087E00E94E10E40 +:10056000BE01882777FD8095982F0E94F60DDF91B8 +:10057000CF911F910F9108950F931F93CF93DF9306 +:10058000EC0182E390E0689F8001699F100D789FE5 +:10059000100D11248BE0B8010E94680E83E0B801B1 +:1005A0000E94680E84E060914E010E94E10E60E0BE +:1005B00080914E0190914F01892B09F461E085E013 +:1005C0000E94E10E86E060914E010E94E10E60E023 +:1005D00080914E0190914F01892B09F461E087E0F1 +:1005E0000E94E10EBE01882777FD8095982F0E941A +:1005F000F60DDF91CF911F910F9108950F931F93E7 +:10060000CF93DF93EC0181E090E090934F018093D2 +:100610004E0182E390E0689F8001699F100D789FF2 +:10062000100D11248BE0B8010E94680E83E0B80120 +:100630000E94680E84E060914E010E94E10E60E02D +:1006400080914E0190914F01892B09F461E085E082 +:100650000E94E10E86E060914E010E94E10E60E092 +:1006600080914E0190914F01892B09F461E087E060 +:100670000E94E10EBE01882777FD8095982F0E9489 +:10068000F60DDF91CF911F910F9108950F931F9356 +:10069000CF93DF93EC0110924F0110924E0182E351 +:1006A00090E0689F8001699F100D789F100D1124C4 +:1006B0008BE0B8010E94680E83E0B8010E94680ECA +:1006C00084E060914E010E94E10E60E080914E0155 +:1006D00090914F01892B09F461E085E00E94E10EC1 +:1006E00086E060914E010E94E10E60E080914E0133 +:1006F00090914F01892B09F461E087E00E94E10E9F +:10070000BE01882777FD8095982F0E94F60DDF9116 +:10071000CF911F910F910895EF92FF920F931F9326 +:10072000CF93DF93EC017A0182E390E0689F800130 +:10073000699F100D789F100D11248BE0B8010E9465 +:10074000680E83E0B8010E94680E1E2D84E06E2DB5 +:100750000E94E10E00E0EF2809F401E085E0602F3F +:100760000E94E10E86E0602F0E94E10E87E0612F7B +:100770000E94E10EBE01882777FD8095982F0E9488 +:10078000F60DDF91CF911F910F91FF90EF9008959B +:10079000EF92FF920F931F93CF93DF932091580115 +:1007A0003091590140915A0150915B01243131053A +:1007B000410551050CF099C0109279011092780111 +:1007C0000E946602C0E0D0E08091580190915901EA +:1007D000A0915A01B0915B014497A105B1050CF0BD +:1007E00064C1CA30D10511F1219668EC70E080E057 +:1007F00090E024EF31E040E050E00E9469107B017E +:100800008C0160E070E080E090E021E030E040E0CA +:1008100050E00E9469109B01AC01C70163E070E0E9 +:10082000A9010E948C030E940702CECF81E090E0D4 +:1008300063E070E00E94FE0260E070E080E090E023 +:1008400021E030E040E050E00E9469106115710540 +:100850008105910529F168EC70E080E090E020E9E5 +:1008600031E040E050E00E9469109B01AC0164EF70 +:1008700071E080E090E00E9469107B018C0162E0F1 +:1008800070E080E090E024E030E040E050E00E9442 +:1008900069109B01AC01C701B9010E94710205C139 +:1008A00068EC70E080E090E020E931E040E050E06A +:1008B0000E9469109B01AC0164EF71E080E090E060 +:1008C0000E9469107B018C0162E070E080E090E0A2 +:1008D00024E030E040E050E00E9469109B01AC0150 +:1008E000C701B9010E94BC02E0C0DA01C901459705 +:1008F000A109B1094897A105B10508F0B3C060E0AE +:1009000070E080E090E021E030E040E050E00E94C4 +:100910006910611571058105910509F454C062E300 +:1009200070E080E090E028E730E040E050E00E9496 +:1009300069107B018C0162E070E080E090E024E0CF +:1009400030E040E050E00E9469109B01AC01C7011B +:10095000B9010E947102C0915801D09159010E94C1 +:1009600007029E01442737FD4095542F809158017E +:1009700090915901A0915A01B0915B012817390754 +:100980004A075B076CF091C082E390E062E070E0A0 +:100990000E947102C0915801D09159010E94070232 +:1009A0009E01442737FD4095542F80915801909126 +:1009B0005901A0915A01B0915B01281739074A07E4 +:1009C0005B0714F372C062E370E080E090E028E718 +:1009D00030E040E050E00E9469107B018C0162E051 +:1009E00070E080E090E024E030E040E050E00E94E1 +:1009F00069109B01AC01C701B9010E94BC022091A2 +:100A000058013091590140915A0150915B01E9011F +:100A1000C901AA2797FDA095BA2F82179307A407AB +:100A2000B5076CF042C082E390E062E070E00E94A3 +:100A3000BC02C0915801D09159010E9407029E0149 +:100A4000442737FD4095542F8091580190915901CA +:100A5000A0915A01B0915B01281739074A075B073B +:100A600014F323C0809178019091790101969093BD +:100A700079018093780124363105410551051CF434 +:100A800062E070E00EC025563040404050402133B7 +:100A900031054105510518F064E070E002C063E0E3 +:100AA00070E082E390E00E9446038091780190918B +:100AB00079014F970CF46CC0109279011092780173 +:100AC00066E970E080E090E022EC31E040E050E048 +:100AD0000E946910DC01CB0163E070E00E94FE021D +:100AE00060E070E080E090E021E030E040E050E045 +:100AF0000E946910611571058105910529F168EC65 +:100B000070E080E090E020E931E040E050E00E94B9 +:100B100069109B01AC0166E970E080E090E00E9402 +:100B200069107B018C0162E070E080E090E024E0DD +:100B300030E040E050E00E9469109B01AC01C70129 +:100B4000B9010E94710224C068EC70E080E090E07E +:100B500020E931E040E050E00E9469109B01AC01C7 +:100B600066E970E080E090E00E9469107B018C01F2 +:100B700062E070E080E090E024E030E040E050E0AF +:100B80000E9469109B01AC01C701B9010E94BC021F +:100B9000DF91CF911F910F91FF90EF9008950E94E8 +:100BA00007020E94C8030895BC018EE591E00E94EF +:100BB000F3006FE070E080E090E00E94F60D089591 +:100BC0006CED75E080E090E00E94F60D84EA96E01E +:100BD00064E070E00E9446038CEF98E064E070E00F +:100BE0000E94FE0280ED97E063E070E041E050E09B +:100BF0000E948C038CED95E064E070E00E94FE02A0 +:100C00000E9466026CED75E080E090E00E94F60DB7 +:100C100084EB90E00E94D40568EE73E080E090E001 +:100C20000E94F60D8AE590E00E94D40568EE73E01C +:100C300080E090E00E94F60D80E090E00E94D405F4 +:100C400068EE73E080E090E00E94F60D8AE590E0A7 +:100C50000E94D40580ED97E064E070E00E944603B6 +:100C60000E94660284EB90E00E94D40568EE73E077 +:100C700080E090E00E94F60D80E090E00E94D405B4 +:100C800068EE73E080E090E00E94F60D8AE590E067 +:100C90000E94D40568EE73E080E090E00E94F60DBB +:100CA00088EB9BE063E070E041E050E00E948C0341 +:100CB0000E94660288EB9BE063E070E040E050E059 +:100CC0000E948C030E94660284EB90E00E94D4058F +:100CD00068EE73E080E090E00E94F60D8AE590E017 +:100CE0000E94D40568EE73E080E090E00E94F60D6B +:100CF00080E090E00E94D4058AE590E00E94D4054F +:100D000088EB9BE063E070E041E050E00E948C03E0 +:100D10000E94660288EB9BE063E070E040E050E0F8 +:100D20000E948C030E94660284EB90E00E94D4052E +:100D300064EF71E080E090E00E94F60D8AE590E0BB +:100D40000E94D40564EF71E080E090E00E94F60D0F +:100D500080E090E00E94D40568EE73E080E090E0CF +:100D60000E94F60D80ED97E063E070E00E9446037C +:100D70000E94660284EB90E00E94D40564EF71E06B +:100D800080E090E00E94F60D8AE590E00E94D40594 +:100D900064EF71E080E090E00E94F60D80E090E06A +:100DA0000E94D4056CED75E080E090E00E94F60DA5 +:100DB00084EA96E064E070E00E9446038CEF98E0DD +:100DC00064E070E00E94FE0280ED97E063E070E076 +:100DD00041E050E00E948C0380ED97E064E070E019 +:100DE0000E94FE020E94660260ED77E080E090E0E3 +:100DF0000E94F60D80ED97E063E070E040E050E087 +:100E00000E948C0384EB90E00E94D40568EE73E0AE +:100E100080E090E00E94F60D8AE590E00E94D40503 +:100E200068EE73E080E090E00E94F60D80E090E0D4 +:100E30000E94D40568EE73E080E090E00E94F60D19 +:100E40008AE590E00E94D40580ED97E063E070E0D1 +:100E500041E050E00E948C0384EB90E00E94D405B6 +:100E600064EF71E080E090E00E94F60D80E090E099 +:100E70000E94D40564EF71E080E090E00E94F60DDE +:100E80008AE590E00E94D40568EE73E080E090E08F +:100E90000E94F60D88EB9BE063E070E041E050E0DB +:100EA0000E948C030E94660288EB9BE063E070E086 +:100EB00040E050E00E948C030E94660284EB90E0C8 +:100EC0000E94D40568EE73E080E090E00E94F60D89 +:100ED0008AE590E00E94D40568EE73E080E090E03F +:100EE0000E94F60D80E090E00E94D4058AE590E033 +:100EF0000E94D40588EB9BE063E070E041E050E0A5 +:100F00000E948C030E94660288EB9BE063E070E025 +:100F100040E050E00E948C030E94660284EB90E067 +:100F20000E94D40564EF71E080E090E00E94F60D2D +:100F30008AE590E00E94D40564EF71E080E090E0E3 +:100F40000E94F60D80E090E00E94D40568EE73E008 +:100F500080E090E00E94F60D80ED97E063E070E0A5 +:100F60000E9446030E94660280ED97E063E070E015 +:100F70000E94FE020E94660284EB90E00E94D4056B +:100F800064EF71E080E090E00E94F60D8AE590E069 +:100F90000E94D40564EF71E080E090E00E94F60DBD +:100FA00080E090E00E94D40564EF71E080E090E082 +:100FB0000E94F60D8AE590E00E94D40560E072EC94 +:100FC0008BEE9BE00E94F60D08950F931F938CE02B +:100FD00060E00E94E10E009172011091730188E0BF +:100FE0000E942E0FF801EE59FE4F80830F5F1F4FB6 +:100FF00010937301009372018CE061E00E94E10E96 +:101000008091720190917301409761F58EEF91E0AC +:101010006BE071E00E94240C109273011092720137 +:1010200080E090E067E070E042E651E00E94AE01AF +:10103000909375018093740188E090E06FE070E018 +:1010400042E651E00E94AE019093770180937601D1 +:1010500080E090E0FC01EE59FE4F10820196803155 +:101060009105C1F71F910F91089580E065EE77E03B +:1010700043E050E00E94090D88E060E00E94C10E4C +:101080008CE061E00E94C10E08956F927F928F9272 +:101090009F92AF92BF92CF92DF92EF92FF920F9307 +:1010A0001F938091740190917501892B81F4809137 +:1010B000760190917701892B51F48BE060E070E02C +:1010C0000E94680E83E060E070E00E94680E8091EC +:1010D000760190917701181619062CF410924F01A1 +:1010E00010924E0108C0892B31F081E090E090937E +:1010F0004F0180934E0184E060914E010E94E10E09 +:1011000060E080914E0190914F01892B09F461E0DC +:1011100085E00E94E10E86E060914E010E94E10EA2 +:1011200060E080914E0190914F01892B09F461E0BC +:1011300087E00E94E10E80917601909177010097FF +:1011400009F454C0609174017091750161157105C5 +:1011500009F44CC000D000D0EDB7FEB731969B012A +:1011600077FF03C0309521953F4FB901882777FD60 +:101170008095982F2FEF30E040E050E020833183BE +:101180004283538320E030E040E050E0AEE1EA2EBD +:10119000F12C012D112DAA24BB2465010E94FE0F04 +:1011A000162F072F0F900F900F900F9080917401C2 +:1011B0009091750199232CF0CB0162E070E00E94C0 +:1011C000A6108BE00E94680E8091740190917501C9 +:1011D00097FF08C0812F902F62E070E00E94A61058 +:1011E000162F072F83E0612F702F61C000D000D031 +:1011F000EDB7FEB731969C0197FF03C0309521955E +:101200003F4FB901882777FD8095982F2FEF30E069 +:1012100040E050E0208331834283538320E030E07C +:1012200040E050E0FEE1EF2EF12C012D112DAA241B +:10123000BB2465010E94FE0F9B01AC010F900F9033 +:101240000F900F908BE0B9010E94680E00D000D083 +:10125000EDB7FEB73196209176013091770137FFD7 +:1012600003C0309521953F4FB901882777FD8095C0 +:10127000982F2FEF30E040E050E02083318342830D +:10128000538320E030E040E050E0EEE1EE2EF12C20 +:10129000012D112DAA24BB2465010E94FE0F9B0184 +:1012A000AC010F900F900F900F9083E0B9010E9456 +:1012B000680E8091760190917701892B09F02EC1FB +:1012C0008091740190917501009709F427C1692FED +:1012D000772767FD70956627770F661F77277093CE +:1012E0004F0160934E0184E00E94E10E60E0809126 +:1012F0004E0190914F01892B09F461E086E00E9434 +:10130000E10E60E080914E0190914F01892B09F42C +:1013100061E085E00E94E10E87E060914E010E944D +:10132000E10E8091740190917501181619060CF068 +:1013300073C08EEF91E060E271E00E94F50B00D087 +:1013400000D06091740170917501882777FD8095B8 +:10135000982F0FEF602E712C812C912CEDB7FEB7DA +:10136000618272828382948220E030E040E050E02B +:101370001EE1E12EF12C012D112DB8E2AB2EB12C86 +:10138000C12CD12C0E94FE0FAB01BC010F900F901D +:101390000F900F908EEF91E00E94EE0C00D000D0E5 +:1013A0006091740170917501882777FD8095982F61 +:1013B000EDB7FEB7618272828382948220E030E0D2 +:1013C00040E050E00E94FE0F9B01AC010F900F9097 +:1013D0000F900F908BE0B9010E94680E00D000D0F2 +:1013E0006091740170917501882777FD8095982F21 +:1013F000EDB7FEB7618272828382948220E030E092 +:1014000040E050E00E94FE0F9B01AC010F900F9056 +:101410000F900F9083E07FC08EEF91E06CE271E05F +:101420000E94F50B00D000D0EDB7FEB731962091A9 +:1014300074013091750137FF03C0309521953F4FFE +:10144000B901882777FD8095982FAFEF6A2E712C10 +:10145000812C912C608271828282938220E030E024 +:1014600040E050E0FEE1EF2EF12C012D112DE8E2DD +:10147000AE2EB12CC12CD12C0E94FE0FAB01BC01B1 +:101480000F900F900F900F908EEF91E00E94EE0C56 +:1014900000D000D0609174017091750170956195D4 +:1014A0007F4F882777FD8095982FEDB7FEB7618233 +:1014B00072828382948220E030E040E050E00E941B +:1014C000FE0F9B01AC010F900F900F900F9083E0E7 +:1014D000B9010E94680E00D000D060917401709133 +:1014E0007501709561957F4F882777FD8095982FBE +:1014F000EDB7FEB7618272828382948220E030E091 +:1015000040E050E00E94FE0F9B01AC010F900F9055 +:101510000F900F908BE0B9010E94680E8EEF91E062 +:1015200067E371E00E94F50B6091740170917501A1 +:101530008EEF91E00E94F90C8EEF91E06CE371E088 +:101540000E94F50B60917601709177018EEF91E02A +:101550000E94F90C68EC70E080E090E00E94F60DCB +:101560001F910F91FF90EF90DF90CF90BF90AF90C1 +:101570009F908F907F906F90089583E10E942E0F2F +:10158000892BA1F483E10E942E0F892BD9F380913E +:101590005C0190915D01019690935D0180935C01E7 +:1015A000049721F410925D0110925C0180915C011E +:1015B00090915D018330910519F40E94E005089532 +:1015C0008230910519F40E94CF050895019711F416 +:1015D0000E94450808950E94EE010E9435088EE59C +:1015E00091E06AE070E00E94A7018EEF91E040E890 +:1015F00055E260E070E00E94420B08950E942E0EBA +:101600000E94EB0A0E94BD0AFDCF1F920F920FB6F7 +:101610000F9211242F933F934F935F936F937F9378 +:101620008F939F93AF93BF93EF93FF934091C60027 +:10163000E091FA01F091FB01CF01019660E870E0C2 +:101640000E94A6109C018091FC019091FD01281739 +:10165000390739F0E658FE4F40833093FB01209361 +:10166000FA01FF91EF91BF91AF919F918F917F917F +:101670006F915F914F913F912F910F900FBE0F90FF +:101680001F901895AF92BF92CF92DF92EF92FF9288 +:101690000F931F93CF93DF936C017A018B01DC01D1 +:1016A0001496AD90BC901597CB01BA0122E030E0C2 +:1016B00040E050E00E94DB10205C3D4B404F5F4F0C +:1016C000CA01B901A80197010E94DB10C901DA0122 +:1016D0000197A109B109292F3A2F4B2F552747FD13 +:1016E0005A950196A11DB11DE5012883E601EE8101 +:1016F000FF8181508083EA85FB85208141E050E0B5 +:10170000CA010E8402C0880F991F0A94E2F7282BA1 +:101710002083EA85FB852081CA010F8402C0880FDF +:10172000991F0A94E2F7282B2083EA85FB858081A4 +:10173000088802C0440F551F0A94E2F7842B808367 +:10174000DF91CF911F910F91FF90EF90DF90CF909D +:10175000BF90AF900895FC01A085B18521898C913F +:1017600090E0022E02C0959587950A94E2F780FFDB +:10177000F6CF0484F585E02D6083089589E491E037 +:101780009093FF018093FE018AE791E0909301021C +:101790008093000285EC90E0909303028093020214 +:1017A00084EC90E0909305028093040280EC90E03A +:1017B000909307028093060281EC90E090930902D7 +:1017C0008093080286EC90E090930B0280930A02CB +:1017D00084E080930C0283E080930D0287E0809385 +:1017E0000E0285E080930F0208950F931F93CF930D +:1017F000DF938C01EB0109C02196D801ED91FC919A +:101800000190F081E02DC801099568816623A1F758 +:10181000DF91CF911F910F9108950F931F938C012A +:10182000DC01ED91FC910190F081E02D6DE00995D6 +:10183000D801ED91FC910190F081E02DC8016AE0A2 +:1018400009951F910F9108950F931F938C010E948A +:10185000F50BC8010E940D0C1F910F9108952F9256 +:101860003F924F925F926F927F928F929F92AF9230 +:10187000BF92CF92DF92EF92FF920F931F93DF936D +:10188000CF93CDB7DEB7A0970FB6F894DEBF0FBEEB +:10189000CDBF1C016A017B01411551056105710530 +:1018A00049F4DC01ED91FC910190F081E02D60E3C1 +:1018B000099554C0882499245401422E5524662445 +:1018C000772401E010E00C0F1D1F080D191DC70142 +:1018D000B601A30192010E94B910F8016083089437 +:1018E000811C911CA11CB11CC701B601A30192016E +:1018F0000E94B910C901DA016C017D01C114D10443 +:10190000E104F104F1F681E0E82EF12CEC0EFD1E6D +:10191000E80CF91C3E010894611C711CD501C4013E +:101920000197A109B1096C01C818D90814C0F601C2 +:10193000EE0DFF1D60816A3010F4605D01C0695CCE +:10194000D101ED91FC910190F081E02DC10109954B +:101950000894E108F1086E147F0449F7A0960FB6C9 +:10196000F894DEBF0FBECDBFCF91DF911F910F91D5 +:10197000FF90EF90DF90CF90BF90AF909F908F90AF +:101980007F906F905F904F903F902F900895EF92CF +:10199000FF920F931F93CF93DF93EC017A018B019A +:1019A00077FF0FC0E881F9810190F081E02D6DE2B1 +:1019B000099510950095F094E094E11CF11C011D2F +:1019C000111DCE01B801A7012AE00E942F0CDF9162 +:1019D000CF911F910F91FF90EF9008950F931F9358 +:1019E0008C010E94C70CC8010E940D0C1F910F9121 +:1019F00008950F931F938C01AB01662757FD6095E7 +:101A0000762F0E94C70CC8010E940D0C1F910F91E8 +:101A10000895823000F5E82FF0E0EE0FFF1FE05F41 +:101A2000FD4F71836083882319F08130A1F408C0D1 +:101A3000809169008C7F842B80936900E89A0895D7 +:101A400080916900440F551F440F551F837F842BDD +:101A500080936900E99A08951F920F920FB60F9232 +:101A600011242F933F934F935F936F937F938F93A3 +:101A70009F93AF93BF93EF93FF9380911002909148 +:101A80001102892B29F0E0911002F09111020995C1 +:101A9000FF91EF91BF91AF919F918F917F916F9146 +:101AA0005F914F913F912F910F900FBE0F901F901C +:101AB00018951F920F920FB60F9211242F933F93F8 +:101AC0004F935F936F937F938F939F93AF93BF9346 +:101AD000EF93FF938091120290911302892B29F0CA +:101AE000E0911202F09113020995FF91EF91BF91DD +:101AF000AF919F918F917F916F915F914F913F91A6 +:101B00002F910F900FBE0F901F9018951F920F925C +:101B10000FB60F9211242F938F939F93AF93BF9380 +:101B20008091140290911502A0911602B0911702B3 +:101B30000196A11DB11D8093140290931502A093EC +:101B40001602B09317028091180290911902A09189 +:101B50001A02B0911B028050904CAF4FBF4F809340 +:101B6000180290931902A0931A02B0931B0227C087 +:101B70008091180290911902A0911A02B0911B0253 +:101B800080589E43A040B040809318029093190261 +:101B9000A0931A02B0931B0280911C0290911D0227 +:101BA000A0911E02B0911F020196A11DB11D80934C +:101BB0001C0290931D02A0931E02B0931F028091FD +:101BC000180290911902A0911A02B0911B0281583B +:101BD0009E43A040B04060F6BF91AF919F918F911E +:101BE0002F910F900FBE0F901F901895EF92FF92BC +:101BF0000F931F937B018C018FB7F89440911C02C7 +:101C000050911D0260911E0270911F028FBF2FB76D +:101C1000F89480911C0290911D02A0911E02B09137 +:101C20001F022FBF841B950BA60BB70BE816F906F6 +:101C30000A071B0760F71F910F91FF90EF9008951F +:101C4000019759F0FC01EE0FFF1FEE0FFF1F3297B7 +:101C50008FB7F8943197F1F78FBF0895789484B5D2 +:101C6000826084BD84B5816084BD85B5826085BD98 +:101C700085B5816085BDEEE6F0E08081816080837E +:101C8000E1E8F0E0808182608083808181608083F0 +:101C9000E0E8F0E0808181608083E1EBF0E080812A +:101CA00084608083E0EBF0E0808181608083EAE7FC +:101CB000F0E0808184608083808182608083808185 +:101CC000816080838081806880831092C100089544 +:101CD0001F93CF93DF93182FEB0161E00E94C10E99 +:101CE000E12FF0E0E255FF4F8491833051F4809171 +:101CF0008000806880938000D0938900C093880022 +:101D00003CC0843051F480918000806280938000D8 +:101D1000D0938B00C0938A0030C0813039F4209773 +:101D200029F184B5806884BDC7BD27C0823039F4ED +:101D30002097E1F084B5806284BDC8BD1EC08630A6 +:101D400041F48091B00080688093B000C093B300EC +:101D500014C0873041F48091B00080628093B0005D +:101D6000C093B4000AC0C038D1051CF4812F60E0D4 +:101D700002C0812F61E00E94E10EDF91CF911F919F +:101D80000895282F30E0C90186569F4FFC01949199 +:101D90002A573F4FF9018491882391F0E82FF0E012 +:101DA000EE0FFF1FE859FF4FA591B491662329F468 +:101DB0008C91909589238C9308958C91892B8C9389 +:101DC0000895482F50E0CA0182559F4FFC0124918D +:101DD000CA0186569F4FFC0194914A575F4FFA0102 +:101DE00034913323D1F1222331F1233021F4809136 +:101DF00080008F7705C0243031F4809180008F7D82 +:101E00008093800018C0213019F484B58F7704C006 +:101E1000223021F484B58F7D84BD0DC0263021F49D +:101E20008091B0008F7705C0273029F48091B000F1 +:101E30008F7D8093B000E32FF0E0EE0FFF1FEE5890 +:101E4000FF4FA591B491662329F48C919095892335 +:101E50008C9308958C91892B8C930895682F70E052 +:101E6000CB0182559F4FFC012491CB0186569F4F99 +:101E7000FC0144916A577F4FFB019491992319F417 +:101E800020E030E038C0222331F1233021F480916A +:101E900080008F7705C0243031F4809180008F7DE1 +:101EA0008093800018C0213019F484B58F7704C066 +:101EB000223021F484B58F7D84BD0DC0263021F4FD +:101EC0008091B0008F7705C0273029F48091B00051 +:101ED0008F7D8093B000892F90E0880F991F8458E0 +:101EE0009F4FFC01A591B4918C9120E030E08423B8 +:101EF00011F021E030E0C9010895DF92EF92FF92E6 +:101F00000F931F93A82FB0E0CD0186569F4FFC0181 +:101F1000D490AA57BF4FFD018491662311F490E03D +:101F200001C09D2D6FEFE62E6FEFF62E6FEF062F9F +:101F30006FE0162FE222F32204231523682F70E0AE +:101F4000660F771F64587F4F20E030E040E050E09C +:101F5000FB01A591B4910AC02E153F05400751071A +:101F600009F440C02F5F3F4F4F4F5F4F8C918D2141 +:101F7000891791F30AC02E153F054007510791F1CB +:101F80002F5F3F4F4F4F5F4F03C0FB01A591B491AF +:101F90008C918D21891779F720E030E040E050E006 +:101FA000FB01A591B49104C02F5F3F4F4F4F5F4F8E +:101FB0008C918D218917C1F3CA01B9012AE030E063 +:101FC00040E050E00E9487109B01AC01205F3F4F32 +:101FD0004F4F5F4F84E056954795379527958A95E3 +:101FE000D1F704C020E030E040E050E0B901CA0180 +:101FF0001F910F91FF90EF90DF9008952F923F92E5 +:102000004F925F926F927F928F929F92AF92BF9208 +:10201000CF92DF92EF92FF920F931F93DF93CF93B4 +:10202000CDB7DEB73B014C0119012A016D897E89CC +:102030008F89988D6A197B098C099D09621A730A28 +:10204000840A950AA40193010E948710E218F308FC +:1020500004091509A80197010E94DB102A0D3B1DF8 +:102060004C1D5D1DB901CA01CF91DF911F910F91E8 +:10207000FF90EF90DF90CF90BF90AF909F908F90A8 +:102080007F906F905F904F903F902F900895EF92C8 +:10209000FF920F931F937B018C01611571058105E0 +:1020A000910529F420E030E040E050E00BC00E94B0 +:1020B000E000A80197010E94DB10AC01CB01DA011E +:1020C0009C01AD01B901CA011F910F91FF90EF90E2 +:1020D0000895EF92FF920F931F937B018C0162177B +:1020E00073078407950764F4261B370B480B590BBD +:1020F000CA01B9010E944710E60EF71E081F191FFA +:10210000B701C8011F910F91FF90EF900895629F52 +:10211000D001739FF001829FE00DF11D649FE00DDF +:10212000F11D929FF00D839FF00D749FF00D659F40 +:10213000F00D9927729FB00DE11DF91F639FB00D3F +:10214000E11DF91FBD01CF011124089597FB092E50 +:1021500007260AD077FD04D049D006D000201AF413 +:10216000709561957F4F0895F6F7909581959F4FF3 +:102170000895A1E21A2EAA1BBB1BFD010DC0AA1FC8 +:10218000BB1FEE1FFF1FA217B307E407F50720F0E0 +:10219000A21BB30BE40BF50B661F771F881F991F5B +:1021A0001A9469F760957095809590959B01AC01A4 +:1021B000BD01CF01089597FB092E05260ED057FDCE +:1021C00004D0D7DF0AD0001C38F4509540953095E4 +:1021D00021953F4F4F4F5F4F0895F6F790958095AB +:1021E000709561957F4F8F4F9F4F0895AA1BBB1B22 +:1021F00051E107C0AA1FBB1FA617B70710F0A61B07 +:10220000B70B881F991F5A95A9F780959095BC0127 +:10221000CD010895EE0FFF1F0590F491E02D099474 +:102220002F923F924F925F926F927F928F929F92E6 +:10223000AF92BF92CF92DF92EF92FF920F931F93D4 +:10224000CF93DF93CDB7DEB7CA1BDB0B0FB6F89485 +:10225000DEBF0FBECDBF09942A88398848885F84C5 +:102260006E847D848C849B84AA84B984C884DF8036 +:10227000EE80FD800C811B81AA81B981CE0FD11D1A +:102280000FB6F894DEBF0FBECDBFED010895F894F0 +:02229000FFCF7E +:10229200536572766F20706F733A00436865676F9B +:1022A20075204E6F766F73203220627974657300E9 +:1022B200476972616E646F20783E300047697261CF +:1022C2006E646F203C300078203D200079203D2054 +:0C22D200000100000000000000AB0B0049 +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.pde new file mode 100644 index 0000000..7b5af92 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.pde @@ -0,0 +1,89 @@ +#include + +#define MOTOR1_P 4 +#define MOTOR1_N 5 +#define MOTOR1_PWM 11 + +#define MOTOR2_P 6 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 13 +#define SERVO_1 10 +#define MODE_BUTTON 19 //5 analógica lida como digital... + +#define MODE_DEMO 3 +#define MODE_WALK 2 +#define MODE_SUNSPOT 1 +#define MODE_STOP 0 +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=0; +Servo myservo10; // create servo object to control a servo + + +void setup() { + setupEngines(); + setupSunSpot(); + myservo10.attach(10); // attaches the servo on pin 10 to the servo object + Serial.begin(9600); +} +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void loop(){ + if(digitalRead(MODE_BUTTON)==0) { + while(digitalRead(MODE_BUTTON)==0); + mode++; + if(mode==4) mode=0; + } + if(mode==MODE_DEMO) { + Demo(); + } + else if(mode==MODE_WALK) { + Walk(); + } + else if(mode==MODE_SUNSPOT) { + SunSpot(); + } + +} + + + +/* + if(y>0) { + sentido = 1; + analogWrite(MOTOR1_PWM,(y == 10 ? 85 : y==20 ? 170 : 255)); + analogWrite(MOTOR2_PWM,(y == 10 ? 85 : y==20 ? 170 : 255)); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + } + else if(y<0){ //para traz + sentido = 0; + analogWrite(MOTOR1_PWM,(y == -10 ? 85 : y==-20 ? 170 : 255)); + analogWrite(MOTOR2_PWM,(y == -10 ? 85 : y==-20 ? 170 : 255)); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + } + */ + +/* + + + */ + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/Demo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/Demo.pde new file mode 100644 index 0000000..6ed3a69 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/Demo.pde @@ -0,0 +1,194 @@ +/* +1.5' 3.2' + C E Am + Faço código como cão;Maldito bug, que não encontro não; + 5.5' 8' com breque + Vem o prazo e o chefão, o redeploy não da certo nÃo; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se você começa de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + Já estou penando aqui + 38' 41' + C E Am + Faço o download de um jar grandão, mas também não 42' + funciona não + 43' 45' 48' + Chamo o arquiteto bacanão, mas no fundo é um manézão + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + Não me sinto up-to-date, eu estou é “deprecate” + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Faço código como cão;Maldito bug, que não encontro não; + 5.5' 8' com breque + Vem o prazo e o chefão, o redeploy não da certo nÃo; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se você começa de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas também não funciona não */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo é um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..dc28a59 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/Print.cpp.o new file mode 100644 index 0000000..6205c51 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/SunSpot.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/SunSpot.pde new file mode 100644 index 0000000..edcd38d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/SunSpot.pde @@ -0,0 +1,101 @@ +#define SUN_SPOT 8 +#define SUN_SPOT_ACK 12 +#define SUN_SPOT_INTERRUPT 0 //PORTA digital 2 + +volatile int data; +volatile boolean bit_array[16]; +volatile int contador; +int x; +int y; + +void SunSpot() { + if(x==0 && y==0) { + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + } + if(y>0) sentido = 0; //Para FRENTE + else if(y<0) sentido = 1;// Para Traz + //Configurando o sentido do trem.. quero dizer do robot + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + if(y!=0 && x!=0) { //Curva frente ou traz... + int coeficientePotencia = map(x<0 ? x*-1 : x,0,30,0,255); + analogWrite(MOTOR1_PWM, x< 0 ? coeficientePotencia : coeficientePotencia/2); + analogWrite(MOTOR2_PWM, x< 0 ? coeficientePotencia/2 : coeficientePotencia); + } + else { //reto + analogWrite(MOTOR1_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + analogWrite(MOTOR2_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + } + //Girando no eixo + if(y==0 && x!=0) { + sentido = x<0; + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_N,sentido); + if(x>0) { + Serial.print("Girando x>0"); + Serial.println(map(x,0,30,40,255)); + analogWrite(MOTOR1_PWM, map(x,0,30,40,255) ); + analogWrite(MOTOR2_PWM , map(x,0,30,40,255) ); + } + else { + Serial.print("Girando <0"); + Serial.println(map(x>0 ? x : x*-1,0,30,40,255)); + + analogWrite(MOTOR2_PWM, map(x*-1,0,30,40,255) ); + analogWrite(MOTOR1_PWM, map(x*-1,0,30,40,255) ); + } + } + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + delay(200); +} +void setupSunSpot() { + attachInterrupt(0, receiveSunSpot, RISING); + pinMode(SUN_SPOT,INPUT); + pinMode(SUN_SPOT_ACK,OUTPUT); +} + +void receiveSunSpot() { + digitalWrite(SUN_SPOT_ACK,LOW); + bit_array[contador++]=digitalRead(SUN_SPOT); + digitalWrite(SUN_SPOT_ACK,HIGH); + if(contador==16) { + Serial.println("Chegou Novos 2 bytes"); + contador=0; + x = BtoI(0,7,bit_array); + + y = BtoI(8,15,bit_array); + + for(int clean=0;clean<16;clean++) bit_array[clean]=false; + + } +} + +int BtoI(int start,int end, volatile boolean bits[]){ + boolean negative=bits[start]; + start++; + unsigned long integer=0; + unsigned long mask=1; + int r; + for (int i = end; i >= start; i--) { + if(negative) { + if (!bits[i]) integer |= mask; + } + else { + if (bits[i]) integer |= mask; + } + mask = mask << 1; + } + r = (int) integer; + if(negative) r= ~r; + return r; +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/WInterrupts.c.o new file mode 100644 index 0000000..b74dfbb Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/WMath.cpp.o new file mode 100644 index 0000000..4e4cf44 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/Walk.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/Walk.pde new file mode 100644 index 0000000..0306154 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/Walk.pde @@ -0,0 +1,223 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int move_count = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + readPing(); + processPing(); + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,50*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/core.a new file mode 100644 index 0000000..9917612 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/pins_arduino.c.o new file mode 100644 index 0000000..c450af7 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring.c.o new file mode 100644 index 0000000..acbd542 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_analog.c.o new file mode 100644 index 0000000..b56797d Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_digital.c.o new file mode 100644 index 0000000..3928ccd Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_pulse.c.o new file mode 100644 index 0000000..525eda2 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_serial.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_serial.c.o new file mode 100644 index 0000000..b8d4c17 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_serial.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_shift.c.o new file mode 100644 index 0000000..8e0db5b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ArduinoSunSpotV2/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Dimmer_D2/Dimmer_D2.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Dimmer_D2/Dimmer_D2.pde new file mode 100644 index 0000000..969461a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Dimmer_D2/Dimmer_D2.pde @@ -0,0 +1,194 @@ +/* + AC Light Control + + Ryan McLaughlin + + Thanks to http://www.andrewkilpatrick.org/blog/?page_id=445 + and http://www.hoelscher-hi.de/hendrik/english/dimmer.htm + + */ +#include + +#include +#include + +#define PING_PIN 4 + +#define INIT_TIMER_COUNT 6 +#define RESET_TIMER2 TCNT2 = INIT_TIMER_COUNT + +#define CW HIGH +#define CCW LOW + +// One and two phases +// 60000ms / 48steps = 1250ms/step +#define TRACK 1250 + +// Half steps +// 60000ms / 96steps = 625 +//#define TRACK 625 + + + + +int led13 = HIGH; +long counter = 0; +int stepStack = 0; + + +int AC_pin = 7; // Output to Opto Triac +int olddim; +long dim = 120; // Dimming level (0-128) 0 = on, 128 = 0ff +long duration, inches, cm, oldCm; +long MAX_DISTANCE = 50; +volatile boolean wasInt = false; +unsigned long time, timeWaiting, DEFAULT_CONFIG_PERIOD=2000; + +void setup() // run once, when the sketch starts +{ + pinMode(AC_pin, OUTPUT); // Set the light control pin as output + Serial.begin(9600); + attachInterrupt(0, light, RISING); // Attach an Interupt to pin2 (interupt 0) for Zero Cross Detection + Wire.begin(66); + Wire.onReceive(receiveEvent); + readPing(true); + MAX_DISTANCE=cm; + + //Timer2 Settings: Timer Prescaler /64, + TCCR2A |= (1< 30 ? 30 : cm; + dim = map(cmn,1,30,10,125); + //Wire.send(dim); + delay(20); + readPing(true); + + } + } + } + delay(150); + + +} +void readPing(boolean disableInt) +{ + wasInt=false; + + if(disableInt) noInterrupts(); + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + if(wasInt) return; + delayMicroseconds(2); + if(wasInt) return; + digitalWrite(PING_PIN, HIGH); + if(wasInt) return; + delayMicroseconds(5); + if(wasInt) return; + digitalWrite(PING_PIN, LOW); + pinMode(PING_PIN, INPUT); + if(wasInt) return; + duration = pulseIn(PING_PIN, HIGH); + if(wasInt) return; + interrupts(); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + + +// Aruino runs at 16 Mhz, so we have 1000 Overflows per second... +// 1/ ((16000000 / 64) / 256) = 1 / 1000 +ISR(TIMER2_OVF_vect) { + RESET_TIMER2; + counter++; + if(!(counter%TRACK)) + { + // enqueue step message + } +}; + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Dimmer_JavaFX/Dimmer_JavaFX.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Dimmer_JavaFX/Dimmer_JavaFX.pde new file mode 100644 index 0000000..ef8e6c5 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Dimmer_JavaFX/Dimmer_JavaFX.pde @@ -0,0 +1,51 @@ +#include + +int AC_pin = 3; // Output to Opto Triac +volatile long dim = 60; // Dimming level (0-128) 0 = on, 128 = 0ff + + +void setup() +{ + // start serial port at 9600 bps: + pinMode(AC_pin, OUTPUT); // Set the light control pin as output + Serial.begin(9600); + attachInterrupt(0, light, RISING); // Attach an Interupt to pin2 (interupt 0) for Zero Cross Detection + Wire.begin(4); // join i2c bus with address #4 + Wire.onReceive(receiveEvent); // register event + +} +void receiveEvent(int howMany) +{ + Serial.println("Evento"); + Serial.println(howMany); +// dim = howMany; + +} + +void light() // function to be fired at the zero crossing to dim the light +{ + //Serial.println("AA"); + + if(dim<125) { + long dimtime = (60*dim); // eval the proper pause to fire the triac + delayMicroseconds(dimtime); // delay the dim time + digitalWrite(AC_pin, HIGH); // fire the Triac + delayMicroseconds(1); // pause briefly to ensure the triac turned on + digitalWrite(AC_pin, LOW); // turn off the Triac gate (triac will not turn off until next zero cross) + } + else { + digitalWrite(AC_pin, LOW); // turn off the Triac gate (triac will not turn off until next zero cross) + } +} + +void loop() +{ + if (Serial.available() > 0) { + byte inByte = Serial.read(); + dim = inByte; + + } +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/DojoBSB/Demo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/DojoBSB/Demo.pde new file mode 100644 index 0000000..290c156 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/DojoBSB/Demo.pde @@ -0,0 +1,195 @@ +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/DojoBSB/DojoBSB.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/DojoBSB/DojoBSB.pde new file mode 100644 index 0000000..cf12436 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/DojoBSB/DojoBSB.pde @@ -0,0 +1,73 @@ +#include + +#define MOTOR1_P 4 +#define MOTOR1_N 5 +#define MOTOR1_PWM 11 + +#define MOTOR2_P 6 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 9 +#define SERVO_H 10 +#define SERVO_V 11 + +#define MODE_BUTTON 19 //5 anal�gica lida como digital... + +#define MODE_DEMO 2 +#define MODE_WALK 3 +#define MODE_SUNSPOT 1 +#define MODE_STOP 0 +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=0; +Servo servoHorizontal; // create servo object to control a servo +Servo servoVertical; // create servo object to control a servo + + +void setup() { + setupEngines(); + setupSunSpot(); + servoHorizontal.attach(SERVO_H); + //servoVertical.attach(SERVO_V); + Serial.begin(9600); +} + + +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + +} + +void loop(){ + + if(digitalRead(MODE_BUTTON)==0) { + while(digitalRead(MODE_BUTTON)==0); + mode++; + if(mode==4) mode=0; + } + if(mode==MODE_DEMO) { + Demo(); + } + else if(mode==MODE_WALK) { + Walk(); + } + else if(mode==MODE_SUNSPOT) { + SunSpot(); + } + +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/DojoBSB/SunSpot.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/DojoBSB/SunSpot.pde new file mode 100644 index 0000000..9623884 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/DojoBSB/SunSpot.pde @@ -0,0 +1,118 @@ +#define SUN_SPOT 8 +#define SUN_SPOT_ACK 12 +#define SUN_SPOT_INTERRUPT 0 //PORTA digital 2 + +volatile int data; +volatile boolean bit_array[16]; +volatile int contador; +int x; +int y; + +void SunSpot() { + if(x==0 && y==0) { + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + } + if(x==100 && y==100) { + digitalWrite(9, HIGH); + delay(500); + digitalWrite(9, LOW); + delay(200); + return; + } + if(x==101) { + changeServo(y); + delay(200); + return; + } + + if(y>0) sentido = 0; //Para FRENTE + else if(y<0) sentido = 1;// Para Traz + //Configurando o sentido do trem.. quero dizer do robot + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + if(y!=0 && x!=0) { //Curva frente ou traz... + int coeficientePotencia = map(x<0 ? x*-1 : x,0,30,0,255); + analogWrite(MOTOR1_PWM, x< 0 ? coeficientePotencia : coeficientePotencia/2); + analogWrite(MOTOR2_PWM, x< 0 ? coeficientePotencia/2 : coeficientePotencia); + } + else { //reto + analogWrite(MOTOR1_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + analogWrite(MOTOR2_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + } + //Girando no eixo + if(y==0 && x!=0) { + sentido = x<0; + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_N,sentido); + if(x>0) { + Serial.print("Girando x>0"); + Serial.println(map(x,0,30,40,255)); + analogWrite(MOTOR1_PWM, map(x,0,30,40,255) ); + analogWrite(MOTOR2_PWM , map(x,0,30,40,255) ); + } + else { + Serial.print("Girando <0"); + Serial.println(map(x>0 ? x : x*-1,0,30,40,255)); + + analogWrite(MOTOR2_PWM, map(x*-1,0,30,40,255) ); + analogWrite(MOTOR1_PWM, map(x*-1,0,30,40,255) ); + } + } + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + delay(200); +} +void setupSunSpot() { + attachInterrupt(0, receiveSunSpot, RISING); + pinMode(SUN_SPOT,INPUT); + pinMode(SUN_SPOT_ACK,OUTPUT); +} + +void receiveSunSpot() { + digitalWrite(SUN_SPOT_ACK,LOW); + bit_array[contador++]=digitalRead(SUN_SPOT); + digitalWrite(SUN_SPOT_ACK,HIGH); + if(contador==16) { + Serial.println("Chegou Novos 2 bytes"); + contador=0; + x = BtoI(0,7,bit_array); + + y = BtoI(8,15,bit_array); + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + for(int clean=0;clean<16;clean++) bit_array[clean]=false; + + } +} + +int BtoI(int start,int end, volatile boolean bits[]){ + boolean negative=bits[start]; + start++; + unsigned long integer=0; + unsigned long mask=1; + int r; + for (int i = end; i >= start; i--) { + if(negative) { + if (!bits[i]) integer |= mask; + } + else { + if (bits[i]) integer |= mask; + } + mask = mask << 1; + } + r = (int) integer; + if(negative) r= ~r; + return r; +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/DojoBSB/Walk.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/DojoBSB/Walk.pde new file mode 100644 index 0000000..d46bc8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/DojoBSB/Walk.pde @@ -0,0 +1,286 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServo(int servoPos) { + servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + andarFrente(300,3); + + readPing(); + while(cm > 35) { + andarFrente(300,3); + readPing(); +} + parar(); + fullScan(); + + if(getLongestPosition() < 9){ + virarEsquerdaRe(500,3); + }else { + virarDireitaRe(500,3); + } + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + + if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + + andarFrente(300,3); + moveCount++; + + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/I2C_Master/I2C_Master.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/I2C_Master/I2C_Master.pde new file mode 100644 index 0000000..53c4fbd --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/I2C_Master/I2C_Master.pde @@ -0,0 +1,40 @@ +#include + + +char comando[16]; +int luz= 0; + + +void setup() +{ + Wire.begin(); + Serial.begin(9600); +} + +void loop () +{ + executarComando(); + delay(1000); + +} + +void executarComando() { + Serial.println("Enviando"); + Wire.beginTransmission(65); // transmit to device #4 + Wire.send(luz++); // sends six bytes + Wire.endTransmission(); // stop transmitting + +} +void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } +} + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/I2C_Slave/I2C_Slave.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/I2C_Slave/I2C_Slave.pde new file mode 100644 index 0000000..784d5eb --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/I2C_Slave/I2C_Slave.pde @@ -0,0 +1,34 @@ +#include + + +void setup() +{ + Serial.begin(9600); + Wire.begin(65); // join i2c bus with address #4 + Wire.onReceive(receiveEvent); // register event + +} +void receiveEvent(int howMany) +{ + while(1 < Wire.available()) // loop through all but the last + { + char c = Wire.receive(); // receive byte as a character + Serial.print(c); // print the character + } + int x = Wire.receive(); // receive byte as an integer + Serial.println(x); // print the integer + + Serial.println("Evento"); + Serial.println(howMany); + +} + +void loop() +{ + Serial.println("esperando..."); + delay(1000); + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/I2C_Slave_Dimmer/I2C_Slave_Dimmer.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/I2C_Slave_Dimmer/I2C_Slave_Dimmer.pde new file mode 100644 index 0000000..dd8a966 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/I2C_Slave_Dimmer/I2C_Slave_Dimmer.pde @@ -0,0 +1,62 @@ +#include + +int AC_pin = 7; +volatile long dim = 100; + + +void setup() +{ + pinMode(AC_pin, OUTPUT); + Serial.begin(9600); + attachInterrupt(0, light, RISING); + Wire.begin(66); + Wire.onReceive(receiveEvent); + +} +void receiveEvent(int howMany) +{ + char comando[16]; + int counter=0; + while(1 < Wire.available()) + { + char c = Wire.receive(); + comando[counter++]=c; + Serial.print(c); + } + int x = Wire.receive(); + Serial.println(x); + + Serial.println("Evento"); + Serial.println(howMany); + //value, fromLow, fromHigh, toLow, toHigh) + dim = map(comando[1], 48,57,10,120); + +} + +void light() +{ + Serial.println("int"); + + if(dim<125) { + long dimtime = (60*dim); // eval the proper pause to fire the triac + Serial.println(dimtime); + delayMicroseconds(dimtime); // delay the dim time + digitalWrite(AC_pin, HIGH); // fire the Triac + delayMicroseconds(1); // pause briefly to ensure the triac turned on + digitalWrite(AC_pin, LOW); // turn off the Triac gate (triac will not turn off until next zero cross) + } + else { + digitalWrite(AC_pin, LOW); // turn off the Triac gate (triac will not turn off until next zero cross) + } +} + +void loop() +{ + if (Serial.available() > 0) { + byte inByte = Serial.read(); + dim = inByte; + } +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/InnovationAward/InnovationAward.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/InnovationAward/InnovationAward.pde new file mode 100644 index 0000000..5b3f610 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/InnovationAward/InnovationAward.pde @@ -0,0 +1,164 @@ +#define RELAY1 7 +#define RELAY2 8 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo + +#define BLUE 9 +#define GREEN 6 +#define RED 5 + +#define TEMPERATURE 2 +#define LIGHT 3 +#define PING_PIN 3 + +#define LED 13 + +long duration, inches, cm; +boolean connected = false; + +void setup() +{ + Serial.begin(115200); + pinMode(LED, OUTPUT); + pinMode(RELAY1, OUTPUT); + pinMode(RELAY2, OUTPUT); + +} + +void loop() +{ + if(Serial.available()) receiveCommand(); +} + +void handShake() { + //Serial.print("ID 0|bluetooth prototype device|6|A|relay|B|dimmer|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.print("ID 0|USB prototype device|6|A|lamp|B|wallsocket|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + if(comando[0]=='A') relayCommand(comando[1], comando[2]); + if(comando[0]=='B') dimmer(comando); + if(comando[0]=='C') RGB(comando); + if(comando[0]=='D') readLight(); + if(comando[0]=='E') readTemperature(); + if(comando[0]=='F') readDistance(); + if(comando[0]=='S') readAllSensors(); + if(comando[0]=='X') shutdown(); + +} + +void relayCommand(char operation, char relay) { + if(operation=='+') { + digitalWrite(relay=='A' ? RELAY1 : RELAY2, HIGH); + if(relay=='C') digitalWrite(relay=='A' ? RELAY1 : RELAY2, HIGH); + } + else if(operation=='-') { + digitalWrite(relay=='A' ? RELAY1 : RELAY2, LOW); + if(relay=='C') digitalWrite(relay=='A' ? RELAY1 : RELAY2 , LOW); + } +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void dimmer(char* comando) { +} + +void readLight() { + String toSend = String(analogRead(LIGHT)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(TEMPERATURE)); + sendToPC(toSend); +} + +void readAllSensors() { + Serial.print(analogRead(LIGHT)); + Serial.print("|"); + Serial.print(analogRead(2)); + Serial.print("|"); + //String toSend3 = String(cm); + Serial.print(cm); + Serial.flush(); +} + + +void readDistance() { + readPing(); + sendToPC(cm); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Innovation_Relay/Innovation_Relay.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Innovation_Relay/Innovation_Relay.pde new file mode 100644 index 0000000..82db7d5 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Innovation_Relay/Innovation_Relay.pde @@ -0,0 +1,70 @@ +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define BLUE 9 +#define GREEN 6 +#define RED 5 + +void setup() +{ + pinMode(11, OUTPUT); + pinMode(12, OUTPUT); + Serial.begin(115200); + analogWrite(RED,255); + delay(250); + analogWrite(RED,0); + delay(250); + analogWrite(GREEN,255); + delay(250); + analogWrite(GREEN,0); + delay(250); + analogWrite(BLUE,255); + delay(250); + analogWrite(BLUE,0); + delay(250); + +} + +void loop() +{ + if(Serial.available()) receiveCommand(); +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='A') relayCommand(comando[1], comando[2]); + if(comando[0]=='B') dimmer(comando); + if(comando[0]=='C') RGB(comando); +} + +void relayCommand(char operation, char relay) { + if(operation=='+') { + digitalWrite(relay=='A' ? 11 : 12, HIGH); + if(relay=='C') digitalWrite(relay=='A' ? 12 : 11, HIGH); + } + else if(operation=='-') { + digitalWrite(relay=='A' ? 11 : 12, LOW); + if(relay=='C') digitalWrite(relay=='A' ? 12 : 11, LOW); + } +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void dimmer(char* comando) {} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaFX_Mirror/JavaFX_Mirror.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaFX_Mirror/JavaFX_Mirror.pde new file mode 100644 index 0000000..7cb0891 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaFX_Mirror/JavaFX_Mirror.pde @@ -0,0 +1,1188 @@ +/* + Serial Call and Response + Language: Wiring/Arduino + + This program sends an ASCII A (byte of value 65) on startup + and repeats that until it gets some data in. + Then it waits for a byte in the serial port, and + sends three sensor values whenever it gets a byte in. + + Thanks to Greg Shakar and Scott Fitzgerald for the improvements + + The circuit: + * potentiometers attached to analog inputs 0 and 1 + * pushbutton attached to digital I/O 2 + + + http://www.arduino.cc/en/Tutorial/SerialCallResponse + + Created 26 Sept. 2005 + by Tom Igoe + Modified 14 April 2009 + by Tom Igoe and Scott Fitzgerald + */ + +int firstSensor = 0; // first analog sensor +int secondSensor = 0; // second analog sensor +int thirdSensor = 0; // digital sensor +int inByte = 0; // incoming serial byte + +void setup() +{ + // start serial port at 9600 bps: + Serial.begin(9600); + pinMode(2, INPUT); // digital sensor is on digital pin 2 + establishContact(); // send a byte to establish contact until receiver responds +} + +void loop() +{ + // if we get a valid byte, read analog ins: + if (Serial.available() > 0) { + // get incoming byte: + inByte = Serial.read(); + // read first analog input, divide by 4 to make the range 0-255: + pinMode(inByte, OUTPUT); + digitalWrite(inByte, HIGH); + delay(1000); + digitalWrite(inByte, LOW + ); + + } +} + +void establishContact() { + while (Serial.available() <= 0) { + Serial.print('A', BYTE); // send a capital A + delay(300); + } +} + +/* +Processing sketch to run with this example: + +import processing.serial.*; + +int bgcolor; // Background color +int fgcolor; // Fill color +Serial myPort; // The serial port +int[] serialInArray = new int[3]; // Where we'll put what we receive +int serialCount = 0; // A count of how many bytes we receive +int xpos, ypos; // Starting position of the ball +boolean firstContact = false; // Whether we've heard from the microcontroller + +void setup() { + size(256, 256); // Stage size + noStroke(); // No border on the next thing drawn + + // Set the starting position of the ball (middle of the stage) + xpos = width/2; + ypos = height/2; + + // Print a list of the serial ports, for debugging purposes: + println(Serial.list()); + + // I know that the first port in the serial list on my mac + // is always my FTDI adaptor, so I open Serial.list()[0]. + // On Windows machines, this generally opens COM1. + // Open whatever port is the one you're using. + String portName = Serial.list()[0]; + myPort = new Serial(this, portName, 9600); +} + +void draw() { + background(bgcolor); + fill(fgcolor); + // Draw the shape + ellipse(xpos, ypos, 20, 20); +} + +void serialEvent(Serial myPort) { + // read a byte from the serial port: + int inByte = myPort.read(); + // if this is the first byte received, and it's an A, + // clear the serial buffer and note that you've + // had first contact from the microcontroller. + // Otherwise, add the incoming byte to the array: + if (firstContact == false) { + if (inByte == 'A') { + myPort.clear(); // clear the serial port buffer + firstContact = true; // you've had first contact from the microcontroller + myPort.write('A'); // ask for more + } + } + else { + // Add the latest byte from the serial port to array: + serialInArray[serialCount] = inByte; + serialCount++; + + // If we have 3 bytes: + if (serialCount > 2 ) { + xpos = serialInArray[0]; + ypos = serialInArray[1]; + fgcolor = serialInArray[2]; + + // print the values (for debugging purposes only): + println(xpos + "\t" + ypos + "\t" + fgcolor); + + // Send a capital A to request new sensor readings: + myPort.write('A'); + // Reset serialCount: + serialCount = 0; + } + } +} +*/ + +/* +Max/MSP version 5 patch to run with this example: + +{ + "boxes" : [ { + "box" : { + "maxclass" : "message", + "text" : "65", + "patching_rect" : [ 339.0, 466.0, 32.5, 18.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-9", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "sel 1", + "patching_rect" : [ 339.0, 437.0, 36.0, 20.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "bang", "" ], + "id" : "obj-6", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "Serial Call-Response \n\nSends a byte out the serial port, and reads 3 bytes in. Sets foregound color, xpos, and ypos of a circle using the values returned from the serial port. \n\nNote: This patch assumes that the device on the other end of the serial port is going to send a single byte of value 65 (ASCII A) on startup. The sketch waits for that byte, then sends an ASCII A whenever it wants more data. \n\ncreated 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe", + "linecount" : 11, + "patching_rect" : [ 404.0, 52.0, 464.0, 158.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-5", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "trigger (or [t]) forces right-left conventions. All the drawing and processing will happen before Max requests new values. When this trigger fires, it sends an ASCII A to ask Arduino for new values.", + "linecount" : 3, + "patching_rect" : [ 239.0, 505.0, 425.0, 48.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-65", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "reinitializes the gates when turned on and off", + "linecount" : 2, + "patching_rect" : [ 170.0, 370.0, 135.0, 34.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-64", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "checks for the ascii value of \"A\" to begin cominucation. After initial communication is made, this block shuts down.", + "linecount" : 3, + "patching_rect" : [ 460.0, 355.0, 233.0, 48.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-63", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "p \"draw the circle\"", + "patching_rect" : [ 217.0, 645.0, 269.0, 19.0 ], + "numoutlets" : 1, + "fontsize" : 10.0, + "outlettype" : [ "" ], + "id" : "obj-62", + "fontname" : "Verdana", + "numinlets" : 3, + "patcher" : { + "fileversion" : 1, + "rect" : [ 54.0, 94.0, 640.0, 480.0 ], + "bglocked" : 0, + "defrect" : [ 54.0, 94.0, 640.0, 480.0 ], + "openrect" : [ 0.0, 0.0, 0.0, 0.0 ], + "openinpresentation" : 0, + "default_fontsize" : 10.0, + "default_fontface" : 0, + "default_fontname" : "Verdana", + "gridonopen" : 0, + "gridsize" : [ 25.0, 25.0 ], + "gridsnaponopen" : 0, + "toolbarvisible" : 1, + "boxanimatetime" : 200, + "imprint" : 0, + "boxes" : [ { + "box" : { + "maxclass" : "message", + "text" : "frgb 255 255 255", + "patching_rect" : [ 375.0, 150.0, 98.0, 18.0 ], + "numoutlets" : 1, + "fontsize" : 11.595187, + "outlettype" : [ "" ], + "id" : "obj-47", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "frgb 0 0 0", + "patching_rect" : [ 275.0, 125.0, 59.0, 18.0 ], + "numoutlets" : 1, + "fontsize" : 11.595187, + "outlettype" : [ "" ], + "id" : "obj-46", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "sel 255 0", + "patching_rect" : [ 300.0, 100.0, 66.0, 21.0 ], + "numoutlets" : 3, + "fontsize" : 12.0, + "outlettype" : [ "bang", "bang", "" ], + "id" : "obj-45", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "pack 0 0 0 0", + "patching_rect" : [ 50.0, 125.0, 180.0, 21.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-43", + "fontname" : "Verdana", + "numinlets" : 4 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "+ 10", + "patching_rect" : [ 200.0, 100.0, 40.0, 21.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "int" ], + "id" : "obj-42", + "fontname" : "Verdana", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "+ 10", + "patching_rect" : [ 75.0, 100.0, 40.0, 21.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "int" ], + "id" : "obj-41", + "fontname" : "Verdana", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "clear, paintoval $1 $2 $3 $4", + "patching_rect" : [ 50.0, 150.0, 152.0, 18.0 ], + "numoutlets" : 1, + "fontsize" : 11.595187, + "outlettype" : [ "" ], + "id" : "obj-40", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "inlet", + "patching_rect" : [ 57.5, 40.0, 25.0, 25.0 ], + "numoutlets" : 1, + "outlettype" : [ "int" ], + "id" : "obj-58", + "numinlets" : 0, + "comment" : "" + } + + } +, { + "box" : { + "maxclass" : "inlet", + "patching_rect" : [ 120.0, 40.0, 25.0, 25.0 ], + "numoutlets" : 1, + "outlettype" : [ "int" ], + "id" : "obj-59", + "numinlets" : 0, + "comment" : "" + } + + } +, { + "box" : { + "maxclass" : "inlet", + "patching_rect" : [ 300.0, 40.0, 25.0, 25.0 ], + "numoutlets" : 1, + "outlettype" : [ "int" ], + "id" : "obj-60", + "numinlets" : 0, + "comment" : "" + } + + } +, { + "box" : { + "maxclass" : "outlet", + "patching_rect" : [ 228.333344, 228.0, 25.0, 25.0 ], + "numoutlets" : 0, + "id" : "obj-61", + "numinlets" : 1, + "comment" : "" + } + + } + ], + "lines" : [ { + "patchline" : { + "source" : [ "obj-47", 0 ], + "destination" : [ "obj-61", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-46", 0 ], + "destination" : [ "obj-61", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-40", 0 ], + "destination" : [ "obj-61", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-60", 0 ], + "destination" : [ "obj-45", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-59", 0 ], + "destination" : [ "obj-42", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-59", 0 ], + "destination" : [ "obj-43", 1 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-58", 0 ], + "destination" : [ "obj-41", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-58", 0 ], + "destination" : [ "obj-43", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-42", 0 ], + "destination" : [ "obj-43", 3 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-41", 0 ], + "destination" : [ "obj-43", 2 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-45", 1 ], + "destination" : [ "obj-47", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-45", 0 ], + "destination" : [ "obj-46", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-43", 0 ], + "destination" : [ "obj-40", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } + ] + } +, + "saved_object_attributes" : { + "fontface" : 0, + "fontsize" : 10.0, + "default_fontface" : 0, + "default_fontname" : "Verdana", + "default_fontsize" : 10.0, + "fontname" : "Verdana", + "globalpatchername" : "" + } + + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "0", + "patching_rect" : [ 310.0, 378.0, 32.5, 20.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "int" ], + "id" : "obj-57", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "!- 1", + "patching_rect" : [ 385.0, 436.0, 32.5, 20.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "int" ], + "id" : "obj-55", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "gate 1 1", + "patching_rect" : [ 385.0, 355.0, 54.0, 20.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-54", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "toggle", + "patching_rect" : [ 385.0, 405.0, 20.0, 20.0 ], + "numoutlets" : 1, + "outlettype" : [ "int" ], + "id" : "obj-53", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "gate 1 0", + "patching_rect" : [ 194.0, 455.0, 54.0, 20.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-50", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "sel 65", + "patching_rect" : [ 385.0, 380.0, 43.0, 20.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "bang", "" ], + "id" : "obj-48", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "lcd", + "patching_rect" : [ 217.0, 695.0, 256.0, 256.0 ], + "numoutlets" : 4, + "outlettype" : [ "list", "list", "int", "" ], + "id" : "obj-39", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "t 65 l", + "patching_rect" : [ 194.0, 504.0, 42.0, 21.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "int", "" ], + "id" : "obj-35", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "val3", + "patching_rect" : [ 535.0, 604.0, 37.0, 21.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-1", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "number", + "patching_rect" : [ 467.0, 604.0, 56.0, 21.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "int", "bang" ], + "id" : "obj-3", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "val2", + "patching_rect" : [ 410.0, 605.0, 37.0, 21.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-18", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "val1", + "patching_rect" : [ 282.0, 605.0, 37.0, 21.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-20", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "number", + "patching_rect" : [ 342.0, 605.0, 56.0, 21.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "int", "bang" ], + "id" : "obj-22", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "number", + "patching_rect" : [ 217.0, 605.0, 55.0, 21.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "int", "bang" ], + "id" : "obj-23", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "unpack 0 0 0", + "patching_rect" : [ 217.0, 570.0, 269.0, 21.0 ], + "numoutlets" : 3, + "fontsize" : 12.0, + "outlettype" : [ "int", "int", "int" ], + "id" : "obj-29", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "zl group 3", + "patching_rect" : [ 194.0, 480.0, 71.0, 21.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "", "" ], + "id" : "obj-31", + "fontname" : "Verdana", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "select 0 1", + "patching_rect" : [ 312.0, 200.0, 62.0, 20.0 ], + "numoutlets" : 3, + "fontsize" : 12.0, + "outlettype" : [ "bang", "bang", "" ], + "id" : "obj-30", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "click here to close the serial port", + "patching_rect" : [ 360.0, 291.0, 206.0, 20.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-26", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "click here to open the serial port", + "patching_rect" : [ 385.0, 265.0, 206.0, 20.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-27", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "close", + "patching_rect" : [ 312.0, 291.0, 39.0, 18.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-21", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "port a", + "patching_rect" : [ 334.0, 265.0, 41.0, 18.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-19", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "Click here to get a list of serial ports", + "patching_rect" : [ 405.0, 239.0, 207.0, 20.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-2", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "toggle", + "patching_rect" : [ 229.0, 155.0, 22.0, 22.0 ], + "numoutlets" : 1, + "outlettype" : [ "int" ], + "id" : "obj-11", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "qmetro 10", + "patching_rect" : [ 229.0, 200.0, 65.0, 20.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "bang" ], + "id" : "obj-12", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "print", + "patching_rect" : [ 354.0, 239.0, 36.0, 18.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-13", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "serial a 9600", + "patching_rect" : [ 229.0, 315.0, 84.0, 20.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "int", "" ], + "id" : "obj-14", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "Read serial input buffer every 10 milliseconds", + "linecount" : 2, + "patching_rect" : [ 13.0, 192.0, 210.0, 34.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-15", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "Click to start", + "patching_rect" : [ 256.0, 163.0, 117.0, 20.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-17", + "fontname" : "Arial", + "numinlets" : 1 + } + + } + ], + "lines" : [ { + "patchline" : { + "source" : [ "obj-12", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-11", 0 ], + "destination" : [ "obj-12", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-13", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ 363.5, 260.5, 238.5, 260.5 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-19", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ 343.5, 288.5, 238.5, 288.5 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-21", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ 321.5, 311.5, 238.5, 311.5 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-30", 0 ], + "destination" : [ "obj-21", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-30", 1 ], + "destination" : [ "obj-19", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-11", 0 ], + "destination" : [ "obj-30", 0 ], + "hidden" : 0, + "midpoints" : [ 238.5, 191.0, 321.5, 191.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-29", 2 ], + "destination" : [ "obj-3", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-29", 0 ], + "destination" : [ "obj-23", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-29", 1 ], + "destination" : [ "obj-22", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-14", 0 ], + "destination" : [ "obj-50", 1 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-50", 0 ], + "destination" : [ "obj-31", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-48", 0 ], + "destination" : [ "obj-53", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-53", 0 ], + "destination" : [ "obj-50", 0 ], + "hidden" : 0, + "midpoints" : [ 394.5, 426.0, 203.5, 426.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-14", 0 ], + "destination" : [ "obj-54", 1 ], + "hidden" : 0, + "midpoints" : [ 238.5, 342.0, 429.5, 342.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-54", 0 ], + "destination" : [ "obj-48", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-62", 0 ], + "destination" : [ "obj-39", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-3", 0 ], + "destination" : [ "obj-62", 2 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-22", 0 ], + "destination" : [ "obj-62", 1 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-23", 0 ], + "destination" : [ "obj-62", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-53", 0 ], + "destination" : [ "obj-55", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-55", 0 ], + "destination" : [ "obj-54", 0 ], + "hidden" : 0, + "midpoints" : [ 394.5, 459.0, 453.0, 459.0, 453.0, 351.0, 394.5, 351.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-30", 0 ], + "destination" : [ "obj-57", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-57", 0 ], + "destination" : [ "obj-53", 0 ], + "hidden" : 0, + "midpoints" : [ 319.5, 401.0, 394.5, 401.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-35", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ 203.5, 542.0, 167.0, 542.0, 167.0, 300.0, 238.5, 300.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-35", 1 ], + "destination" : [ "obj-29", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-31", 0 ], + "destination" : [ "obj-35", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-6", 0 ], + "destination" : [ "obj-9", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-53", 0 ], + "destination" : [ "obj-6", 0 ], + "hidden" : 0, + "midpoints" : [ 394.5, 431.5, 348.5, 431.5 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-9", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } + ] +} + + +*/ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome.zip b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome.zip new file mode 100644 index 0000000..fbbc34d Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome.zip differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/.DS_Store b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/.DS_Store new file mode 100644 index 0000000..c877d4f Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/.DS_Store differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build.xml new file mode 100644 index 0000000..ee9af2c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build.xml @@ -0,0 +1,83 @@ + + + + + + Builds, tests, and runs the project . + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/.timestamp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/.timestamp new file mode 100644 index 0000000..999b584 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/.timestamp @@ -0,0 +1 @@ +ignore me \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/manifest.mf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/manifest.mf new file mode 100644 index 0000000..d54b83d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/manifest.mf @@ -0,0 +1,7 @@ +MIDlet-1: Arduhome,,com.netomarin.arduhome.core.ArduhomeMIDlet +MIDlet-Permissions: javax.microedition.io.Connector.bluetooth.client +MIDlet-Vendor: Globalcode - Eversource +MIDlet-Name: Arduhome +MIDlet-Version: 1.0 +MicroEdition-Configuration: CLDC-1.1 +MicroEdition-Profile: MIDP-2.0 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/bt/BluetoothClientServer.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/bt/BluetoothClientServer.java new file mode 100644 index 0000000..0285fba --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/bt/BluetoothClientServer.java @@ -0,0 +1,200 @@ +package com.netomarin.arduhome.bt; + +import com.netomarin.arduhome.core.ArduhomeMIDlet; +import com.netomarin.arduhome.core.FlowManager; +import com.netomarin.arduhome.view.ConnectionForm; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.Vector; + +import javax.bluetooth.BluetoothStateException; +import javax.bluetooth.DeviceClass; +import javax.bluetooth.DiscoveryAgent; +import javax.bluetooth.DiscoveryListener; +import javax.bluetooth.LocalDevice; +import javax.bluetooth.RemoteDevice; +import javax.bluetooth.ServiceRecord; +import javax.bluetooth.UUID; +import javax.microedition.io.Connector; +import javax.microedition.io.StreamConnection; + +/** + * + * @author Neto Marin + */ +public class BluetoothClientServer implements DiscoveryListener { + UUID RFCOMM_UUID = new UUID(0x1101); + private StreamConnection streamConn = null; + private LocalDevice localDevice = null; + private InputStream is = null; + private InputStreamReader isr = null; + private OutputStream os = null; + private OutputStreamWriter osw = null; + private DiscoveryAgent discoveryAgent = null; + private RemoteDevice remoteDevice; + private Vector services; + private static BluetoothClientServer instance; + + private boolean connected = false; + + private BluetoothClientServer() { + } + + public static BluetoothClientServer getInstance() { + if (instance == null) { + instance = new BluetoothClientServer(); + } + + return instance; + } + + public void InitClient() { + SearchAvailDevices(); + + } + + public void SearchAvailDevices() { + try { + //First get the local device and obtain the discovery agent. + this.remoteDevice = null; + localDevice = LocalDevice.getLocalDevice(); + discoveryAgent = localDevice.getDiscoveryAgent(); + ConnectionForm.getInstance().updateGaugeStatus("Starting search..."); + discoveryAgent.startInquiry(DiscoveryAgent.GIAC, this); + } catch (BluetoothStateException ex) { + System.out.println("Problem in searching the blue tooth devices"); + ConnectionForm.getInstance().updateGaugeStatus("Error searching devics!!"); + ConnectionForm.getInstance().append(ex.getMessage()); + } + } + + public void sendMessage(byte[] messageToSend) { + try { + //osw.write(messageToSend); + //osw.flush(); + os.write(messageToSend); + os.flush(); + } catch (IOException ex) { + } + } + + public String RecieveMessages() { + byte[] data = null; + + try { + int length = is.read(); + data = new byte[length]; + length = 0; + + while (length != data.length) { + int ch = is.read(data, length, data.length - length); + + if (ch == -1) { + throw new IOException("Can't read data"); + } + length += ch; + } + } catch (IOException e) { + System.err.println(e); +// MainForm.updateConnectionStatus("Error receiving messages!"); + } + + return new String(data); + } + + /********************************************************************************************* + * below are the pure virtual methods of discoverlistern + * + * + *******************************************************************************************/ + //Called when device is found during inquiry + public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { + try { + // Get Device Info + boolean found = btDevice.getBluetoothAddress().equals(ArduhomeMIDlet.getCentralMacAddress()); + ConnectionForm.getInstance().updateGaugeStatus("Device found: " + btDevice.getBluetoothAddress() + + (found ? " - Central FOUND!" : " - not central device!")); + + if (found) { + ConnectionForm.getInstance().updateGaugeStatus("Central FOUND!"); + this.remoteDevice = btDevice; + return; + } + + } catch (Exception e) { + System.out.println("Device Discovered Error: " + e); + ConnectionForm.getInstance().updateGaugeStatus("Error on device discovered"); + ConnectionForm.getInstance().append(e.getMessage()); + } + } + + public void inquiryCompleted(int discType) { + if ( remoteDevice != null ) { + services = new Vector(); + UUID[] query = new UUID[1]; + query[0] = RFCOMM_UUID; + try { + discoveryAgent.searchServices(null, query, remoteDevice, this); + } catch (BluetoothStateException ex) { + ex.printStackTrace(); + } + } else { + ConnectionForm.getInstance().updateGaugeStatus("Central not found!"); + } + } + + + + //called when service found during service search + public void servicesDiscovered(int transID, ServiceRecord[] records) { + ConnectionForm.getInstance().updateGaugeStatus("Looking for RFCOMM channel!"); + for(int i = 0; i < records.length; i++) + this.services.addElement(records[i]); + ConnectionForm.getInstance().updateGaugeStatus("Service search completed!"); + } + + //called when service search gets complete + public void serviceSearchCompleted(int transID, int respCode) { + ConnectionForm.getInstance().updateGaugeStatus("callback serviceSearchCompleted"); + if ( remoteDevice != null) { + try { + ConnectionForm.getInstance().updateGaugeStatus("Starting connection..."); + //lets the communication start by setting the url and send client reponse + streamConn = (StreamConnection)Connector.open(((ServiceRecord)(services.elementAt(0))).getConnectionURL(0, false)); + ConnectionForm.getInstance().updateGaugeStatus("Opening communication..."); + os = streamConn.openOutputStream(); + osw = new OutputStreamWriter(os, "US-ASCII"); + is = streamConn.openInputStream(); + isr = new InputStreamReader(is, "US-ASCII"); + + this.connected = true; + + ConnectionForm.getInstance().updateGaugeStatus("Connection Stablished!"); + FlowManager.getInstance().showMainScreen(); + } catch (IOException ex) { + ConnectionForm.getInstance().updateGaugeStatus("Connection error!!"); + ConnectionForm.getInstance().append(ex.getMessage()); + } + + } else { + ConnectionForm.getInstance().updateGaugeStatus("Central not found..."); + } + } + + public void CloseAll() { + try { + if (os != null) { + os.close(); + } + + if (is != null) { + is.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/core/ArduhomeMIDlet.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/core/ArduhomeMIDlet.java new file mode 100644 index 0000000..ad7e732 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/core/ArduhomeMIDlet.java @@ -0,0 +1,44 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.core; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.view.ConnectionForm; +import javax.microedition.lcdui.Display; +import javax.microedition.midlet.*; + +/** + * @author neto + */ +public class ArduhomeMIDlet extends MIDlet { + + private static ArduhomeMIDlet instance; + private static String centralMacAddress; + + public void startApp() { + if ( instance == null ) + instance = this; + + centralMacAddress = FlowManager.loadSettings(); + Display.getDisplay(this).setCurrent(new ConnectionForm()); + BluetoothClientServer.getInstance().InitClient(); + } + + public void pauseApp() { + } + + public void destroyApp(boolean unconditional) { + this.notifyDestroyed(); + } + + public static ArduhomeMIDlet getInstance() { + return instance; + } + + public static String getCentralMacAddress() { + return centralMacAddress; + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/core/FlowManager.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/core/FlowManager.java new file mode 100644 index 0000000..d853acd --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/core/FlowManager.java @@ -0,0 +1,108 @@ +package com.netomarin.arduhome.core; + +import com.netomarin.arduhome.view.DimmerForm; +import com.netomarin.arduhome.view.MainForm; +import com.netomarin.arduhome.view.RGBForm; +import com.netomarin.arduhome.view.RelayForm; +import com.netomarin.arduhome.view.SettingsForm; +import javax.microedition.lcdui.Display; +import javax.microedition.rms.RecordStore; +import javax.microedition.rms.RecordStoreException; + +/** + * + * @author neto + */ +public class FlowManager { + + private static FlowManager instace; + private MainForm mainForm; + private RelayForm relayForm; + private DimmerForm dimmerForm; + private RGBForm rgbForm; + + private FlowManager() { + } + + public static FlowManager getInstance() { + if ( instace == null ) + instace = new FlowManager(); + + return instace; + } + + public void showMainScreen() { + if ( mainForm == null ) + mainForm = new MainForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(mainForm); + } + + public void showRelayForm() { + if ( relayForm == null ) + relayForm = new RelayForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(relayForm); + } + + public void showDimmerForm() { + if ( dimmerForm == null ) + this.dimmerForm = new DimmerForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(dimmerForm); + } + + public void showRGBForm() { + if ( rgbForm == null ) + this.rgbForm = new RGBForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(rgbForm); + } + + public void sendString(String stringToSend) { + + } + + public static String loadSettings() { + RecordStore db = null; + String macAddress = null; + + try { + db = RecordStore.openRecordStore("Settings", true); + if ( db.getNumRecords() > 0 ) { + macAddress = new String(db.getRecord(0)); + } else { + macAddress = SettingsForm.DEFAULT_MAC; + } + } catch (RecordStoreException ex) { + ex.printStackTrace(); + } finally { + try { + db.closeRecordStore(); + } catch (RecordStoreException ex) {} + } + + return macAddress; + } + + public static void saveSettings(String macAddress) { + RecordStore db = null; + + try { + db = RecordStore.openRecordStore("Settings", true); + + if ( db.getNumRecords() > 0 ) { + db.setRecord(0, macAddress.getBytes(), 0, macAddress.getBytes().length); + } else { + db.addRecord(macAddress.getBytes(), 0, macAddress.getBytes().length); + } + + } catch (RecordStoreException ex) { + ex.printStackTrace(); + } finally { + try { + db.closeRecordStore(); + } catch (RecordStoreException ex) {} + } + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/ConnectionForm.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/ConnectionForm.java new file mode 100644 index 0000000..b414697 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/ConnectionForm.java @@ -0,0 +1,62 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.core.ArduhomeMIDlet; +import java.io.IOException; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Gauge; +import javax.microedition.lcdui.Image; +import javax.microedition.lcdui.ImageItem; +import javax.microedition.lcdui.Item; + +/** + * + * @author neto + */ +public class ConnectionForm extends Form implements CommandListener { + + private Gauge gauge; + private ImageItem logoItem; + private Command exitCommand = new Command("Exit", Command.EXIT, 0); + + private static ConnectionForm instance; + + public ConnectionForm() { + super("Connecting"); + instance = this; + try { + logoItem = new ImageItem(null, Image.createImage("arduhomelogo.png"), Item.LAYOUT_VCENTER | Item.LAYOUT_CENTER, null); + this.append(logoItem); + } catch (IOException ex) { + ex.printStackTrace(); + } + + + this.gauge = new Gauge("Conectando a Central...", false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING); + this.append(gauge); + + this.addCommand(exitCommand); + this.setCommandListener(this); + } + + public static ConnectionForm getInstance() { + return instance; + } + + public void commandAction(Command cmnd, Displayable dsplbl) { + if ( cmnd.equals(exitCommand)) { + ArduhomeMIDlet.getInstance().destroyApp(true); + } + } + + public void updateGaugeStatus(String status) { + gauge.setLabel(status); + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/DimmerForm.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/DimmerForm.java new file mode 100644 index 0000000..9e27baf --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/DimmerForm.java @@ -0,0 +1,74 @@ +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.FlowManager; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Gauge; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.ItemCommandListener; +import javax.microedition.lcdui.ItemStateListener; +import javax.microedition.lcdui.StringItem; + +/** + * + * @author netomarin + */ +public class DimmerForm extends Form implements CommandListener, ItemCommandListener, ItemStateListener { + + private Gauge dimmerGauge = new Gauge("Dimmer", true, 9, 0); + + private Command sendCommand = new Command("Send", Command.OK, 0); + private Command backCommand = new Command("Back", Command.BACK, 0); + + private StringItem statusItem = new StringItem("Command sent:", null); + + public DimmerForm() { + super("Dimmer Control"); + + this.append(dimmerGauge); + this.setItemStateListener(this); + this.append(statusItem); + + this.addCommand(backCommand); + this.setCommandListener(this); + + //reseting dimmer + ByteArrayOutputStream bous = new ByteArrayOutputStream(); + bous.write((byte)'B'); + bous.write(9); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + } + + public void commandAction(Command command, Displayable displayable) { + if ( command.equals(backCommand)) { + FlowManager.getInstance().showMainScreen(); + } + } + + public void commandAction(Command cmnd, Item item) { + //throw new UnsupportedOperationException("Not supported yet."); + } + + public void itemStateChanged(Item item) { + if (item.equals(dimmerGauge)) { + try { + ByteArrayOutputStream bous = new ByteArrayOutputStream(); + bous.write((int)'B'); + int dimmerValue = dimmerGauge.getValue(); + if ( dimmerValue == 0 ) + dimmerValue = 9; + bous.write(dimmerValue); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + this.statusItem.setText("B" + dimmerGauge.getValue()); + bous.close(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/MainForm.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/MainForm.java new file mode 100644 index 0000000..90d9bf8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/MainForm.java @@ -0,0 +1,57 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.ArduhomeMIDlet; +import com.netomarin.arduhome.core.FlowManager; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Display; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.List; + +/** + * + * @author neto + */ +public class MainForm extends List implements CommandListener { + + private Command exitCommand = new Command("Exit", Command.EXIT, 0); + private Command selectCommand = new Command("Select", Command.OK, 1); + private Command settingsCommand = new Command("Settings", Command.SCREEN, 2); + + public MainForm() { + super("Arduhome", List.IMPLICIT, new String[]{"Relay", "Dimmer", "RGB Leds"}, null); + + this.setSelectCommand(selectCommand); + this.addCommand(settingsCommand); + this.addCommand(exitCommand); + this.setCommandListener(this); + } + + public void commandAction(Command cmnd, Displayable dsplbl) { + if ( cmnd.equals(exitCommand) ) { + BluetoothClientServer.getInstance().CloseAll(); + ArduhomeMIDlet.getInstance().destroyApp(true); + } else if ( cmnd.equals(settingsCommand) ) { + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(new SettingsForm()); + } else if ( cmnd.equals(selectCommand) ) { + switch (this.getSelectedIndex() ) { + case 0: + FlowManager.getInstance().showRelayForm(); + break; + case 1: + FlowManager.getInstance().showDimmerForm(); + break; + case 2: + FlowManager.getInstance().showRGBForm(); + break; + } + + } + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/RGBForm.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/RGBForm.java new file mode 100644 index 0000000..e696714 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/RGBForm.java @@ -0,0 +1,76 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.FlowManager; +import java.io.ByteArrayOutputStream; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Gauge; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.ItemStateListener; +import javax.microedition.lcdui.StringItem; + +/** + * + * @author neto + */ +public class RGBForm extends Form implements CommandListener, ItemStateListener { + + private Gauge rGauge = new Gauge("Red", true, 9, 0); + private Gauge gGauge = new Gauge("Green", true, 9, 0); + private Gauge bGauge = new Gauge("Blue", true, 9, 0); + + private StringItem statusItem = new StringItem("Command sent:", null); + + private Command backCommand = new Command("Back", Command.BACK, 0); + + public RGBForm() { + super("RGB Leds"); + + this.append(rGauge); + this.append(gGauge); + this.append(bGauge); + this.setItemStateListener(this); + + this.append(statusItem); + + this.addCommand(backCommand); + this.setCommandListener(this); + } + + public void commandAction(Command command, Displayable displayable) { + if ( command.equals(backCommand)) { + FlowManager.getInstance().showMainScreen(); + } + } + + public void itemStateChanged(Item item) { + if (item instanceof Gauge) { + ByteArrayOutputStream bous = new ByteArrayOutputStream(); + bous.write((int)'C'); + bous.write((int)'R'); + bous.write((int)rGauge.getValue()); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + bous.write((int)'C'); + bous.write((int)'R'); + + bous.write((int)gGauge.getValue()); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + + bous.write((int)'C'); + bous.write((int)'R'); + bous.write((int)bGauge.getValue()); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + + this.statusItem.setText("C" + (byte)rGauge.getValue() + (byte)gGauge.getValue() + (byte)bGauge.getValue()); + } + } + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/RelayForm.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/RelayForm.java new file mode 100644 index 0000000..283b5da --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/RelayForm.java @@ -0,0 +1,76 @@ +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.FlowManager; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.ItemCommandListener; +import javax.microedition.lcdui.StringItem; + +/** + * + * @author neto + */ +public class RelayForm extends Form implements CommandListener, ItemCommandListener { + + private Command backCommand = new Command("Back", Command.BACK, 0); + private Command buttonCommand = new Command("Execute", Command.OK, 0); + + private StringItem lightState = new StringItem(null, "Turn ON", Item.BUTTON); + private StringItem discoMode = new StringItem(null, "DISCO!!", Item.BUTTON); + + private boolean lightOn = false; + private boolean discoOn = false; + String msg = null; + + public RelayForm() { + super("Relay Control"); + + this.lightState.setLayout(Item.LAYOUT_NEWLINE_AFTER); + + this.append(lightState); + this.append(discoMode); + lightState.setDefaultCommand(buttonCommand); + lightState.setItemCommandListener(this); + discoMode.setDefaultCommand(buttonCommand); + discoMode.setItemCommandListener(this); + + this.addCommand(backCommand); + this.setCommandListener(this); + } + + public void commandAction(Command command, Displayable displayable) { + if ( command.equals(backCommand)) { + FlowManager.getInstance().showMainScreen(); + } + } + + public void commandAction(Command command, Item item) { + if ( item.equals(lightState)) { + if ( lightOn ) { + msg = "A+A"; + lightState.setText("Turn OFF"); + } else { + msg = "A-A"; + lightState.setText("Turn ON"); + } + + lightOn = !lightOn; + } else if ( item.equals(discoMode)) { + if ( discoOn ) { + msg = "A+C"; + lightState.setText("STOP Disco!"); + } else { + msg = "A-C"; + lightState.setText("DISCO!!"); + } + + discoOn = !discoOn; + } + + BluetoothClientServer.getInstance().sendMessage(msg.getBytes()); + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/SettingsForm.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/SettingsForm.java new file mode 100644 index 0000000..049d49f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/SettingsForm.java @@ -0,0 +1,46 @@ +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.core.FlowManager; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.TextField; + +/** + * + * @author neto + */ +public class SettingsForm extends Form implements CommandListener { + + //public static final String DEFAULT_MAC = "0006660412A9"; //bluesmirf + public static final String DEFAULT_MAC = "00066604127D"; //bluesmirf + //public static final String DEFAULT_MAC = "000666041225"; //bluesmirf + + private Command backCommand = new Command("Back", Command.BACK, 0); + private Command saveCommand = new Command("Save", Command.OK, 1); + + private TextField macAddressTextField; + + public SettingsForm() { + super("Settings"); + + String macAddress = FlowManager.loadSettings(); + macAddressTextField = new TextField("Bluetooth: ", + macAddress == null ? DEFAULT_MAC : macAddress, 12, TextField.ANY); + this.append(macAddressTextField); + + this.setCommandListener(this); + this.addCommand(backCommand); + this.addCommand(saveCommand); + } + + public void commandAction(Command cmnd, Displayable dsplbl) { + if ( cmnd.equals(backCommand) ) { + FlowManager.getInstance().showMainScreen(); + } else if ( cmnd.equals(saveCommand)) { + FlowManager.saveSettings(macAddressTextField.getString()); + FlowManager.getInstance().showMainScreen(); + } + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/dist/Arduhome.jad b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/dist/Arduhome.jad new file mode 100644 index 0000000..ca37a2f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/dist/Arduhome.jad @@ -0,0 +1,9 @@ +MIDlet-1: Arduhome,,com.netomarin.arduhome.core.ArduhomeMIDlet +MIDlet-Jar-Size: 16116 +MIDlet-Jar-URL: Arduhome.jar +MIDlet-Name: Arduhome +MIDlet-Permissions: javax.microedition.io.Connector.bluetooth.client +MIDlet-Vendor: Globalcode - Eversource +MIDlet-Version: 1.0 +MicroEdition-Configuration: CLDC-1.1 +MicroEdition-Profile: MIDP-2.0 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/build-impl.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/build-impl.xml new file mode 100644 index 0000000..7763b1b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/build-impl.xml @@ -0,0 +1,1247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Classpath to J2ME Ant extension library (libs.j2me_ant_ext.classpath property) is not set. For example: location of mobility/modules/org-netbeans-mobility-antext.jar file in the IDE installation directory. + Platform home (platform.home property) is not set. Value of this property should be ${platform.active.description} emulator home directory location. + Platform boot classpath (platform.bootclasspath property) is not set. Value of this property should be ${platform.active.description} emulator boot classpath containing all J2ME classes provided by emulator. + Must set src.dir + Must set build.dir + Must set dist.dir + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set preprocessed.dir + + + + + + + + + + + + + + + + + + Must set build.classes.dir + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + Must set obfuscated.classes.dir + + + + Must set obfuscated.classes.dir + Must set obfuscator.srcjar + Must set obfuscator.destjar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set preverify.classes.dir + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MicroEdition-Configuration: ${platform.configuration} + + MicroEdition-Configuration: ${platform.configuration} + + + + MicroEdition-Profile: ${platform.profile} + + MicroEdition-Profile: ${platform.profile} + + + + Must set dist.jad + + + + + + + + + + + + + + + + + + + + + + + + ${manifest.midlets}${evaluated.manifest.apipermissions}${evaluated.manifest.pushregistry}${manifest.others}${manifest.jad} + ${manifest.midlets}${evaluated.manifest.apipermissions}${evaluated.manifest.pushregistry}${manifest.others}${manifest.manifest} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Starting emulator with port number ${active.debug.port} + + + + + + + + + + + + + + + + + Starting emulator with port number ${active.debug.port} + + + + + + + + + + + + + + + + + Must set dist.javadoc.dir + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${all.configurations} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property deployment.${deployment.method}.scriptfile not set. The property should point to an Ant script providing ${deployment.method} deployment. + + + + + + + + Classpath to Ant Contrib library (libs.ant-contrib.classpath property) is not set. + + + + + + + + + Active project configuration: @{cfg} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property build.root.dir is not set. By default its value should be \"build\". + Property dist.root.dir is not set. By default its value should be \"dist\". + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/genfiles.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/genfiles.properties new file mode 100644 index 0000000..166b8a6 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +build.xml.data.CRC32=6394fea5 +build.xml.script.CRC32=f4991ba4 +build.xml.stylesheet.CRC32=9c6a911d +nbproject/build-impl.xml.data.CRC32=6394fea5 +nbproject/build-impl.xml.script.CRC32=97fa5ec4 +nbproject/build-impl.xml.stylesheet.CRC32=e46c2d22 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/private/private.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/private/private.properties new file mode 100644 index 0000000..480594c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/private/private.properties @@ -0,0 +1,8 @@ +#Wed, 12 Sep 2012 11:58:51 -0300 +#Sat Aug 28 14:40:55 BRT 2010 +netbeans.user=/home/vsenger/.netbeans/7.2 +javadoc.preview=true +config.active= +deployment.counter=86 +app-version.autoincrement=true +deployment.number=0.0.85 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/private/private.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/private/private.xml new file mode 100644 index 0000000..c1f155a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/project.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/project.properties new file mode 100644 index 0000000..b2f15d1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/project.properties @@ -0,0 +1,144 @@ +abilities=MMAPI=1.2,JSR82=1.1,JSR280=1.0,JSR226=1.0,MIDP=2.1,JSR229=1.1,SATSA=1.0,CLDC=1.1,JSR177=1.0,JSR179=1.0,J2MEWS=1.0,WMA=2.0,JSR172=1.0,JSR256=1.2,OBEX=1.0,ColorScreen,JSR238=1.0,TouchScreen,JSR211=1.0,ScreenWidth=240,JSR75=1.0,JSR184=1.1,ScreenHeight=320,ScreenColorDepth=16,JSR180=1.1.0, +all.configurations=\ +application.args= +application.description= +application.description.detail= +application.name= +application.vendor=Vendor +build.classes.dir=${build.dir}/compiled +build.classes.excludes=**/*.java,**/*.form,**/*.class,**/.nbintdb,**/*.mvd,**/*.wsclient,**/*.vmd +build.dir=build/${config.active} +build.root.dir=build +debug.level=debug +debugger.timeout= +deployment.copy.target=${file.reference.site-jme} +deployment.instance=default +deployment.jarurl=${dist.jar} +deployment.method=Copy +deployment.override.jarurl=false +dist.dir=dist/${config.active} +dist.jad=Arduhome.jad +dist.jar=Arduhome.jar +dist.javadoc.dir=${dist.dir}/doc +dist.root.dir=dist +extra.classpath= +file.reference.builtin.ks=${netbeans.user}/config/j2me/builtin.ks +file.reference.site-jme=../../../../../../../var/www/site/jme +filter.exclude.tests=false +filter.excludes= +filter.more.excludes=**/overview.html,**/package.html +filter.use.standard=true +jar.compress=true +javac.debug=true +javac.deprecation=false +javac.encoding=UTF-8 +javac.optimize=false +javac.source=1.3 +javac.target=1.3 +javadoc.author=false +javadoc.encoding= +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +libs.classpath=${libs.JMUnit4CLDC10.classpath} +main.class= +main.class.class=applet +manifest.apipermissions=MIDlet-Permissions: javax.microedition.io.Connector.bluetooth.client\n +manifest.file=manifest.mf +manifest.is.liblet=false +manifest.jad= +manifest.manifest= +manifest.midlets=MIDlet-1: Arduhome,,com.netomarin.arduhome.core.ArduhomeMIDlet\n +manifest.others=MIDlet-Vendor: Globalcode - Eversource\nMIDlet-Name: Arduhome\nMIDlet-Version: 1.0\n +manifest.pushregistry= +name=Arduhome +no.dependencies=false +nokiaS80.application.icon= +nsicom.application.monitorhost= +nsicom.application.runremote= +nsicom.application.runverbose= +nsicom.remoteapp.location=\\My Documents\\NetBeans Applications +nsicom.remotevm.location=\\Windows\\creme\\bin\\CrEme.exe +obfuscated.classes.dir=${build.dir}/obfuscated +obfuscation.custom= +obfuscation.level=0 +obfuscator.destjar=${build.dir}/obfuscated.jar +obfuscator.srcjar=${build.dir}/before-obfuscation.jar +platform.active=Sun_Java_TM__Wireless_Toolkit_2_5_2_01_for_CLDC +platform.active.description=Sun Java(TM) Wireless Toolkit 2.5.2_01 for CLDC +platform.apis=JSR238-1.0,WMA-2.0,MMAPI-1.1,JSR211-1.0,JSR179-1.0.1,OBEX-1.0,JSR177-1.0,JSR234-1.0,SATSA-APDU-1.0,JSR75-1.0,J2ME-WS-1.0,J2ME-XMLRPC-1.0,SATSA-JCRMI-1.0,SATSA-CRYPTO-1.0,JSR239-1.0,JSR184-1.1,JSR229-1.1.0,SATSA-PKI-1.0,JSR180-1.0.1,JSR226-1.0 +platform.bootclasspath=${platform.home}/lib/jsr226.jar:${platform.home}/lib/satsa-crypto.jar:${platform.home}/lib/jsr229.jar:${platform.home}/lib/jsr238.jar:${platform.home}/lib/j2me-xmlrpc.jar:${platform.home}/lib/jsr211.jar:${platform.home}/lib/satsa-jcrmi.jar:${platform.home}/lib/satsa-apdu.jar:${platform.home}/lib/jsr082.jar:${platform.home}/lib/jsr184.jar:${platform.home}/lib/jsr239.jar:${platform.home}/lib/jsr75.jar:${platform.home}/lib/jsr179.jar:${platform.home}/lib/satsa-pki.jar:${platform.home}/lib/jsr180.jar:${platform.home}/lib/mmapi.jar:${platform.home}/lib/j2me-ws.jar:${platform.home}/lib/wma20.jar:${platform.home}/lib/jsr234.jar:${platform.home}/lib/cldcapi11.jar:${platform.home}/lib/midpapi20.jar +platform.configuration=CLDC-1.1 +platform.device=QwertyDevice +platform.fat.jar=true +platform.profile=MIDP-2.0 +platform.trigger=CLDC +platform.type=UEI-1.0.1 +preprocessed.dir=${build.dir}/preprocessed +preverify.classes.dir=${build.dir}/preverified +preverify.sources.dir=${build.dir}/preverifysrc +resources.dir=resources +ricoh.application.email= +ricoh.application.fax= +ricoh.application.icon= +ricoh.application.target-jar= +ricoh.application.telephone= +ricoh.application.uid=81936294 +ricoh.application.version= +ricoh.dalp.application-desc.auto-run=false +ricoh.dalp.application-desc.energy-save= +ricoh.dalp.application-desc.exec-auth= +ricoh.dalp.application-desc.visible=true +ricoh.dalp.argument= +ricoh.dalp.codebase= +ricoh.dalp.display-mode.color=true +ricoh.dalp.display-mode.is-4line-support=false +ricoh.dalp.display-mode.is-hvga-support=true +ricoh.dalp.display-mode.is-vga-support=false +ricoh.dalp.display-mode.is-wvga-support=false +ricoh.dalp.information.abbreviation= +ricoh.dalp.information.icon.basepath= +ricoh.dalp.information.icon.location= +ricoh.dalp.information.is-icon-used=true +ricoh.dalp.install.destination=hdd +ricoh.dalp.install.mode.auto=true +ricoh.dalp.install.work-dir=hdd +ricoh.dalp.is-managed=true +ricoh.dalp.resources.dsdk.version=2.0 +ricoh.dalp.resources.jar.basepath= +ricoh.dalp.resources.jar.version= +ricoh.dalp.version= +ricoh.icon.invert=false +ricoh.platform.target.version= +run.cmd.options= +run.jvmargs= +run.method=STANDARD +run.security.domain=manufacturer +run.use.security.domain=false +savaje.application.icon= +savaje.application.icon.focused= +savaje.application.icon.small= +savaje.application.uid=TBD +savaje.bundle.base= +savaje.bundle.debug=false +savaje.bundle.debug.port= +semc.application.caps= +semc.application.icon= +semc.application.icon.count= +semc.application.icon.splash= +semc.application.icon.splash.installonly=false +semc.application.uid=E3212324 +semc.certificate.path= +semc.private.key.password= +semc.private.key.path= +sign.alias=minimal +sign.enabled=false +sign.keystore=${file.reference.builtin.ks} +src.dir=src +use.emptyapis=true +use.preprocessor=true diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/project.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/project.xml new file mode 100644 index 0000000..dbd8432 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/nbproject/project.xml @@ -0,0 +1,10 @@ + + + org.netbeans.modules.kjava.j2meproject + + + Arduhome + 1.6 + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/res/.DS_Store b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/res/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/res/.DS_Store differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/res/arduhomeicon.png b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/res/arduhomeicon.png new file mode 100644 index 0000000..41237ed Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/res/arduhomeicon.png differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/res/arduhomelogo.png b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/res/arduhomelogo.png new file mode 100644 index 0000000..1a2307c Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/res/arduhomelogo.png differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/res/logo.gif b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/res/logo.gif new file mode 100644 index 0000000..fae584e Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/res/logo.gif differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/bt/BluetoothClientServer.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/bt/BluetoothClientServer.java new file mode 100644 index 0000000..c850d53 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/bt/BluetoothClientServer.java @@ -0,0 +1,201 @@ +package com.netomarin.arduhome.bt; + +import com.netomarin.arduhome.core.ArduhomeMIDlet; +import com.netomarin.arduhome.core.FlowManager; +import com.netomarin.arduhome.view.ConnectionForm; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.Vector; + +import javax.bluetooth.BluetoothStateException; +import javax.bluetooth.DeviceClass; +import javax.bluetooth.DiscoveryAgent; +import javax.bluetooth.DiscoveryListener; +import javax.bluetooth.LocalDevice; +import javax.bluetooth.RemoteDevice; +import javax.bluetooth.ServiceRecord; +import javax.bluetooth.UUID; +import javax.microedition.io.Connector; +import javax.microedition.io.StreamConnection; + +/** + * + * @author Neto Marin + */ +public class BluetoothClientServer implements DiscoveryListener { + + UUID RFCOMM_UUID = new UUID(0x1101); + private StreamConnection streamConn = null; + private LocalDevice localDevice = null; + private InputStream is = null; + private InputStreamReader isr = null; + private OutputStream os = null; + private OutputStreamWriter osw = null; + private DiscoveryAgent discoveryAgent = null; + private RemoteDevice remoteDevice; + private Vector services; + private static BluetoothClientServer instance; + private boolean connected = false; + + private BluetoothClientServer() { + } + + public static BluetoothClientServer getInstance() { + if (instance == null) { + instance = new BluetoothClientServer(); + } + + return instance; + } + + public void initClient() { + searchAvailDevices(); + + } + + public void searchAvailDevices() { + try { + //First get the local device and obtain the discovery agent. + this.remoteDevice = null; + localDevice = LocalDevice.getLocalDevice(); + discoveryAgent = localDevice.getDiscoveryAgent(); + ConnectionForm.getInstance().updateGaugeStatus("Starting search..."); + discoveryAgent.startInquiry(DiscoveryAgent.GIAC, this); + } catch (BluetoothStateException ex) { + System.out.println("Problem in searching the blue tooth devices"); + ConnectionForm.getInstance().updateGaugeStatus("Error searching devics!!"); + ConnectionForm.getInstance().append(ex.getMessage()); + } + } + + public void sendMessage(byte[] messageToSend) { + try { + //osw.write(messageToSend); + //osw.flush(); + os.write(messageToSend); + os.flush(); + } catch (IOException ex) { + } + } + + public String RecieveMessages() { + byte[] data = null; + + try { + int length = is.read(); + data = new byte[length]; + length = 0; + + while (length != data.length) { + int ch = is.read(data, length, data.length - length); + + if (ch == -1) { + throw new IOException("Can't read data"); + } + length += ch; + } + } catch (IOException e) { + System.err.println(e); +// MainForm.updateConnectionStatus("Error receiving messages!"); + } + + return new String(data); + } + + /** + * ******************************************************************************************* + * below are the pure virtual methods of discoverlistern + * + * + ****************************************************************************************** + */ + //Called when device is found during inquiry + public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { + try { + // Get Device Info + boolean found = btDevice.getBluetoothAddress().equals(ArduhomeMIDlet.getCentralMacAddress()); + ConnectionForm.getInstance().updateGaugeStatus("Device found: " + btDevice.getBluetoothAddress() + + (found ? " - Central FOUND!" : " - not central device!")); + + if (found) { + ConnectionForm.getInstance().updateGaugeStatus("Central FOUND!"); + this.remoteDevice = btDevice; + return; + } + + } catch (Exception e) { + System.out.println("Device Discovered Error: " + e); + ConnectionForm.getInstance().updateGaugeStatus("Error on device discovered"); + ConnectionForm.getInstance().append(e.getMessage()); + } + } + + public void inquiryCompleted(int discType) { + if (remoteDevice != null) { + services = new Vector(); + UUID[] query = new UUID[1]; + query[0] = RFCOMM_UUID; + try { + discoveryAgent.searchServices(null, query, remoteDevice, this); + } catch (BluetoothStateException ex) { + ex.printStackTrace(); + } + } else { + ConnectionForm.getInstance().updateGaugeStatus("Central not found!"); + } + } + + //called when service found during service search + public void servicesDiscovered(int transID, ServiceRecord[] records) { + ConnectionForm.getInstance().updateGaugeStatus("Looking for RFCOMM channel!"); + for (int i = 0; i < records.length; i++) { + this.services.addElement(records[i]); + } + ConnectionForm.getInstance().updateGaugeStatus("Service search completed!"); + } + + //called when service search gets complete + public void serviceSearchCompleted(int transID, int respCode) { + ConnectionForm.getInstance().updateGaugeStatus("callback serviceSearchCompleted"); + if (remoteDevice != null) { + try { + ConnectionForm.getInstance().updateGaugeStatus("Starting connection..."); + //lets the communication start by setting the url and send client reponse + streamConn = (StreamConnection) Connector.open(((ServiceRecord) (services.elementAt(0))).getConnectionURL(0, false)); + ConnectionForm.getInstance().updateGaugeStatus("Opening communication..."); + os = streamConn.openOutputStream(); + osw = new OutputStreamWriter(os, "US-ASCII"); + is = streamConn.openInputStream(); + isr = new InputStreamReader(is, "US-ASCII"); + + this.connected = true; + + ConnectionForm.getInstance().updateGaugeStatus("Connection Stablished!"); + FlowManager.getInstance().showMainScreen(); + } catch (IOException ex) { + ConnectionForm.getInstance().updateGaugeStatus("Connection error!!"); + ConnectionForm.getInstance().append(ex.getMessage()); + } + + } else { + ConnectionForm.getInstance().updateGaugeStatus("Central not found..."); + } + } + + public void CloseAll() { + try { + if (os != null) { + os.close(); + } + + if (is != null) { + is.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/bt/NewEmptyJMUnitTest.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/bt/NewEmptyJMUnitTest.java new file mode 100644 index 0000000..e9b2d5b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/bt/NewEmptyJMUnitTest.java @@ -0,0 +1,23 @@ +/* + * NewEmptyJMUnitTest.java + * JMUnit based test + * + * Created on 12/09/2012, 14:37:41 + */ +package com.netomarin.arduhome.bt; + +import jmunit.framework.cldc10.*; + +/** + * @author vsenger + */ +public class NewEmptyJMUnitTest extends TestCase { + + public NewEmptyJMUnitTest() { + //The first parameter of inherited constructor is the number of test cases + super(0, "NewEmptyJMUnitTest"); + } + + public void test(int testNumber) throws Throwable { + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/core/ArduhomeMIDlet.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/core/ArduhomeMIDlet.java new file mode 100644 index 0000000..24e13b4 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/core/ArduhomeMIDlet.java @@ -0,0 +1,44 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.core; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.view.ConnectionForm; +import javax.microedition.lcdui.Display; +import javax.microedition.midlet.*; + +/** + * @author neto + */ +public class ArduhomeMIDlet extends MIDlet { + + private static ArduhomeMIDlet instance; + private static String centralMacAddress; + + public void startApp() { + if ( instance == null ) + instance = this; + + centralMacAddress = FlowManager.loadSettings(); + Display.getDisplay(this).setCurrent(new ConnectionForm()); + BluetoothClientServer.getInstance().initClient(); + } + + public void pauseApp() { + } + + public void destroyApp(boolean unconditional) { + this.notifyDestroyed(); + } + + public static ArduhomeMIDlet getInstance() { + return instance; + } + + public static String getCentralMacAddress() { + return centralMacAddress; + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/core/FlowManager.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/core/FlowManager.java new file mode 100644 index 0000000..d853acd --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/core/FlowManager.java @@ -0,0 +1,108 @@ +package com.netomarin.arduhome.core; + +import com.netomarin.arduhome.view.DimmerForm; +import com.netomarin.arduhome.view.MainForm; +import com.netomarin.arduhome.view.RGBForm; +import com.netomarin.arduhome.view.RelayForm; +import com.netomarin.arduhome.view.SettingsForm; +import javax.microedition.lcdui.Display; +import javax.microedition.rms.RecordStore; +import javax.microedition.rms.RecordStoreException; + +/** + * + * @author neto + */ +public class FlowManager { + + private static FlowManager instace; + private MainForm mainForm; + private RelayForm relayForm; + private DimmerForm dimmerForm; + private RGBForm rgbForm; + + private FlowManager() { + } + + public static FlowManager getInstance() { + if ( instace == null ) + instace = new FlowManager(); + + return instace; + } + + public void showMainScreen() { + if ( mainForm == null ) + mainForm = new MainForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(mainForm); + } + + public void showRelayForm() { + if ( relayForm == null ) + relayForm = new RelayForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(relayForm); + } + + public void showDimmerForm() { + if ( dimmerForm == null ) + this.dimmerForm = new DimmerForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(dimmerForm); + } + + public void showRGBForm() { + if ( rgbForm == null ) + this.rgbForm = new RGBForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(rgbForm); + } + + public void sendString(String stringToSend) { + + } + + public static String loadSettings() { + RecordStore db = null; + String macAddress = null; + + try { + db = RecordStore.openRecordStore("Settings", true); + if ( db.getNumRecords() > 0 ) { + macAddress = new String(db.getRecord(0)); + } else { + macAddress = SettingsForm.DEFAULT_MAC; + } + } catch (RecordStoreException ex) { + ex.printStackTrace(); + } finally { + try { + db.closeRecordStore(); + } catch (RecordStoreException ex) {} + } + + return macAddress; + } + + public static void saveSettings(String macAddress) { + RecordStore db = null; + + try { + db = RecordStore.openRecordStore("Settings", true); + + if ( db.getNumRecords() > 0 ) { + db.setRecord(0, macAddress.getBytes(), 0, macAddress.getBytes().length); + } else { + db.addRecord(macAddress.getBytes(), 0, macAddress.getBytes().length); + } + + } catch (RecordStoreException ex) { + ex.printStackTrace(); + } finally { + try { + db.closeRecordStore(); + } catch (RecordStoreException ex) {} + } + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/ConnectionForm.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/ConnectionForm.java new file mode 100644 index 0000000..b414697 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/ConnectionForm.java @@ -0,0 +1,62 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.core.ArduhomeMIDlet; +import java.io.IOException; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Gauge; +import javax.microedition.lcdui.Image; +import javax.microedition.lcdui.ImageItem; +import javax.microedition.lcdui.Item; + +/** + * + * @author neto + */ +public class ConnectionForm extends Form implements CommandListener { + + private Gauge gauge; + private ImageItem logoItem; + private Command exitCommand = new Command("Exit", Command.EXIT, 0); + + private static ConnectionForm instance; + + public ConnectionForm() { + super("Connecting"); + instance = this; + try { + logoItem = new ImageItem(null, Image.createImage("arduhomelogo.png"), Item.LAYOUT_VCENTER | Item.LAYOUT_CENTER, null); + this.append(logoItem); + } catch (IOException ex) { + ex.printStackTrace(); + } + + + this.gauge = new Gauge("Conectando a Central...", false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING); + this.append(gauge); + + this.addCommand(exitCommand); + this.setCommandListener(this); + } + + public static ConnectionForm getInstance() { + return instance; + } + + public void commandAction(Command cmnd, Displayable dsplbl) { + if ( cmnd.equals(exitCommand)) { + ArduhomeMIDlet.getInstance().destroyApp(true); + } + } + + public void updateGaugeStatus(String status) { + gauge.setLabel(status); + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/DimmerForm.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/DimmerForm.java new file mode 100644 index 0000000..9e27baf --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/DimmerForm.java @@ -0,0 +1,74 @@ +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.FlowManager; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Gauge; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.ItemCommandListener; +import javax.microedition.lcdui.ItemStateListener; +import javax.microedition.lcdui.StringItem; + +/** + * + * @author netomarin + */ +public class DimmerForm extends Form implements CommandListener, ItemCommandListener, ItemStateListener { + + private Gauge dimmerGauge = new Gauge("Dimmer", true, 9, 0); + + private Command sendCommand = new Command("Send", Command.OK, 0); + private Command backCommand = new Command("Back", Command.BACK, 0); + + private StringItem statusItem = new StringItem("Command sent:", null); + + public DimmerForm() { + super("Dimmer Control"); + + this.append(dimmerGauge); + this.setItemStateListener(this); + this.append(statusItem); + + this.addCommand(backCommand); + this.setCommandListener(this); + + //reseting dimmer + ByteArrayOutputStream bous = new ByteArrayOutputStream(); + bous.write((byte)'B'); + bous.write(9); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + } + + public void commandAction(Command command, Displayable displayable) { + if ( command.equals(backCommand)) { + FlowManager.getInstance().showMainScreen(); + } + } + + public void commandAction(Command cmnd, Item item) { + //throw new UnsupportedOperationException("Not supported yet."); + } + + public void itemStateChanged(Item item) { + if (item.equals(dimmerGauge)) { + try { + ByteArrayOutputStream bous = new ByteArrayOutputStream(); + bous.write((int)'B'); + int dimmerValue = dimmerGauge.getValue(); + if ( dimmerValue == 0 ) + dimmerValue = 9; + bous.write(dimmerValue); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + this.statusItem.setText("B" + dimmerGauge.getValue()); + bous.close(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/MainForm.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/MainForm.java new file mode 100644 index 0000000..90d9bf8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/MainForm.java @@ -0,0 +1,57 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.ArduhomeMIDlet; +import com.netomarin.arduhome.core.FlowManager; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Display; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.List; + +/** + * + * @author neto + */ +public class MainForm extends List implements CommandListener { + + private Command exitCommand = new Command("Exit", Command.EXIT, 0); + private Command selectCommand = new Command("Select", Command.OK, 1); + private Command settingsCommand = new Command("Settings", Command.SCREEN, 2); + + public MainForm() { + super("Arduhome", List.IMPLICIT, new String[]{"Relay", "Dimmer", "RGB Leds"}, null); + + this.setSelectCommand(selectCommand); + this.addCommand(settingsCommand); + this.addCommand(exitCommand); + this.setCommandListener(this); + } + + public void commandAction(Command cmnd, Displayable dsplbl) { + if ( cmnd.equals(exitCommand) ) { + BluetoothClientServer.getInstance().CloseAll(); + ArduhomeMIDlet.getInstance().destroyApp(true); + } else if ( cmnd.equals(settingsCommand) ) { + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(new SettingsForm()); + } else if ( cmnd.equals(selectCommand) ) { + switch (this.getSelectedIndex() ) { + case 0: + FlowManager.getInstance().showRelayForm(); + break; + case 1: + FlowManager.getInstance().showDimmerForm(); + break; + case 2: + FlowManager.getInstance().showRGBForm(); + break; + } + + } + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/RGBForm.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/RGBForm.java new file mode 100644 index 0000000..e696714 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/RGBForm.java @@ -0,0 +1,76 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.FlowManager; +import java.io.ByteArrayOutputStream; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Gauge; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.ItemStateListener; +import javax.microedition.lcdui.StringItem; + +/** + * + * @author neto + */ +public class RGBForm extends Form implements CommandListener, ItemStateListener { + + private Gauge rGauge = new Gauge("Red", true, 9, 0); + private Gauge gGauge = new Gauge("Green", true, 9, 0); + private Gauge bGauge = new Gauge("Blue", true, 9, 0); + + private StringItem statusItem = new StringItem("Command sent:", null); + + private Command backCommand = new Command("Back", Command.BACK, 0); + + public RGBForm() { + super("RGB Leds"); + + this.append(rGauge); + this.append(gGauge); + this.append(bGauge); + this.setItemStateListener(this); + + this.append(statusItem); + + this.addCommand(backCommand); + this.setCommandListener(this); + } + + public void commandAction(Command command, Displayable displayable) { + if ( command.equals(backCommand)) { + FlowManager.getInstance().showMainScreen(); + } + } + + public void itemStateChanged(Item item) { + if (item instanceof Gauge) { + ByteArrayOutputStream bous = new ByteArrayOutputStream(); + bous.write((int)'C'); + bous.write((int)'R'); + bous.write((int)rGauge.getValue()); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + bous.write((int)'C'); + bous.write((int)'R'); + + bous.write((int)gGauge.getValue()); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + + bous.write((int)'C'); + bous.write((int)'R'); + bous.write((int)bGauge.getValue()); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + + this.statusItem.setText("C" + (byte)rGauge.getValue() + (byte)gGauge.getValue() + (byte)bGauge.getValue()); + } + } + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/RelayForm.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/RelayForm.java new file mode 100644 index 0000000..283b5da --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/RelayForm.java @@ -0,0 +1,76 @@ +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.FlowManager; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.ItemCommandListener; +import javax.microedition.lcdui.StringItem; + +/** + * + * @author neto + */ +public class RelayForm extends Form implements CommandListener, ItemCommandListener { + + private Command backCommand = new Command("Back", Command.BACK, 0); + private Command buttonCommand = new Command("Execute", Command.OK, 0); + + private StringItem lightState = new StringItem(null, "Turn ON", Item.BUTTON); + private StringItem discoMode = new StringItem(null, "DISCO!!", Item.BUTTON); + + private boolean lightOn = false; + private boolean discoOn = false; + String msg = null; + + public RelayForm() { + super("Relay Control"); + + this.lightState.setLayout(Item.LAYOUT_NEWLINE_AFTER); + + this.append(lightState); + this.append(discoMode); + lightState.setDefaultCommand(buttonCommand); + lightState.setItemCommandListener(this); + discoMode.setDefaultCommand(buttonCommand); + discoMode.setItemCommandListener(this); + + this.addCommand(backCommand); + this.setCommandListener(this); + } + + public void commandAction(Command command, Displayable displayable) { + if ( command.equals(backCommand)) { + FlowManager.getInstance().showMainScreen(); + } + } + + public void commandAction(Command command, Item item) { + if ( item.equals(lightState)) { + if ( lightOn ) { + msg = "A+A"; + lightState.setText("Turn OFF"); + } else { + msg = "A-A"; + lightState.setText("Turn ON"); + } + + lightOn = !lightOn; + } else if ( item.equals(discoMode)) { + if ( discoOn ) { + msg = "A+C"; + lightState.setText("STOP Disco!"); + } else { + msg = "A-C"; + lightState.setText("DISCO!!"); + } + + discoOn = !discoOn; + } + + BluetoothClientServer.getInstance().sendMessage(msg.getBytes()); + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/SettingsForm.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/SettingsForm.java new file mode 100644 index 0000000..049d49f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/SettingsForm.java @@ -0,0 +1,46 @@ +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.core.FlowManager; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.TextField; + +/** + * + * @author neto + */ +public class SettingsForm extends Form implements CommandListener { + + //public static final String DEFAULT_MAC = "0006660412A9"; //bluesmirf + public static final String DEFAULT_MAC = "00066604127D"; //bluesmirf + //public static final String DEFAULT_MAC = "000666041225"; //bluesmirf + + private Command backCommand = new Command("Back", Command.BACK, 0); + private Command saveCommand = new Command("Save", Command.OK, 1); + + private TextField macAddressTextField; + + public SettingsForm() { + super("Settings"); + + String macAddress = FlowManager.loadSettings(); + macAddressTextField = new TextField("Bluetooth: ", + macAddress == null ? DEFAULT_MAC : macAddress, 12, TextField.ANY); + this.append(macAddressTextField); + + this.setCommandListener(this); + this.addCommand(backCommand); + this.addCommand(saveCommand); + } + + public void commandAction(Command cmnd, Displayable dsplbl) { + if ( cmnd.equals(backCommand) ) { + FlowManager.getInstance().showMainScreen(); + } else if ( cmnd.equals(saveCommand)) { + FlowManager.saveSettings(macAddressTextField.getString()); + FlowManager.getInstance().showMainScreen(); + } + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/build.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/build.xml new file mode 100644 index 0000000..387c825 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/build.xml @@ -0,0 +1,47 @@ + + + + + + Builds, tests, and runs the project ArduhomeJavaFX. + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/build/compiled/desktopapplication1/Main.fxc b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/build/compiled/desktopapplication1/Main.fxc new file mode 100644 index 0000000..101ad23 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/build/compiled/desktopapplication1/Main.fxc @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/build/compiled/org/netbeans/javafx/design/md5sums.md5 b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/build/compiled/org/netbeans/javafx/design/md5sums.md5 new file mode 100644 index 0000000..9bd8b6e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/build/compiled/org/netbeans/javafx/design/md5sums.md5 @@ -0,0 +1,2 @@ +0175d1cc2edc8cfc8a24505f1c3dc94d DesignState.fx +2d7e067ad3042476a4539c95835ca643 DesignStateChangeType.java diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1.html b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1.html new file mode 100644 index 0000000..934432d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1.html @@ -0,0 +1,22 @@ + + + +DesktopApplication1 + + +

DesktopApplication1

+ + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1.jnlp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1.jnlp new file mode 100644 index 0000000..cf2bb15 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1.jnlp @@ -0,0 +1,21 @@ + + + + DesktopApplication1 + vsenger + + DesktopApplication1 + + + + + + + + + + + MainJavaFXScript=desktopapplication1.Main + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1_browser.jnlp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1_browser.jnlp new file mode 100644 index 0000000..e6170d9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1_browser.jnlp @@ -0,0 +1,21 @@ + + + + DesktopApplication1 + vsenger + + DesktopApplication1 + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/build-impl.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/build-impl.xml new file mode 100644 index 0000000..01d6c4f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/build-impl.xml @@ -0,0 +1,397 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set build.dir + Must set dist.dir + Must set dist.javadoc.dir + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/genfiles.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/genfiles.properties new file mode 100644 index 0000000..9162bad --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=74174ecf +build.xml.script.CRC32=918ef008 +build.xml.stylesheet.CRC32=37714ed0@1.11.2 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=74174ecf +nbproject/build-impl.xml.script.CRC32=8ed6c15f +nbproject/build-impl.xml.stylesheet.CRC32=f3287c92@1.11.2 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/config.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/private.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/private.properties new file mode 100644 index 0000000..1ccfb47 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/private.properties @@ -0,0 +1,5 @@ +application.args=\ +javac.debug=true +javadoc.preview=true +mobile.device=DefaultFxPhone1 +user.properties.file=/home/vsenger/.netbeans/6.9/build.properties diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/private.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/private.xml new file mode 100644 index 0000000..1fb0a64 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/private.xml @@ -0,0 +1,7 @@ + + + + + file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/project.properties b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/project.properties new file mode 100644 index 0000000..a3216b4 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/project.properties @@ -0,0 +1,55 @@ +applet.draggable=true +applet.height=200 +applet.width=200 +application.title=DesktopApplication1 +application.vendor=vsenger +build.classes.excludes=**/*.java,**/*.form,**/*.fx +build.classpath=\ + ${javac.classpath}:\ + ${src.dir}:\ + ${build.classes.dir}: +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +debug.classpath=\ + ${run.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ArduhomeJavaFX.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +file.reference.RXTXcomm.jar=../../../../../../../../java/netbeans-6.9.1/javafx/javafx-sdk/lib/shared/RXTXcomm.jar +includes=** +jar.compress=true +javac.classpath=\ + ${file.reference.RXTXcomm.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.source=1.5 +javac.target=1.5 +javadoc.additionalparam= +javadoc.author=true +javadoc.encoding= +javadoc.private=true +javadoc.version=false +javafx.profile=desktop +jnlp.codebase.type=local +jnlp.offline-allowed=true +jnlp.packEnabled=false +jnlp.signed=false +main.class=desktopapplication1.Main +manifest.file=manifest.mf +pack200.jar.compress=true +platform.active=default_fx_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs=-Dgnu.io.rxtx.SerialPorts=/dev/rfcomm0 +source.encoding=UTF-8 +src.dir=src diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/project.xml b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/project.xml new file mode 100644 index 0000000..3a7d05c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/project.xml @@ -0,0 +1,13 @@ + + + org.netbeans.modules.javafx.project + + + ArduhomeJavaFX + 1.6.5 + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java new file mode 100644 index 0000000..93e57e3 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java @@ -0,0 +1,138 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.globalcode.eletronlivre.arduino.serial; + +import gnu.io.CommPortIdentifier; +import gnu.io.SerialPort; +import gnu.io.UnsupportedCommOperationException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Enumeration; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author vsenger + */ +public class Arduino { + + static boolean init = false; + static Enumeration portList; + static CommPortIdentifier portId; + static String messageString = "10"; + static SerialPort serialPort; + static OutputStream outputStream; + static InputStream inputStream; + static boolean outputBufferEmptyFlag = false; + static String defaultPort = "/dev/rfcomm1"; + //static String defaultPort = "/dev/ttyUSB0"; + public static void begin(int bps) { + if (!init) { + init(); + } + + } + public static void delay(long milis) { + try { + Thread.sleep(milis); + } catch (InterruptedException ex) { + } + + } + + public static void init() { + init = true; + portList = CommPortIdentifier.getPortIdentifiers(); + + System.out.println("Iniciando"); + //System.out.println(portList.); + while (portList.hasMoreElements()) { + portId = (CommPortIdentifier) portList.nextElement(); + System.out.println(portId.getName()); + if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { + if (portId.getName().equals(defaultPort)) { + System.out.println("Found port " + defaultPort); + try { + serialPort = + (SerialPort) portId.open("SimpleWriteCOM17", 9600); + } catch (Exception e) { + System.out.println("Port in use."); + continue; + } + + + try { + outputStream = serialPort.getOutputStream(); + inputStream = serialPort.getInputStream(); + serialPort.setSerialPortParams(9600, + SerialPort.DATABITS_8, + SerialPort.STOPBITS_1, + SerialPort.PARITY_NONE); + + serialPort.notifyOnOutputEmpty(true); + } catch (UnsupportedCommOperationException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + System.out.println("Error setting event notification"); + System.out.println(e.toString()); + } + } + } + } + } + + public static void enviar(float f) throws Exception { + + enviar(new byte[]{(byte) f}); + } + //100, 1, 1024, 1, 9 + public static int map(int val, int minOriginal, int maxOriginal, int minTarget, int maxTarget) { + return val / ((maxOriginal - minOriginal) / (maxTarget - minTarget)); + + + } + public static void main(String[] args) { + System.out.println(map(100,1,1024,1,9)); + System.out.println(map(1000,1,1024,1,9)); + System.out.println(map(500,1,1024,1,9)); + System.out.println(map(50,1,1024,1,9)); + } + public static void enviar(byte bytes[]) throws Exception { + if (!init) { + init(); + } + + System.out.println("Escrevendo..."); + outputStream.write(66); //my I2C ID + System.out.println(bytes[0]); + + outputStream.write(bytes[0] ==0 ? 10 : bytes[0] ); + outputStream.flush(); + System.out.println("Esperando..."); + + + } + class BluetoothListener extends Thread { + public void run() { + while(true) { + try { + if (inputStream.available() > 0) { + while(inputStream.available()>0) { + System.out.print(inputStream.read()); + } + } + } catch (IOException ex) { + Logger.getLogger(Arduino.class.getName()).log(Level.SEVERE, null, ex); + } + Arduino.delay(50); + + } + } + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/.LCKMain.fx~ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/.LCKMain.fx~ new file mode 100644 index 0000000..d0d4b5a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/.LCKMain.fx~ @@ -0,0 +1 @@ +/home/vsenger/DesktopApplication1/src/desktopapplication1/Main.fx \ No newline at end of file diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/Main.fx b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/Main.fx new file mode 100644 index 0000000..1a74841 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/Main.fx @@ -0,0 +1,150 @@ +/* + * Main.fx + * + * Created on Aug 11, 2010, 6:44:24 PM + */ +package desktopapplication1; + +import br.com.globalcode.eletronlivre.arduino.serial.Arduino; + +/** + * @author vsenger + */ +public class Main { + + // //GEN-BEGIN:main + def __layoutInfo_scrollBar: javafx.scene.layout.LayoutInfo = javafx.scene.layout.LayoutInfo { + width: 361.0 + height: 17.0 + } + public-read def scrollBar: javafx.scene.control.ScrollBar = javafx.scene.control.ScrollBar { + opacity: 1.0 + layoutX: 14.0 + layoutY: 46.0 + layoutInfo: __layoutInfo_scrollBar + onMouseClicked: null + onMousePressed: null + onMouseReleased: teste + min: 20.0 + max: 120.0 + } + + public-read def Luz_1: javafx.scene.control.Label = javafx.scene.control.Label { + layoutX: 20.0 + layoutY: 18.0 + text: "Luz 1" + } + + public-read def button: javafx.scene.control.Button = javafx.scene.control.Button { + visible: false + layoutX: 404.0 + layoutY: 279.0 + text: "Button" + } + + def __layoutInfo_arduinoConsole: javafx.scene.layout.LayoutInfo = javafx.scene.layout.LayoutInfo { + } + public-read def arduinoConsole: javafx.scene.control.TextBox = javafx.scene.control.TextBox { + visible: false + layoutX: 17.0 + layoutY: 279.0 + layoutInfo: __layoutInfo_arduinoConsole + } + + public-read def color: javafx.scene.paint.Color = javafx.scene.paint.Color { + red: 0.9529412 + green: 0.8980392 + blue: 0.11372549 + } + + public-read def circle: javafx.scene.shape.Circle = javafx.scene.shape.Circle { + opacity: 1.0 + layoutX: 406.0 + layoutY: 33.0 + fill: color + radius: 25.0 + } + + public-read def scene: javafx.scene.Scene = javafx.scene.Scene { + width: 480.0 + height: 320.0 + content: getDesignRootNodes () + } + + public-read def currentState: org.netbeans.javafx.design.DesignState = org.netbeans.javafx.design.DesignState { + names: [ "teste", ] + actual: 0 + timelines: [ + javafx.animation.Timeline { + keyFrames: [ + javafx.animation.KeyFrame { + time: 0ms + action: function() { + scrollBar.layoutX = 95.0; + scrollBar.layoutY = 46.0; + Luz_1.layoutX = 95.0; + Luz_1.layoutY = 24.0; + circle.layoutX = 33.0; + circle.layoutY = 46.0; + button.visible = true; + button.layoutX = 327.0; + button.layoutY = 279.0; + button.text = "Begin Communication"; + button.action = buttonActionAtteste; + arduinoConsole.visible = true; + __layoutInfo_arduinoConsole.width = 274.0; + } + } + ] + } + ] + } + + public-read def connected: org.netbeans.javafx.design.DesignState = org.netbeans.javafx.design.DesignState { + names: [ "State 1", ] + actual: 0 + timelines: [ + javafx.animation.Timeline { + keyFrames: [ + javafx.animation.KeyFrame { + time: 0ms + } + ] + } + ] + } + + public function getDesignRootNodes (): javafx.scene.Node[] { + [ scrollBar, Luz_1, circle, button, arduinoConsole, ] + } + + public function getDesignScene (): javafx.scene.Scene { + scene + } + // //GEN-END:main + + function buttonActionAtteste(): Void { + Arduino.begin(9600); + + //TODO + } + + function teste(event: javafx.scene.input.MouseEvent): Void { + java.lang.System.out.println(scrollBar.value); + circle.opacity = -1 - scrollBar.value / 100; + if(Arduino.map(scrollBar.value, 20, 121, 1, 9)==0) { + Arduino.enviar(9); + } + else Arduino.enviar(Arduino.map(scrollBar.value, 20, 121, 1, 9)); + } + +} + +function run (): Void { + var design = Main {}; + + javafx.stage.Stage { + title: "Main" + scene: design.getDesignScene () + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/Main.fxc b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/Main.fxc new file mode 100644 index 0000000..101ad23 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/Main.fxc @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/DesignState.fx b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/DesignState.fx new file mode 100644 index 0000000..2a588ad --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/DesignState.fx @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2009, Oracle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution. + * * Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.netbeans.javafx.design; + +import javafx.animation.Timeline; +import org.netbeans.javafx.design.DesignStateChangeType; + +/** + * Represents a container of a single state variable in a design. + * State variable can hold at maximum one particular state at a time. + * The actual state is held in actual field. + * + * It is required to set timelines field. + * Then you can switch between states using actual field directly or any helper method e.g. previous or next. + * Optionally you can set names field to navigate to states using their names. + * + * The onActualStateChanged method provides a callback for actual field changes. + * The onTransitionFinished method provides a callback for notifying of a finished transition animations. + * The doNotAnimateOnce field allows to fast-forward a transition animation of next state change. + */ +public class DesignState { + + /** + * Contains a sequence of names. + * Each name is assigned to a particular state represented by an index starting from zero. + * For getting an index from a specified name, you can use findIndex method. + */ + public-init var names: String[]; + + /** + * Contains a sequence of timelines. + * Each timeline is assigned to a particular state represented by an index starting from zero. + * A timeline sets various properties of components in a design to specific value. + * At the end of the timeline, the design should look as designed for a specific state. + */ + public-init var timelines: Timeline[] on replace { + initiateTransitionStates (); + } + + + var transitionStates: TransitionState[]; + + function initiateTransitionStates (): Void { + if (not FX.isInitialized(transitionStates)) { + transitionStates = for (i in [0..PAUSE_AND_PLAY_FROM_START. + * If null value is set, IllegalArgumentException is thrown. + */ + public-init var stateChangeType = DesignStateChangeType.PAUSE_AND_PLAY_FROM_START on replace oldValue { + if (stateChangeType == null) { + stateChangeType = oldValue; + throw new java.lang.IllegalArgumentException (); + } + } + + /** + * This is a notification method called when the actual state is changed. + * @param oldState the previous state + * @param newState the new actual state + */ + public var onActualStateChanged: function (oldState: Integer, newState: Integer): Void; + + /** + * This method is called when a timeline for a specific state is interrupted or finished. + * This method can be used e.g. for switching to next states for a slide-show effect. + * If the finishedState parameter value equals to DesignState.actual value + * then the transition is finished normally by finishing playing the whole animation. + * If the finishedState parameter value does NOT equal to DesignState.actual value + * then the transition is interrupted by invoked switch to another state i.e. + * by setting DesignState.actual field value or using the control methods. + * @param finishedState the state which transition is finished; If equals to DesignState.actual then transition has finished normally. Otherwise it has been interrupted. + */ + public var onTransitionFinished: function (finishedState: Integer): Void; + + /** + * Defines whether the next animation is played normally or fast-forward to the end immediately. + * If initially set to true, then a design immediately skips an animation for the start state. + * Similarly if you want to fast-switch to a new state, then set this field to true right before setting the new actual state index. + * Once an animation is skipped, the field is set to false automatically. + * The field must not be initialized with bind expression. + */ + public var doNotAnimateOnce: Boolean = true; + + /** + * Holds the actual state index. The defined indices are [0 .. < sizeof names]. + * Any other index is taken as undefined. + * Default actual state index is -1. + * When a new actual state index is set, then based on onActualStateChanged + * a new timeline is started and onActualStateChanged method is called. + */ + public var actual = -1 on replace old { + initiateTransitionStates (); + def oldTimeline = timelines[old]; + def actualTimeline = timelines[actual]; + + if (stateChangeType == DesignStateChangeType.PAUSE_AND_PLAY_FROM_START) { + oldTimeline.stop (); + actualTimeline.evaluateKeyValues (); + actualTimeline.playFromStart (); + + } else if (stateChangeType == DesignStateChangeType.FINISH_AND_PLAY_FROM_START) { + oldTimeline.time = oldTimeline.totalDuration; + actualTimeline.evaluateKeyValues (); + actualTimeline.playFromStart (); + + } else if (stateChangeType == DesignStateChangeType.CONTINUE_AND_PLAY) { + actualTimeline.evaluateKeyValues (); + actualTimeline.play (); + + } else if (stateChangeType == DesignStateChangeType.DO_NOTHING) { + } + + if (doNotAnimateOnce) { + doNotAnimateOnce = false; + FX.deferAction (function (): Void { + actualTimeline.time = actualTimeline.totalDuration; + }); + } + + onActualStateChanged (old, actual); + } + + /** + * Returns a state index by a state name which can be found in names field. + * @param name the state name to search for + * @return the state index or -1 if not found. + */ + public function findIndex (name: String): Integer { + javafx.util.Sequences.indexOf(names, name); + } + + /** + * Returns whether the actual state index is 0 or less. + * @return true, if actual state index <= 0 + */ + public bound function isFirst (): Boolean { + actual <= 0 + } + + /** + * Returns whether the actual state index is equal or greater than the last defined index. + * @return true, if actual state index >= sizeof names - 1 + */ + public bound function isLast (): Boolean { + actual >= sizeof names - 1 + } + + /** + * If possible, sets the actual state index to previous state index + * i.e. decrements the actual state index by 1. + * The method cares about the lower limit and disables decrement + * when the new actual state index would be undefined index. + */ + public function previous () { + if (not isFirst ()) { + actual = actual - 1; + } + } + + /** + * If possible, sets the actual state index to next state index + * i.e. increments the actual state index by 1. + * The method cares about the upper limit and disables increment + * when the new actual state index would be undefined index. + */ + public function next () { + if (not isLast ()) { + actual = actual + 1; + } + } + + /** + * If possible, sets the actual state index to previous state index in a loop + * i.e. decrements the actual state index by 1 in a loop of defined indices. + * If the new actual state index would be undefined index, the last defined index is set instead. + */ + public function previousWrapped () { + actual = if (isFirst ()) then sizeof names - 1 else actual - 1 + } + + /** + * If possible, sets the actual state index to next state index in a loop + * i.e. increments the actual state index by 1 in a loop of defined indices. + * If the new actual state index would be undefined index, the first defined index is set instead. + */ + public function nextWrapped () { + actual = if (isLast ()) then 0 else actual + 1 + } + +} + +class TransitionState { + + public-init var designState: DesignState; + + public-init var timeline: Timeline; + + public-init var index: Integer; + + var running = bind timeline.running on replace oldRunning { + if (oldRunning and not running) { + designState.onTransitionFinished (index); + } + } + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/DesignStateChangeType.java b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/DesignStateChangeType.java new file mode 100644 index 0000000..fecdb7e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/DesignStateChangeType.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2009, Oracle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution. + * * Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.netbeans.javafx.design; + +/** + * Represents a type of behaviour for timelines of previous and new state when an actual state is changed in state a DesignState. + */ +public enum DesignStateChangeType { + + /** + * Use this constant for setting DesignState.stateChangeType field. + * This type stops previous timeline and plays the new timeline from its start. + */ + PAUSE_AND_PLAY_FROM_START, + + /** + * Use this constant for setting DesignState.stateChangeType field. + * This type finishes previous timeline by setting the time to the totalDuration and plays the new timeline from its start. + */ + FINISH_AND_PLAY_FROM_START, + + /** + * Use this constant for setting DesignState.stateChangeType field. + * This type leaves the previous timeline running and starts playing the new one. + * This behaviour may lead to some unconsistent state e.g. when a new timeline finishes before the old one. + */ + CONTINUE_AND_PLAY, + + /** + * Use this constant for setting DesignState.stateChangeType field. + * This type does not do anything with the timelines. + */ + DO_NOTHING + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/md5sums.md5 b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/md5sums.md5 new file mode 100644 index 0000000..9bd8b6e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/md5sums.md5 @@ -0,0 +1,2 @@ +0175d1cc2edc8cfc8a24505f1c3dc94d DesignState.fx +2d7e067ad3042476a4539c95835ca643 DesignStateChangeType.java diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_Central/I2C_Central.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_Central/I2C_Central.pde new file mode 100644 index 0000000..3d8c712 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_Central/I2C_Central.pde @@ -0,0 +1,111 @@ +#include +#include + +char comando[16]; +int luz= 0; + +LiquidCrystal lcd(4, 9, 14, 15, 16, 17); + +void setup() +{ + Wire.begin(); + //Wire.onReceive(receiveEvent); + Serial.begin(115200); + initLCD(); +} + +void receiveEvent(int howMany) { + char string[16]; + int counter=0; + while(Wire.available()>0) { + string[counter++]=Wire.receive(); + } + + + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Central Updated"); + lcd.setCursor(0, 1); + lcd.print(string); + +} +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Mater I2C On"); + lcd.setCursor(0, 1); + lcd.print("Waiting command."); +} + +void loop () +{ + if(Serial.available()>0) { + limpaComando(); + + int counter =0; + while(Serial.available()>0) { + comando[counter++]=Serial.read(); + delay(20); + } + lcd.clear(); + lcd.setCursor(0, 0); + + lcd.print(comando); + executarComando(); + //lcd.print("Aguardando...."); + for(int x=0;x<4;x++) { + digitalWrite(4, HIGH); + delay(30); + digitalWrite(4, LOW); + delay(30); + } + } + delay(5); +} + + +void receiveEvent() { + if(Wire.available()>0) // slave may send less than requested + { + byte b = Wire.receive(); + while(Wire.available()) Wire.receive(); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("something new"); + lcd.setCursor(0, 1); + lcd.print(b, DEC); + + + } +} + +void executarComando() { + lcd.setCursor(0, 0); + lcd.print("Begin with "); + lcd.setCursor(12, 0); + lcd.print(comando[0]); + Wire.beginTransmission(comando[0]); + Wire.send(comando); + Wire.endTransmission(); + lcd.setCursor(2, 1); + lcd.print("commuicated..."); + +} +void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } +} + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_Dimmer_OK/I2C_Dimmer_OK.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_Dimmer_OK/I2C_Dimmer_OK.pde new file mode 100644 index 0000000..3d01296 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_Dimmer_OK/I2C_Dimmer_OK.pde @@ -0,0 +1,147 @@ +/* + AC Light Control + + Ryan McLaughlin + + Thanks to http://www.andrewkilpatrick.org/blog/?page_id=445 + and http://www.hoelscher-hi.de/hendrik/english/dimmer.htm + + */ +#include + +#define PING_PIN 4 + +int led13 = HIGH; +long counter = 0; +int stepStack = 0; + +int AC_pin = 7; // Output to Opto Triac +int olddim=0; +long duration, inches, cm, oldCm; +long MAX_DISTANCE = 50; + +//ISR Vars +volatile boolean wasInt = false; +volatile int dim = 120; // Dimming level (0-128) 0 = on, 128 = 0ff + +void setup() // run once, when the sketch starts +{ + pinMode(AC_pin, OUTPUT); // Set the light control pin as output + attachInterrupt(0, light, RISING); // Attach an Interupt to pin2 (interupt 0) for Zero Cross Detection + Wire.begin(66); + Wire.onReceive(receiveEvent); + readPing(true); + MAX_DISTANCE=cm; + Serial.begin(9600); + +} + +void receiveEvent(int howMany) +{ + byte comando[16]; + int counter=0; + while(1 < Wire.available()) + { + byte c = Wire.receive(); + comando[counter++]=c; + } + int x = Wire.receive(); + int val = comando[1]; + dim = map(val, 0,9,1,125); +} + +void light() // function to be fired at the zero crossing to dim the light +{ + Serial.println("ok"); + wasInt=true; + if(dim<125) { + long dimtime = (60*dim); // eval the proper pause to fire the triac + delayMicroseconds(dimtime); // delay the dim time + digitalWrite(AC_pin, HIGH); // fire the Triac + delayMicroseconds(1); // pause briefly to ensure the triac turned on + digitalWrite(AC_pin, LOW); // turn off the Triac gate (triac will not turn off until next zero cross) + } + else { + digitalWrite(AC_pin, LOW); // turn off the Triac gate (triac will not turn off until next zero cross) + } +} + +void pisca(int re) { + int dimold = dim; + for(int x=0;x 30 ? 30 : cm; + dim = map(cmn,1,30,10,125); + Wire.beginTransmission(60); + char texto[10]; + itoa(map(dim,10,125,1,9),texto, 1); + //Wire.send(texto); + //Wire.endTransmission(); + delay(20); + readPing(true); + + } + } + } + delay(150);*/ +} + +void readPing(boolean disableInt) +{ + wasInt=false; + + if(disableInt) noInterrupts(); + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + if(wasInt) return; + delayMicroseconds(2); + if(wasInt) return; + digitalWrite(PING_PIN, HIGH); + if(wasInt) return; + delayMicroseconds(5); + if(wasInt) return; + digitalWrite(PING_PIN, LOW); + pinMode(PING_PIN, INPUT); + if(wasInt) return; + duration = pulseIn(PING_PIN, HIGH); + if(wasInt) return; + interrupts(); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_RGB/I2C_RGB.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_RGB/I2C_RGB.pde new file mode 100644 index 0000000..10188c1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_RGB/I2C_RGB.pde @@ -0,0 +1,51 @@ +#include + +#define RED 17 +#define GREEN 7 +#define BLUE 9 + + +void setup() +{ + pinMode(RED, OUTPUT); + pinMode(GREEN, OUTPUT); + pinMode(BLUE, OUTPUT); + pinMode(2, OUTPUT); + pinMode(3, OUTPUT); + + //Serial.begin(9600); + Wire.begin(67); + Wire.onReceive(receiveEvent); + +} +void receiveEvent(int howMany) +{ + char comando[16]; + int counter=0; + while(Wire.available()>0) { + digitalWrite(2,HIGH); + digitalWrite(3,HIGH); + delay(100); + digitalWrite(2,LOW); + digitalWrite(3,LOW); + Wire.receive();// skyp first byte, my ID + } + /*Serial.println("Evento, bytes recebidos"); + Serial.println(howMany); + + Serial.println(Wire.receive(),DEC); + Serial.println(Wire.receive(),DEC); + Serial.println(Wire.receive(),DEC); + Serial.println("Evento finalizado...");*/ + + +} + +void loop() +{ + +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_Slave_Tomada/I2C_Slave_Tomada.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_Slave_Tomada/I2C_Slave_Tomada.pde new file mode 100644 index 0000000..5ee3712 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_Slave_Tomada/I2C_Slave_Tomada.pde @@ -0,0 +1,64 @@ + #include + + +void setup() +{ + pinMode(3, OUTPUT); + pinMode(4, OUTPUT); + Serial.begin(9600); + Wire.begin(65); // join i2c bus with address #4 + Wire.onReceive(receiveEvent); // register event + +} +void receiveEvent(int howMany) +{ + char comando[16]; + int counter=0; + while(1 < Wire.available()) // loop through all but the last + { + char c = Wire.receive(); // receive byte as a character + comando[counter++]=c; + Serial.print(c); // print the character + } + int x = Wire.receive(); // receive byte as an integer + Serial.println(x); // print the integer + + Serial.println("Evento"); + Serial.println(howMany); + if(comando[1]=='+') { + Serial.println("Ligando relê"); + digitalWrite(comando[2]=='A' ? 3 : 4, HIGH); + } + else if(comando[1]=='-') { + Serial.println("Desligando relê"); + digitalWrite(comando[2]=='A' ? 3 : 4, LOW); + } + + /*char comando[16]; + int c=0; + while(1 < Wire.available()) // loop through all but the last + { + if(c=0) Wire.receive(); //skip first byte (my ID) + comando[c++] = Wire.receive(); // receive byte as a character + + } + Serial.println(comando); + if(comando[0]=='+') { + Serial.println("Ligando relê"); + digitalWrite(comando[1]=='A' ? 3 : 4, HIGH); + } + else if(comando[0]=='-') { + Serial.println("Desligando relê"); + digitalWrite(comando[1]=='A' ? 3 : 4, LOW); + } */ +} + +void loop() +{ + Serial.println("esperando..."); + delay(1000); + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_Tomada2/I2C_Tomada2.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_Tomada2/I2C_Tomada2.pde new file mode 100644 index 0000000..a56f224 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/JavaOne2010/I2C_Tomada2/I2C_Tomada2.pde @@ -0,0 +1,56 @@ +#include +#define RED 9 +#define GREEN 7 +#define BLUE 7 +int red=2,green=2,blue=2; + +void setup() +{ + pinMode(RED, OUTPUT); + pinMode(GREEN, OUTPUT); + pinMode(BLUE, OUTPUT); + Serial.begin(9600); + Wire.begin(67); // join i2c bus with address #4 + Wire.onReceive(receiveEvent); // register event + +} +void receiveEvent(int howMany) +{ + char comando[16]; + int counter=0; + while(1 < Wire.available()) // loop through all but the last + { + char c = Wire.receive(); // receive byte as a character + comando[counter++]=c; + } + char c = Wire.receive(); // receive byte as a character + + red = comando[1]; + green = comando[2]; + blue = comando[3]; + Serial.println("comando"); + Serial.println(comando); + +} + +void loop() +{ + analogWrite(RED, red==1 ? 0 : red); + analogWrite(BLUE, blue==1 ? 0 : blue); + analogWrite(GREEN, green==1 ? 0 : green); + Serial.println("Red"); + Serial.println(red); + Serial.println("Green"); + Serial.println(green); + Serial.println("Blue"); + Serial.println(blue); + + Serial.println("esperando..."); + delay(1000); + +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/MonitorDuino/monitorDuino_v1_0/monitorDuino_v1_0.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/MonitorDuino/monitorDuino_v1_0/monitorDuino_v1_0.pde new file mode 100644 index 0000000..c2e501d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/MonitorDuino/monitorDuino_v1_0/monitorDuino_v1_0.pde @@ -0,0 +1,212 @@ +/* :::MonitorDuino v_1.0::: +/* An Arduino based performance computer monitor +/* +/* AUTHOR: Stefano Manni | http://www.stefanomanni.it/arduino | ::FREE SOFTWARE:: +/* +/* HOW TO: upload sketch and run systemMonitor.sh script on your computer with LINUX OS + + * CIRCUIT: + * LCD --------------------------- ARDUINO + * + * Vss pin (1) to GND + * Vdd pin (2) to 5V + * VO/Contrast pin (3) to 5V through a potentiometer + * RS pin (4) to digital pin 12 + * Enable pin (6) to digital pin 11 + * D4 pin (11) to digital pin 5 + * D5 pin (12) to digital pin 4 + * D6 pin (13) to digital pin 3 + * D7 pin (14) to digital pin 2 + * R/W pin (5) to GND + * Led+ pin (15) to 5V + * Led- pin (16( to GND +*/ + +#include "string.h" +#include + +char UPTIME[6]; //system uptime [h:min] +char CPU[7]; //cpu utilization [%] +char RAM[6]; //memory used [MB] +char NET[11]; //download rate [kB/s] +char FS[4]; //upload rate [kB/s] +char TEMP[5]; //cpu temperature [°Celsius] + +int numR = 4; //number of rows on lcd +int numC = 20; //number of columns on lcd + +char string[40]; //string received from bash script via serial + +LiquidCrystal lcd(12,11,6,5,4,3); //constructor LiquidCrystal xxx (RS, Enable, D4, D5, D6, D7) + +boolean flag=false; + +//Pattern (P_) of constant strings and custom chars to visualize on lcd +byte P_arrowDown[9]={B00000,B00000,B11111,B01110,B00100,B00000,B00000,B00000,}; //custom char arrow down +byte P_arrowUp[9]={B00000,B00000,B00000,B00100,B01110,B11111,B00000,B00000,}; //custom char arrow up +char P_header[20] = "MonitorDuino v_1.0"; +char P_uptime[9]= "Uptime:"; +char P_cpuUsage[12]="Cpu usage:"; +char P_cpuTemp[11]= "Cpu temp:"; +char P_mem[12]="Mem usage:"; +char P_rx[10]="Rx rate:"; +char P_disk[13]="Disk usage:"; + + +void setup(){ +lcd.createChar(1,P_arrowDown); +lcd.createChar(2,P_arrowUp); +lcd.begin(numR,numC); +Serial.begin(115200); +attachInterrupt(0, changePage, RISING); //interrupt on digital pin 2 (pushbutton through a pull-down resistor) +initPage1(); +} + + +void initPage1(){ +lcd.clear(); +lcd.setCursor(0,0); +lcd.print(P_header); //defined in MonitorDuinoStrings.h +lcd.setCursor(0,1); +lcd.print(P_uptime); +lcd.setCursor(0,2); +lcd.print(P_cpuUsage); +lcd.setCursor(0,3); +lcd.print(P_cpuTemp); +lcd.setCursor(19,3); +lcd.write(1); //arrow DOWN +} + + +void initPage2(){ +lcd.clear(); +lcd.setCursor(0,0); +lcd.print(P_header); +lcd.setCursor(0,1); +lcd.print(P_mem); +lcd.setCursor(0,2); +lcd.print(P_rx); +lcd.setCursor(0,3); +lcd.print(P_disk); +lcd.setCursor(19,0); +lcd.write(2); //arrow UP +} + + +void changePage (){ //invoked when an interrupt occurs +flag=!flag; +if (!flag) initPage1(); +else initPage2(); +} + + +void clearRow(int col, int row){ +int k; + lcd.setCursor(col,row); + for(k=col;k 0){ + delay(10); + string[i]=Serial.read(); + i++; +} + +if (i!=0) { //if i've receveid something + + for(i;i" + echo "--disk= " + echo "--tty= " + echo "" + echo "EXAMPLES:" + echo "./systemMonitor.sh --net=eth0 --disk=/dev/sda1 --tty=/dev/ttyUSB0" + exit + ;; + + esac +done + +if [ "$netDev" == "" ] && [ "$diskPath" == "" ] && [ "$tty" == "" ] +then + echo "Usage: -h for help" + exit +fi + +if [ "$netDev" == "" ] +then + echo "Usage: --net= " + exit +fi + +if [ "$diskPath" == "" ] +then + echo "Usage: --disk= " + exit +fi + +if [ "$tty" == "" ] +then + echo "Usage: --tty= " + exit +fi + + +#Send data +clear +echo -n "Sending data to Arduino" + +while true; +do + UPTIME=$(uptime | awk '{ print $3 }' | cut -d, -f1) + CPU=$(mpstat -P ALL 1 1 | grep Average | grep all | awk '{print $3"%"}') + RAM=$(free -mo | grep Mem: | awk '{ print $3"MB" }') + NETdown=$(bwm-ng -o plain -c 1 | grep $netDev | awk '{print $2"kB/s"}') + FS=$(df -hT | grep $diskPath | awk '{print $6}') + TEMP=$(cat /proc/acpi/thermal_zone/TZS0/temperature | awk '{print $2"C"}') + + echo $UPTIME@$CPU@$RAM@$NETdown@$FS@$TEMP > $tty + echo -n "." + +done + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/PainelLedRGB/PainelLedRGB.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/PainelLedRGB/PainelLedRGB.pde new file mode 100644 index 0000000..314c532 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/PainelLedRGB/PainelLedRGB.pde @@ -0,0 +1,70 @@ +#include +void setup() { + pinMode(9, OUTPUT); + pinMode(10, OUTPUT); + pinMode(11, OUTPUT); + Serial.begin(9600); + Wire.begin(65); + Wire.onReceive(receiveEvent); + +} +int val; +byte comando[16]; + +void receiveEvent(int howMany) +{ + Serial.println(howMany); + + int counter=0; + while(1 < Wire.available()) + { + byte c = Wire.receive(); + comando[counter++]=c; + Serial.print(c); + } + char numero[3]; + numero[0]=comando[1]; + numero[1]=comando[2]; + numero[2]=comando[3]; + val = atoi(numero); + +} + + +void loop() { + /* Serial.println( analogRead(0)); + Serial.println( analogRead(1)); + Serial.println( analogRead(2)); + Serial.println( "============");*/ + //analogWrite(9, map(analogRead(0),0,1024,0,255)); + //analogWrite(10, map(analogRead(1),0,1024,0,255)); + //analogWrite(11, map(analogRead(2),0,1024,0,255)); + if(val>0 && val<90) { + analogWrite(9, map(val,0,90,0,255)); + analogWrite(10, 0); + analogWrite(11, 0); + + } + else if(val>90 && val<180) { + analogWrite(10, map(val,90,180,0,255)); + analogWrite(9, 0); + analogWrite(11, 0); + + } + else if(val>180 && val<270) { + analogWrite(11, map(val,180,270,0,255)); + analogWrite(10, 0); + analogWrite(9, 0); + } + else if(val>270 && val<360) { + analogWrite(9, map(val,270,360,0,255)); + analogWrite(10, map(val,270,360,0,255)); + analogWrite(11, 0); + } + +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/PainelMotores/PainelMotores.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/PainelMotores/PainelMotores.pde new file mode 100644 index 0000000..319c8c8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/PainelMotores/PainelMotores.pde @@ -0,0 +1,57 @@ +// Controlling a servo position using a potentiometer (variable resistor) +// by Michal Rinott + +#include + +Servo myservo; // create servo object to control a servo +Servo myservo1; // create servo object to control a servo + +int potpin = 1; // analog pin used to connect the potentiometer +int val; // variable to read the value from the analog pin + +void setup() +{ + Serial.begin(9600); + pinMode(9, OUTPUT); + pinMode(6, OUTPUT); + + myservo.attach(10); // attaches the servo on pin 9 to the servo object + myservo1.attach(11); // attaches the servo on pin 9 to the servo object +} + +void loop() +{ + myservo.write(map(analogRead(2), 0, 1023, 0, 179)); + myservo1.write(map(analogRead(0), 0, 1023, 0, 179)); + analogWrite(9,map(analogRead(1), 0, 1023, 0, 255)); + analogWrite(6,map(analogRead(1), 0, 1023, 0, 255)); + delay(50); + + + Serial.println( analogRead(0)); + + Serial.println( analogRead(1)); + Serial.println( analogRead(2)); + Serial.println( "============"); + /*if(Serial.available()>0) { + + while(Serial.available()>0) { + + int dado = int(Serial.read()); + Serial.println(dado,DEC); + myservo.write(dado); + int dado1 = int(Serial.read()); + Serial.println(dado1,DEC); + myservo1.write(dado1); + + } + }*/ + + /*val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) + //Serial.println(val); + val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) + //myservo.write(analogRead(1)/4); // sets the servo position according to the scaled value + //myservo1.write(analogRead(2)/4); // sets the servo position according to the scaled value */ + delay(10); // waits for the servo to get there +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/PortasGlobalcode/PortasGlobalcode.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/PortasGlobalcode/PortasGlobalcode.pde new file mode 100644 index 0000000..beac208 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/PortasGlobalcode/PortasGlobalcode.pde @@ -0,0 +1,31 @@ +void setup() { + Serial.begin(9600); + pinMode(8, OUTPUT); + pinMode(9, OUTPUT); +} + + +void loop() { + if(Serial.available() >0) { + int incoming=Serial.read(); + Serial.println("Recebendo dados"); + Serial.println(incoming, DEC); + abrirPorta(incoming); + + } +} + +void abrirPorta(int conjunto) { + if(conjunto=65) { + Serial.println("Abrindo porta do 22"); + digitalWrite(8, HIGH); + delay(200); + digitalWrite(8, LOW); + } + if(conjunto=66) { + Serial.println("Abrindo porta do 34"); + digitalWrite(9, HIGH); + delay(200); + digitalWrite(9, LOW); + } +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/Potenciometro_com_LED_e_Serial.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/Potenciometro_com_LED_e_Serial.pde new file mode 100644 index 0000000..c23e7fb --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/Potenciometro_com_LED_e_Serial.pde @@ -0,0 +1,24 @@ +#include + +void setup() { + pinMode(3, OUTPUT); + pinMode(4, OUTPUT); + pinMode(5, OUTPUT); + pinMode(9, OUTPUT); + pinMode(2, INPUT); + Serial.begin(9600); +} + +void loop(){ + analogWrite(3, analogRead(2)); + analogWrite(4, analogRead(2)/4); + analogWrite(9, analogRead(2)/4); + analogWrite(5, analogRead(2)); + pos = analogRead(2) / 7; + + Serial.println(analogRead(2)); + delay(100); + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..dc28a59 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.cpp new file mode 100644 index 0000000..763821f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.cpp @@ -0,0 +1,107 @@ +#include + +#define P0 0 // Porta Digital 0 - Led 1 - +#define P1 1 // Porta Digital 1 - Led 2 +#define P2 2 // Porta Digital 2 - Led 3 - PWM +#define P3 3 // Porta Digital 3 - Led 4 +#define P4 4 // Porta Digital 4 - Led 5 - PWM +#define P5 5 // Porta Digital 5 - Led 6 - PWM +#define P6 6 // Porta Digital 6 - Led 7 +#define P7 7 // Porta Digital 7 - Led 8 +#define P8 8 // Porta Digital 8 - Transistor Q3 +#define P9 9 // Porta Digital 9 - Transistor Q2 - PWM +#define P10 10 // Porta Digital 10 - Servo1 - PWM +#define P11 11 // Porta Digital 11 - Servo2 - PWM +#define P12 12 // Porta Digital 12 - Buzzer +#define P13 13 // Porta Digital 13 - Led 9 +#define AP0 14 // Porta Analogica 0 +#define AP1 15 // Porta Analogica 1 +#define AP2 16 // Porta Analogica 2 +#define AP3 17 // Porta Analogica 3 +#define AP4 18 // Porta Analogica 4 +#define AP5 19 // Porta Analogica 5 + +#define A0 0 // Porta Analogica 0 - LDR +#define A1 1 // Porta Analogica 1 - POT 1 +#define A2 2 // Porta Analogica 2 - POT 2 +#define A3 3 // Porta Analogica 3 - Transistor Q5 +#define A4 4 // Porta Analogica 4 - Transistor Q4 +#define A5 5 // Porta Analogica 3 - Chave + +#define LED_1 0 +#define LED_2 1 +#define LED_3 2 +#define LED_4 3 +#define LED_5 4 +#define LED_6 5 +#define LED_7 6 +#define LED_8 7 +#define LED_9 13 + +#define Q2 9 +#define Q3 8 +#define Q4 17 +#define Q5 18 + +#define LDR 0 +#define POT1 1 +#define POT2 2 +#define CHAVE 5 +#include "WProgram.h" +void setup(); +void loop(); +int pos = 0; // variable to store the servo position + +int transistorPin1 = P8; +int transistorPin2 = P9; +int transistorPin3 = AP3; +int transistorPin4 = AP4; + +int inPin = AP5; + +int val = 0; + +//Servo myservo9; // create servo object to control a servo + +void setup() { + // myservo9.attach(10); // attaches the servo on pin 9 to the servo object + + pinMode(2, INPUT); + pinMode(5, OUTPUT); + pinMode(9, OUTPUT); + pinMode(10, OUTPUT); + pinMode(11, OUTPUT); + pinMode(3, OUTPUT); + pinMode(4, OUTPUT); + Serial.begin(9600); +} + +void loop(){ + analogWrite(3, analogRead(2)); + analogWrite(4, analogRead(2)/4); + analogWrite(9, analogRead(2)/4); + //analogWrite(9, 128); + //digitalWrite (9, HIGH); + pos = analogRead(2) / 7; + //myservo9.write(pos); // tell servo to go to position in variable 'pos' + + analogWrite(5, analogRead(2)); + Serial.println(analogRead(2)); + delay(100); + +} + + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.cpp.o new file mode 100644 index 0000000..7256e71 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.elf new file mode 100644 index 0000000..d30bfe2 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.hex new file mode 100644 index 0000000..e618d93 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.hex @@ -0,0 +1,160 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C94CA020C948A000C94F4000C948A005C +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000AD0111241FBECFEFD4E0DEBFCDBFD5 +:1000D00011E0A0E0B1E0ECEDF9E002C005900D9276 +:1000E000A830B107D9F711E0A8E0B1E001C01D9236 +:1000F000AC3AB107E1F710E0C4ECD0E004C02297BD +:10010000FE010E94E804C23CD107C9F70E94ED003D +:100110000C94EC040C94000082E00E949E03BC014D +:1001200083E00E94BC0382E00E949E0364E070E0D2 +:100130000E94820484E00E94BC0382E00E949E032D +:1001400064E070E00E94820489E00E94BC0382E0C7 +:100150000E949E0367E070E00E9482047093090190 +:100160006093080182E00E949E03BC0185E00E942A +:10017000BC0382E00E949E03BC018EE891E00E94D5 +:10018000BA0264E670E080E090E00E943A030895CD +:1001900082E060E00E94150485E061E00E941504A1 +:1001A00089E061E00E9415048AE061E00E94150484 +:1001B0008BE061E00E94150483E061E00E94150479 +:1001C00084E061E00E9415048EE891E040E855E289 +:1001D00060E070E00E94310108950E9464030E9473 +:1001E000C8000E948C00FDCF1F920F920FB60F9295 +:1001F00011242F933F934F935F936F937F938F932C +:100200009F93AF93BF93EF93FF934091C600E0910C +:100210008A01F0918B01CF01019660E870E00E94A5 +:1002200082049C0180918C0190918D0128173907DF +:1002300039F0E65FFE4F408330938B0120938A01B3 +:10024000FF91EF91BF91AF919F918F917F916F91AE +:100250005F914F913F912F910F900FBE0F901F9084 +:100260001895AF92BF92CF92DF92EF92FF920F93C9 +:100270001F93CF93DF936C017A018B01DC011496FD +:10028000AD90BC901597CB01BA0122E030E040E080 +:1002900050E00E94B704205C3D4B404F5F4FCA01C5 +:1002A000B901A80197010E94B704C901DA010197B9 +:1002B000A109B109292F3A2F4B2F552747FD5A95F0 +:1002C0000196A11DB11DE5012883E601EE81FF81A4 +:1002D00081508083EA85FB85208141E050E0CA019E +:1002E0000E8402C0880F991F0A94E2F7282B2083FE +:1002F000EA85FB852081CA010F8402C0880F991FFF +:100300000A94E2F7282B2083EA85FB858081088800 +:1003100002C0440F551F0A94E2F7842B8083DF91BB +:10032000CF911F910F91FF90EF90DF90CF90BF90F2 +:10033000AF900895FC01A085B18521898C9190E052 +:10034000022E02C0959587950A94E2F780FFF6CFBA +:100350000484F585E02D6083089585E091E0909315 +:100360008F0180938E018AE091E0909391018093B8 +:10037000900185EC90E0909393018093920184EC3E +:1003800090E0909395018093940180EC90E090939D +:1003900097018093960181EC90E09093990180936E +:1003A000980186EC90E090939B0180939A0184E001 +:1003B00080939C0183E080939D0187E080939E0160 +:1003C00085E080939F0108950F931F938C01DC01BA +:1003D000ED91FC910190F081E02D6DE00995D8013F +:1003E000ED91FC910190F081E02DC8016AE0099542 +:1003F0001F910F9108952F923F924F925F926F92AB +:100400007F928F929F92AF92BF92CF92DF92EF92A4 +:10041000FF920F931F93DF93CF93CDB7DEB7A097D3 +:100420000FB6F894DEBF0FBECDBF1C016A017B0181 +:10043000411551056105710549F4DC01ED91FC910F +:100440000190F081E02D60E3099554C0882499243F +:100450005401422E55246624772401E010E00C0F4D +:100460001D1F080D191DC701B601A30192010E94AD +:100470009504F80160830894811C911CA11CB11C97 +:10048000C701B601A30192010E949504C901DA01D6 +:100490006C017D01C114D104E104F104F1F681E0A5 +:1004A000E82EF12CEC0EFD1EE80CF91C3E01089420 +:1004B000611C711CD501C4010197A109B1096C012E +:1004C000C818D90814C0F601EE0DFF1D60816A300E +:1004D00010F4605D01C0695CD101ED91FC91019067 +:1004E000F081E02DC10109950894E108F1086E142E +:1004F0007F0449F7A0960FB6F894DEBF0FBECDBFBC +:10050000CF91DF911F910F91FF90EF90DF90CF90EF +:10051000BF90AF909F908F907F906F905F904F9023 +:100520003F902F900895EF92FF920F931F93CF93D8 +:10053000DF93EC017A018B0177FF0FC0E881F9812D +:100540000190F081E02D6DE2099510950095F094F1 +:10055000E094E11CF11C011D111DCE01B801A701A1 +:100560002AE00E94FB01DF91CF911F910F91FF9034 +:10057000EF9008950F931F938C01AB01662757FDF1 +:100580006095762F0E949302C8010E94E4011F919A +:100590000F9108951F920F920FB60F9211242F936F +:1005A0008F939F93AF93BF938091A0019091A101EE +:1005B000A091A201B091A3010196A11DB11D80934C +:1005C000A0019093A101A093A201B093A3018091F7 +:1005D000A4019091A501A091A601B091A70180501E +:1005E000904CAF4FBF4F8093A4019093A501A0936F +:1005F000A601B093A70127C08091A4019091A50105 +:10060000A091A601B091A70180589E43A040B040A0 +:100610008093A4019093A501A093A601B093A70194 +:100620008091A8019091A901A091AA01B091AB017C +:100630000196A11DB11D8093A8019093A901A093DB +:10064000AA01B093AB018091A4019091A501A09162 +:10065000A601B091A70181589E43A040B04060F62A +:10066000BF91AF919F918F912F910F900FBE0F90DF +:100670001F901895EF92FF920F931F937B018C01AF +:100680008FB7F8944091A8015091A9016091AA01F7 +:100690007091AB018FBF2FB7F8948091A801909112 +:1006A000A901A091AA01B091AB012FBF841B950BAA +:1006B000A60BB70BE816F9060A071B0760F71F9190 +:1006C0000F91FF90EF900895789484B5826084BD77 +:1006D00084B5816084BD85B5826085BD85B5816046 +:1006E00085BDEEE6F0E0808181608083E1E8F0E0A6 +:1006F000808182608083808181608083E0E8F0E097 +:10070000808181608083E1EBF0E080818460808380 +:10071000E0EBF0E0808181608083EAE7F0E08081B7 +:100720008460808380818260808380818160808317 +:100730008081806880831092C100089587709091B5 +:1007400000019295990F990F907C982B90937C00C3 +:1007500080917A00806480937A0080917A0086FD8F +:10076000FCCF2091780040917900942F80E030E018 +:10077000282B392BC90108951F93CF93DF93182F8E +:10078000EB0161E00E941504E12FF0E0E255FF4F1C +:100790008491833051F48091800080688093800040 +:1007A000D0938900C09388003CC0843051F480917C +:1007B0008000806280938000D0938B00C0938A0079 +:1007C00030C0813039F4209729F184B5806884BD28 +:1007D000C7BD27C0823039F42097E1F084B580622C +:1007E00084BDC8BD1EC0863041F48091B0008068D1 +:1007F0008093B000C093B30014C0873041F480915F +:10080000B00080628093B000C093B4000AC0C038CA +:10081000D1051CF4812F60E002C0812F61E00E94AD +:100820003504DF91CF911F910895282F30E0C90141 +:1008300086569F4FFC0194912A573F4FF9018491AE +:10084000882391F0E82FF0E0EE0FFF1FE859FF4FEB +:10085000A591B491662329F48C91909589238C936A +:1008600008958C91892B8C930895482F50E0CA01EC +:1008700082559F4FFC012491CA0186569F4FFC016F +:1008800094914A575F4FFA0134913323D1F12223D7 +:1008900031F1233021F4809180008F7705C024301E +:1008A00031F4809180008F7D8093800018C02130CA +:1008B00019F484B58F7704C0223021F484B58F7D7C +:1008C00084BD0DC0263021F48091B0008F7705C023 +:1008D000273029F48091B0008F7D8093B000E32F02 +:1008E000F0E0EE0FFF1FEE58FF4FA591B491662385 +:1008F00029F48C91909589238C9308958C91892B60 +:100900008C93089597FB092E07260AD077FD04D013 +:1009100049D006D000201AF4709561957F4F089554 +:10092000F6F7909581959F4F0895A1E21A2EAA1B84 +:10093000BB1BFD010DC0AA1FBB1FEE1FFF1FA2178F +:10094000B307E407F50720F0A21BB30BE40BF50B8C +:10095000661F771F881F991F1A9469F76095709515 +:10096000809590959B01AC01BD01CF01089597FB47 +:10097000092E05260ED057FD04D0D7DF0AD0001C63 +:1009800038F450954095309521953F4F4F4F5F4F2C +:100990000895F6F790958095709561957F4F8F4FEC +:1009A0009F4F0895AA1BBB1B51E107C0AA1FBB1F85 +:1009B000A617B70710F0A61BB70B881F991F5A95EB +:1009C000A9F780959095BC01CD010895EE0FFF1F0A +:0C09D0000590F491E02D0994F894FFCFFD +:0809DC0001000000009A010077 +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.pde new file mode 100644 index 0000000..7d50858 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.pde @@ -0,0 +1,91 @@ +#include + +#define P0 0 // Porta Digital 0 - Led 1 - +#define P1 1 // Porta Digital 1 - Led 2 +#define P2 2 // Porta Digital 2 - Led 3 - PWM +#define P3 3 // Porta Digital 3 - Led 4 +#define P4 4 // Porta Digital 4 - Led 5 - PWM +#define P5 5 // Porta Digital 5 - Led 6 - PWM +#define P6 6 // Porta Digital 6 - Led 7 +#define P7 7 // Porta Digital 7 - Led 8 +#define P8 8 // Porta Digital 8 - Transistor Q3 +#define P9 9 // Porta Digital 9 - Transistor Q2 - PWM +#define P10 10 // Porta Digital 10 - Servo1 - PWM +#define P11 11 // Porta Digital 11 - Servo2 - PWM +#define P12 12 // Porta Digital 12 - Buzzer +#define P13 13 // Porta Digital 13 - Led 9 +#define AP0 14 // Porta Analogica 0 +#define AP1 15 // Porta Analogica 1 +#define AP2 16 // Porta Analogica 2 +#define AP3 17 // Porta Analogica 3 +#define AP4 18 // Porta Analogica 4 +#define AP5 19 // Porta Analogica 5 + +#define A0 0 // Porta Analogica 0 - LDR +#define A1 1 // Porta Analogica 1 - POT 1 +#define A2 2 // Porta Analogica 2 - POT 2 +#define A3 3 // Porta Analogica 3 - Transistor Q5 +#define A4 4 // Porta Analogica 4 - Transistor Q4 +#define A5 5 // Porta Analogica 3 - Chave + +#define LED_1 0 +#define LED_2 1 +#define LED_3 2 +#define LED_4 3 +#define LED_5 4 +#define LED_6 5 +#define LED_7 6 +#define LED_8 7 +#define LED_9 13 + +#define Q2 9 +#define Q3 8 +#define Q4 17 +#define Q5 18 + +#define LDR 0 +#define POT1 1 +#define POT2 2 +#define CHAVE 5 +int pos = 0; // variable to store the servo position + +int transistorPin1 = P8; +int transistorPin2 = P9; +int transistorPin3 = AP3; +int transistorPin4 = AP4; + +int inPin = AP5; + +int val = 0; + +Servo myservo9; // create servo object to control a servo + +void setup() { + // myservo9.attach(10); // attaches the servo on pin 9 to the servo object + + pinMode(2, INPUT); + pinMode(5, OUTPUT); + pinMode(9, OUTPUT); + pinMode(10, OUTPUT); + pinMode(11, OUTPUT); + pinMode(3, OUTPUT); + pinMode(4, OUTPUT); + Serial.begin(9600); +} + +void loop(){ + analogWrite(3, analogRead(2)); + analogWrite(4, analogRead(2)/4); + analogWrite(9, analogRead(2)/4); + //analogWrite(9, 128); + //digitalWrite (9, HIGH); + pos = analogRead(2) / 7; + //myservo9.write(pos); // tell servo to go to position in variable 'pos' + + analogWrite(5, analogRead(2)); + Serial.println(analogRead(2)); + delay(100); + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Print.cpp.o new file mode 100644 index 0000000..6205c51 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/WInterrupts.c.o new file mode 100644 index 0000000..b74dfbb Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/WMath.cpp.o new file mode 100644 index 0000000..4e4cf44 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/core.a new file mode 100644 index 0000000..92e9407 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/pins_arduino.c.o new file mode 100644 index 0000000..c450af7 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring.c.o new file mode 100644 index 0000000..acbd542 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_analog.c.o new file mode 100644 index 0000000..b56797d Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_digital.c.o new file mode 100644 index 0000000..3928ccd Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_pulse.c.o new file mode 100644 index 0000000..525eda2 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_serial.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_serial.c.o new file mode 100644 index 0000000..b8d4c17 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_serial.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_shift.c.o new file mode 100644 index 0000000..8e0db5b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Receptor_RF/Receptor_RF.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Receptor_RF/Receptor_RF.pde new file mode 100644 index 0000000..beedd68 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Receptor_RF/Receptor_RF.pde @@ -0,0 +1,57 @@ +#include + +#define BOTAO_PORTAO 9 +#define BOTAO_INTERFONE 8 +#define LED 4 +int valor_anterior = -1; +int erro =0; +int recebidos = 0; + +uint8_t buf[VW_MAX_MESSAGE_LEN]; +uint8_t buflen = VW_MAX_MESSAGE_LEN; + + +void setup() +{ + Serial.begin(9600); // Debugging only + //Serial.println("setup"); + pinMode(LED, OUTPUT); + pinMode(BOTAO_PORTAO, OUTPUT); + pinMode(BOTAO_INTERFONE, OUTPUT); + pinMode(12, INPUT); + vw_set_rx_pin (12); + vw_setup(2000); // Bits per sec + vw_rx_start(); +} + +void loop() +{ + digitalWrite(BOTAO_PORTAO, true); + digitalWrite(BOTAO_INTERFONE, false); + //Serial.println("Esperando..."); + if (vw_get_message(buf, &buflen)) // Non-blocking + { + digitalWrite(BOTAO_PORTAO, false); + digitalWrite(BOTAO_INTERFONE, true); + digitalWrite(LED, true); + Serial.println("Chegou"); + delay(1000); + switch (buf[0]){ + case '0': + break; + case '1': + break; + case '2': + break; + case '9': + break; + } + digitalWrite(BOTAO_PORTAO, true); + digitalWrite(BOTAO_INTERFONE, false); + digitalWrite(LED, false); + recebidos++; + } +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/RoboVoador/RoboVoador.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/RoboVoador/RoboVoador.pde new file mode 100644 index 0000000..8f87c31 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/RoboVoador/RoboVoador.pde @@ -0,0 +1,31 @@ +#include + +#define MOTOR1 11 +#define SERVO1 10 +#define LDR 0 +Servo myservo; + +void setup() +{ + Serial.begin(9600); + myservo.attach(SERVO1); +} + +void loop() +{ + myservo.write(1); + funcionaMotor(1500); + delay(5000); + myservo.write(90); + funcionaMotor(1500); + delay(5000); + myservo.write(178); + funcionaMotor(1500); + delay(5000); +} + +void funcionaMotor(int tempo) { + analogWrite(MOTOR1,80); + delay(tempo); + analogWrite(MOTOR1,0); +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Teste_Receptor/Teste_Receptor.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Teste_Receptor/Teste_Receptor.pde new file mode 100644 index 0000000..fb5299d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Teste_Receptor/Teste_Receptor.pde @@ -0,0 +1,44 @@ +#include +#include + +uint8_t buf[VW_MAX_MESSAGE_LEN]; +uint8_t buflen = VW_MAX_MESSAGE_LEN; + +LiquidCrystal lcd(14, 17, 4, 3, 2, 18); + +void setup() { + setupReceptorRF(); + lcd.begin(16, 2); + initLCD(); +} +void initLCD() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("BRoBot:"); + lcd.setCursor(0, 1); + lcd.print("Aguardando...."); +} +void setupReceptorRF() { + pinMode(1,INPUT); + pinMode(12, OUTPUT); + vw_set_rx_pin (1); //Pino que recebe os dados + vw_setup(2000); // Bits per sec + vw_rx_start(); // Start the receiver PLL running +} + +void loop(){ + uint8_t buf[VW_MAX_MESSAGE_LEN]; + uint8_t buflen = VW_MAX_MESSAGE_LEN; + if (vw_get_message(buf, &buflen)) // Non-blocking + { + char conteudo[buflen]; + for(int x=0;x0) { + byte incoming=Serial.read(); + Serial.println("Recebendo dados"); + Serial.println(incoming, DEC); + if(incoming==1) { + digitalWrite(3, HIGH); + delay(2000); + digitalWrite(3, LOW); + } + else { + digitalWrite(2, HIGH); + delay(2000); + digitalWrite(2, LOW); + } + } +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Transmissor_Serial/Transmissor_Serial.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Transmissor_Serial/Transmissor_Serial.pde new file mode 100644 index 0000000..f41a530 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Transmissor_Serial/Transmissor_Serial.pde @@ -0,0 +1,48 @@ +#include + +char comando[16]; + +void setup() +{ + Serial.begin(9600); + pinMode(3, OUTPUT); + vw_set_tx_pin(3); + vw_setup(2000); +} + +void loop() +{ + int counter=0; + if(Serial.available()>0) { + limpaComando(); + Serial.print("Lendo "); + while(Serial.available()>0 && counter<=16 && comando[counter]!='\n') { + comando[counter]=Serial.read(); + Serial.print(comando[counter]); + counter++; + delay(10); + } + Serial.print(" - "); + Serial.print(counter-1); + Serial.println("bytes lidos"); + Serial.print("Enviando "); + Serial.print(sizeof(comando)); + Serial.print(" bytes="); + Serial.println(comando); + enviar(comando); + //processar(comando); + } +} + +void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } +} +void enviar(char* comando) { + vw_send((uint8_t *) comando,strlen(comando)); +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Ubatuba/Ubatuba.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Ubatuba/Ubatuba.pde new file mode 100644 index 0000000..50b8a11 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/Ubatuba/Ubatuba.pde @@ -0,0 +1,17 @@ +void setup() { + for(int x=0;x<20;x++) { + pinMode(x, OUTPUT); + } +} + +void loop() { + for(int x=0;x<20;x++) { + digitalWrite(x, HIGH); + } + delay(1000); + for(int x=0;x<20;x++) { + digitalWrite(x, LOW); + } + delay(1000); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/_3ShieldTest/Servo1.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/_3ShieldTest/Servo1.pde new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/_3ShieldTest/_3ShieldTest.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/_3ShieldTest/_3ShieldTest.pde new file mode 100644 index 0000000..3bdfced --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/_3ShieldTest/_3ShieldTest.pde @@ -0,0 +1,118 @@ +#include +#include +//#include + +#define MOTOR1_P 12 +#define MOTOR1_N 11 +#define MOTOR1_PWM 5 + +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 6 +LiquidCrystal lcd(14, 15, 16, 17, 18, 19); + +//Servo servoHorizontal; // create servo object to control a servo +//Servo servoVertical; // create servo object to control a servo + + +void setup() { + setupReceptorRF(); + + pinMode(5, OUTPUT); + pinMode(6, OUTPUT); + pinMode(7, OUTPUT); + pinMode(8, OUTPUT); + pinMode(9, OUTPUT); + pinMode(10, OUTPUT); + pinMode(14, OUTPUT); + pinMode(15, OUTPUT); + pinMode(16, OUTPUT); + pinMode(17, OUTPUT); + pinMode(18, OUTPUT); + pinMode(19, OUTPUT); + + //servoHorizontal.attach(10); // attaches the servo on pin 9 to the servo object + //servoVertical.attach(11); + Serial.begin(9600); + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("BRoBot:"); + lcd.setCursor(0, 1); + lcd.print("Aguardando...."); +} +void setupReceptorRF() { + pinMode(12, OUTPUT); + digitalWrite(12, LOW); + //Configura o Receptor + vw_set_rx_pin (12); //Pino que recebe os dados + vw_setup(2000); // Bits per sec + vw_rx_start(); // Start the receiver PLL running + +} +void loop() { + + //Serial.println(analogRead(0)/4); + /*if(Serial.available()>0) { + + while(Serial.available()>0) { + + int dado = int(Serial.read()); + Serial.println(dado,DEC); + //servoVertical.write(dado); + int dado1 = int(Serial.read()); + Serial.println(dado1,DEC); + //servoHorizontal.write(dado1); + + } + }*/ + analogWrite(MOTOR1_PWM,250); + //digitalWrite(MOTOR1_PWM, HIGH); + digitalWrite(MOTOR1_P, HIGH); + digitalWrite(MOTOR1_N, LOW); + analogWrite(MOTOR2_PWM, 250); + //digitalWrite(MOTOR2_PWM, HIGH); + digitalWrite(MOTOR2_P, HIGH); + digitalWrite(MOTOR2_N, LOW); + delay(2000); + + /*uint8_t buf[VW_MAX_MESSAGE_LEN]; + uint8_t buflen = VW_MAX_MESSAGE_LEN; + Serial.println("Esperando..."); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("BRoBot:"); + lcd.setCursor(0, 1); + + if (vw_get_message(buf, &buflen)) // Non-blocking + { + int i; + Serial.println("cHEGOU..."); + lcd.setCursor(0, 1); + lcd.print("Recebendo Dados..."); + + for (i = 0; i < buflen-1; i++) + { + lcd.clear(); + lcd.setCursor(0, 0); + if(buf[i]='a') { + lcd.print("Vou andar"); + + analogWrite(MOTOR1_PWM, 250); + digitalWrite(MOTOR1_P, !HIGH); + digitalWrite(MOTOR1_N, !LOW); + analogWrite(MOTOR2_PWM, 250); + digitalWrite(MOTOR2_P, !HIGH); + digitalWrite(MOTOR2_N, !LOW); + delay(1000); + } + Serial.print(buf[i]); + } + lcd.clear(); + + }*/ + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/android/android.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/android/android.pde new file mode 100644 index 0000000..5d2b30b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/android/android.pde @@ -0,0 +1,57 @@ +/* + Sends sensor data to Android + (needs SensorGraph and Amarino app installed and running on Android) +*/ +#include +#include +#include + +MeetAndroid meetAndroid; +int sensor = 5; +int bussolaVal =200; + +LiquidCrystal lcd(4, 9, 14, 15, 16, 17); + +void setup() +{ + // use the baud rate your bluetooth module is configured to + // not all baud rates are working well, i.e. ATMEGA168 works best with 57600 + Serial.begin(115200); + Wire.begin(0x12); + Wire.onRequest(sendBussola); + initLCD(); + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Device Ready"); + // we initialize pin 5 as an input pin + pinMode(sensor, INPUT); + meetAndroid.registerFunction(bussola, 'A'); +} + +void sendBussola() { + Wire.send(bussolaVal); + +} + +void bussola(byte flag, byte numOfValues) { + int b[numOfValues]; + meetAndroid.getIntValues(b); + bussolaVal=b[0]; + + lcd.setCursor(0, 1); + lcd.print(b[0]); +} + +void initLCD() { +} +void loop() +{ + meetAndroid.receive(); // you need to keep this in your loop() to receive events + + // read input pin and send result to Android + meetAndroid.send(analogRead(sensor)); + + // add a little delay otherwise the phone is pretty busy + delay(200); +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/android_masterobot/android_masterobot.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/android_masterobot/android_masterobot.pde new file mode 100644 index 0000000..c313049 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/android_masterobot/android_masterobot.pde @@ -0,0 +1,36 @@ +/* + Sends sensor data to Android + (needs SensorGraph and Amarino app installed and running on Android) +*/ +#include + +int bussolaVal =200; +boolean dataReady = false; + +void setup() +{ + Serial.begin(9600); + Wire.begin(); +} + + +void loop() +{ + delay(200); + + Wire.requestFrom(0x12 , 2); + delay(50); + boolean timeout = true; + for (int i = 0; i < 10; i++) { + if (Wire.available() > 0) { + timeout = false; + Serial.print("Receive"); + bussolaVal=Wire.receive(); + Serial.println(bussolaVal); + break; + } + + } + Serial.println("esperando"); + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/home3/RGB.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/home3/RGB.ino new file mode 100644 index 0000000..d549ee8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/home3/RGB.ino @@ -0,0 +1,62 @@ +void modo_change_rgb_red_setup() { + lcd.setCursor(0, 1); + lcd.print("RED"); + rgb='R'; +} +void modo_change_rgb_green_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("GREEN"); + rgb='G'; +} +void modo_change_rgb_blue_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("BLUE"); + rgb='B'; +} +void modo_change_rgb() { + lcd.clear(); + lcd.setCursor(0, 0); + readPing(); + int port = 0; + if(rgb=='R') { + port = RED; + lcd.print("RGB Red"); + } + else if(rgb=='G') { + port = GREEN; + lcd.print("RGB Green"); + } + else if(rgb=='B') { + port = BLUE; + lcd.print("RGB Blue"); + } + if(cm<10) { + delay(200); + readPing(); + if(cm<10){ + blink(port, 3, 100); + while(cm<50) { + int cmok=cm; + cmok = cmok>25 ? 25 : cmok; + cmok = cmok<5 ? 5 : cmok; + + int amount = map(cmok,5,25,255,0); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(amount); + analogWrite(port, amount); + delay(50); + readPing(); + } + } + } + delay(150); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/home3/home3.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/home3/home3.ino new file mode 100644 index 0000000..b073dcf --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/home3/home3.ino @@ -0,0 +1,280 @@ +#include +#include +#include +#include "hrmi_funcs.h" + +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 +#define MAX_IN_BUFFSIZE 16 + +LiquidCrystal_I2C lcd(0x27,16,2); + +#define RELAY1 7 +#define RELAY2 8 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo + +#define BLUE 9 +#define GREEN 6 +#define RED 3 + +#define TEMPERATURE 2 +#define LIGHT 3 +#define PING_PIN 5 + +#define LED 13 +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use + +long duration, inches, cm; +boolean connected = false; +long handTimer=0; + +char rgb='R'; +void setup() +{ + hrmi_open(); + + Kernel.setup(INTERRUPTION); + + Kernel.registerMode("M1", modo_default_setup); + Kernel.registerTask(modo_default); + Kernel.registerMode("MH", modo_heart_monitor_setup); + Kernel.registerTask(modo_heart_monitor); + + Kernel.registerMode("M2", modo_change_rgb_red_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M3", modo_change_rgb_green_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M4", modo_change_rgb_blue_setup); + Kernel.registerTask(modo_change_rgb); + + Serial.begin(115200); + pinMode(LED, OUTPUT); + //pinMode(RELAY1, OUTPUT); + //pinMode(RELAY2, OUTPUT); + lcd.init(); + lcd.setBacklight(0); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print("by Globalcode"); + delay(500); +} + + +void loop() +{ + Kernel.loop(); +} +void modo_heart_monitor_setup() { +} +void modo_heart_monitor() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + //} + Serial.println(" "); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Heart Monitor"); + lcd.setCursor(0, 1); + //char c*[]; + //toa(i2cRspArray[2],&c); + String n = String(i2cRspArray[2]); + + lcd.print(i2cRspArray[2],DEC); + + } + if (++numEntries > 30) numEntries = 0; + Kernel.wait(300); +} + +void modo_default_setup() { + lcd.setBacklight(15); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); +} +void modo_default() { + + if(Serial.available()) receiveCommand(); + if(millis()-handTimer>1000) { + readPing(); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(readTemperatureCelsius()); + handTimer=millis(); + } + +} + +float readTemperatureCelsius() { + float temperatura = (analogRead(TEMPERATURE) * 0.00488); // 5V / 1023 = 0.00488 (precisão do A/D) + temperatura = temperatura * 100; //Converte milivolts para graus celcius, lembrando que a cada 10mV equivalem a 1 grau celcius + return temperatura; +} + +void handShake() { + //Serial.print("ID 0|bluetooth prototype device|6|A|relay|B|dimmer|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.print("ID 1|bluetooth board sensor|6|H|heartbeat|C|temperature-bluetooth|D|light-bluetooth|S|allsensors|R|RGB-bluetooth|F|distance"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); + connected=false; +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + //if(comando[0]=='A') relayCommand(comando[1], 'A'); + //if(comando[0]=='B') relayCommand(comando[1], 'B'); + if(comando[0]=='R') RGB(comando); + if(comando[0]=='D') readLight(); + if(comando[0]=='H') readHeartBeat(); + if(comando[0]=='F') readDistance(); + if(comando[0]=='C') readTemperature(); + if(comando[0]=='S') readAllSensors(); + if(comando[0]=='X') shutdown(); +} +void readHeartBeat() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + Serial.flush(); + } + if (++numEntries > 30) numEntries = 0; +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void readLight() { + String toSend = String(analogRead(LIGHT)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(TEMPERATURE)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + Serial.print("|"); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + +void readDistance() { + readPing(); + sendToPC(String(cm)); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + + + + + + + +void blink(int port, int n, int d) { + pinMode(port, OUTPUT); + for(int x=0;x + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.write(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome/jHome.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome/jHome.pde new file mode 100644 index 0000000..cbe1b16 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome/jHome.pde @@ -0,0 +1,176 @@ +# Default jHome pin +#define RX 0 +#define TX 1 +#define AUX_INT 2 + +#define RELAY1 3 +#define RELAY2 4 + +#define RED 5 +#define GREEN 6 + +#define AUX1 7 +#define AUX2 8 + +#define BLUE 9 +//10, 11, 12, 13 SPI port reserved for ethernet + +//ANALOG +#define RELAY1 14 //0 +#define RELAY2 15 //1 + +#define TEMPERATURE 2 +#define LIGHT 3 +//4, 5 reserved for I2C component, ex. LCD display + +long duration, inches, cm; +boolean connected = false; + +void setup() +{ + Serial.begin(115200); + pinMode(LED, OUTPUT); + pinMode(RELAY1, OUTPUT); + pinMode(RELAY2, OUTPUT); + pinMode(PORTAO_1, OUTPUT); + pinMode(PORTAO_2, OUTPUT); + +} + +void loop() +{ + if(Serial.available()) receiveCommand(); +} + +void handShake() { + //Serial.print("ID 0|bluetooth prototype device|6|A|relay|B|dimmer|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.print("ID 1|USB prototype device|6|A|lamp|B|wallsocket|C|temperature|D|light|S|allsensors|R|RGB"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); + connected=false; +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + if(comando[0]=='A') relayCommand(comando[1], 'A'); + if(comando[0]=='B') relayCommand(comando[1], 'B'); + if(comando[0]=='R') RGB(comando); + if(comando[0]=='D') readLight(); + if(comando[0]=='F') readDistance(); + if(comando[0]=='C') readTemperature(); + if(comando[0]=='S') readAllSensors(); + if(comando[0]=='X') shutdown(); +} + +void relayCommand(char operation, char relay) { + if(operation=='+') { + digitalWrite(relay=='A' ? RELAY1 : RELAY2, HIGH); + } + else if(operation=='-') { + digitalWrite(relay=='A' ? RELAY1 : RELAY2, LOW); + } +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void dimmer(char* comando) { +} + +void readLight() { + String toSend = String(analogRead(LIGHT)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(TEMPERATURE)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + +void readDistance() { + readPing(); + sendToPC(cm); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_device1/jHome_device1.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_device1/jHome_device1.pde new file mode 100644 index 0000000..8ec7f8b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_device1/jHome_device1.pde @@ -0,0 +1,171 @@ +#define RELAY1 2 +#define RELAY2 4 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo + +#define BLUE 9 +#define GREEN 6 +#define RED 5 + +#define TEMPERATURE 2 +#define LIGHT 3 +#define PING_PIN 3 + +#define PORTAO_1 7 +#define PORTAO_2 8 + +#define LED 13 + +long duration, inches, cm; +boolean connected = false; + +void setup() +{ + Serial.begin(115200); + pinMode(LED, OUTPUT); + pinMode(RELAY1, OUTPUT); + pinMode(RELAY2, OUTPUT); + pinMode(PORTAO_1, OUTPUT); + pinMode(PORTAO_2, OUTPUT); + +} + +void loop() +{ + if(Serial.available()) receiveCommand(); +} + +void handShake() { + //Serial.print("ID 0|bluetooth prototype device|6|A|relay|B|dimmer|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.print("ID 1|USB prototype device|6|A|lamp|B|wallsocket|C|temperature|D|light|S|allsensors|R|RGB"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); + connected=false; +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + if(comando[0]=='A') relayCommand(comando[1], 'A'); + if(comando[0]=='B') relayCommand(comando[1], 'B'); + if(comando[0]=='R') RGB(comando); + if(comando[0]=='D') readLight(); + if(comando[0]=='F') readDistance(); + if(comando[0]=='C') readTemperature(); + if(comando[0]=='S') readAllSensors(); + if(comando[0]=='X') shutdown(); +} + +void relayCommand(char operation, char relay) { + if(operation=='+') { + digitalWrite(relay=='A' ? RELAY1 : RELAY2, HIGH); + } + else if(operation=='-') { + digitalWrite(relay=='A' ? RELAY1 : RELAY2, LOW); + } +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void dimmer(char* comando) { +} + +void readLight() { + String toSend = String(analogRead(LIGHT)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(TEMPERATURE)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + +void readDistance() { + readPing(); + sendToPC(cm); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_deviceJL/jHome_deviceJL.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_deviceJL/jHome_deviceJL.ino new file mode 100644 index 0000000..ae85fff --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_deviceJL/jHome_deviceJL.ino @@ -0,0 +1,136 @@ + +#define RELAY1 14 +#define RELAY2 15 +#define RELAY3 16 +#define RELAY4 17 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo + +#define BLUE 9 +#define GREEN 6 +#define RED 5 + +#define TEMPERATURE 2 +#define LIGHT 3 +#define PING_PIN 3 + +#define LED 13 + +long duration, inches, cm; +boolean connected = false; + +void setup() +{ + Serial.begin(115200); + pinMode(LED, OUTPUT); + pinMode(RELAY1, OUTPUT); + pinMode(RELAY2, OUTPUT); + pinMode(RELAY3, OUTPUT); + pinMode(RELAY4, OUTPUT); + +} + +void loop() +{ + if(Serial.available()) receiveCommand(); +} + +void handShake() { + //Serial.print("ID 0|bluetooth prototype device|6|A|relay|B|dimmer|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.print("ID 4|USB prototype device|4|A|wallsock1|B|wallsocket2|C|wallsock3|D|wallsock4"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); + connected=false; +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + if(comando[0]=='A') relayCommand(comando[1], 'A'); + if(comando[0]=='B') relayCommand(comando[1], 'B'); + if(comando[0]=='C') relayCommand(comando[1], 'C'); + if(comando[0]=='D') relayCommand(comando[1], 'D'); + if(comando[0]=='X') shutdown(); +} + +void relayCommand(char operation, char relay) { + if(operation=='+') { + digitalWrite(relay=='A' ? RELAY1 : relay=='B' ? RELAY2 : relay=='C' ? RELAY3 : RELAY4, HIGH); + } + else if(operation=='-') { + digitalWrite(relay=='A' ? RELAY1 : relay=='B' ? RELAY2 : relay=='C' ? RELAY3 : RELAY4, LOW); + } + +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void dimmer(char* comando) { +} + +void readLight() { + String toSend = String(analogRead(LIGHT)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(TEMPERATURE)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + + + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_sensor/hrmi_funcs.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_sensor/hrmi_funcs.cpp new file mode 100644 index 0000000..a0c8c46 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_sensor/hrmi_funcs.cpp @@ -0,0 +1,60 @@ +/* + * hrmi_funcs.cpp + * + * Arduino library to communicate with a HRMI using I2C + * + * Written by Dan Julio, www.danjuliodesigns.com + * Version 1.1, 12/28/2008 + * + */ + + #include + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.write(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_sensor/jHome_sensor.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_sensor/jHome_sensor.ino new file mode 100644 index 0000000..bfa3195 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_sensor/jHome_sensor.ino @@ -0,0 +1,341 @@ +#include +#include +#include + +#include "hrmi_funcs.h" +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 +#define MAX_IN_BUFFSIZE 16 + +LiquidCrystal_I2C lcd(0x27,16,2); + +#define RELAY1 7 +#define RELAY2 8 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo + +#define BLUE 9 +#define GREEN 6 +#define RED 3 + +#define TEMPERATURE 2 +#define LIGHT 3 +#define PING_PIN 5 + +#define LED 13 +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use + +long duration, inches, cm; +boolean connected = false; +long handTimer=0; + +char rgb='R'; +void setup() +{ + hrmi_open(); + + Kernel.setup(INTERRUPTION); + + Kernel.registerMode("M1", modo_default_setup); + Kernel.registerTask(modo_default); + Kernel.registerMode("MH", modo_heart_monitor_setup); + Kernel.registerTask(modo_heart_monitor); + + Kernel.registerMode("M2", modo_change_rgb_red_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M3", modo_change_rgb_green_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M4", modo_change_rgb_blue_setup); + Kernel.registerTask(modo_change_rgb); + + Serial.begin(115200); + pinMode(LED, OUTPUT); + //pinMode(RELAY1, OUTPUT); + //pinMode(RELAY2, OUTPUT); + lcd.init(); + lcd.setBacklight(0); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print("by Globalcode"); + delay(500); +} + + +void loop() +{ + Kernel.loop(); +} +void modo_heart_monitor_setup() { +} +void modo_heart_monitor() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + //} + Serial.println(" "); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Heart Monitor"); + lcd.setCursor(0, 1); + //char c*[]; + //toa(i2cRspArray[2],&c); + String n = String(i2cRspArray[2]); + + lcd.print(i2cRspArray[2],DEC); + + } + if (++numEntries > 30) numEntries = 0; + Kernel.wait(300); +} + +void modo_change_rgb_red_setup() { + lcd.setCursor(0, 1); + lcd.print("RED"); + rgb='R'; +} +void modo_change_rgb_green_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("GREEN"); + rgb='G'; +} +void modo_change_rgb_blue_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("BLUE"); + rgb='B'; +} +void modo_change_rgb() { + lcd.clear(); + lcd.setCursor(0, 0); + readPing(); + int port = 0; + if(rgb=='R') { + port = RED; + lcd.print("RGB Red"); + } + else if(rgb=='G') { + port = GREEN; + lcd.print("RGB Green"); + } + else if(rgb=='B') { + port = BLUE; + lcd.print("RGB Blue"); + } + if(cm<10) { + delay(200); + readPing(); + if(cm<10){ + blink(port, 3, 100); + while(cm<50) { + int cmok=cm; + cmok = cmok>25 ? 25 : cmok; + cmok = cmok<5 ? 5 : cmok; + + int amount = map(cmok,5,25,255,0); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(amount); + analogWrite(port, amount); + delay(50); + readPing(); + } + } + } + delay(150); +} +void modo_default_setup() { + lcd.setBacklight(15); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); +} +void modo_default() { + + if(Serial.available()) receiveCommand(); + if(millis()-handTimer>1000) { + readPing(); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(readTemperatureCelsius()); + handTimer=millis(); + } + +} + +float readTemperatureCelsius() { + float temperatura = (analogRead(TEMPERATURE) * 0.00488); // 5V / 1023 = 0.00488 (precisão do A/D) + temperatura = temperatura * 100; //Converte milivolts para graus celcius, lembrando que a cada 10mV equivalem a 1 grau celcius + return temperatura; +} + +void handShake() { + //Serial.print("ID 0|bluetooth prototype device|6|A|relay|B|dimmer|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.print("ID 1|bluetooth board sensor|6|H|heartbeat|C|temperature-bluetooth|D|light-bluetooth|S|allsensors|R|RGB-bluetooth|F|distance"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); + connected=false; +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + //if(comando[0]=='A') relayCommand(comando[1], 'A'); + //if(comando[0]=='B') relayCommand(comando[1], 'B'); + if(comando[0]=='R') RGB(comando); + if(comando[0]=='D') readLight(); + if(comando[0]=='H') readHeartBeat(); + if(comando[0]=='F') readDistance(); + if(comando[0]=='C') readTemperature(); + if(comando[0]=='S') readAllSensors(); + if(comando[0]=='X') shutdown(); +} +void readHeartBeat() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + Serial.flush(); + } + if (++numEntries > 30) numEntries = 0; +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void readLight() { + String toSend = String(analogRead(LIGHT)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(TEMPERATURE)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + Serial.print("|"); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + +void readDistance() { + readPing(); + sendToPC(String(cm)); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + + + + + + + +void blink(int port, int n, int d) { + pinMode(port, OUTPUT); + for(int x=0;x + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.write(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_sensor_teste/jHome_sensor_teste.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_sensor_teste/jHome_sensor_teste.ino new file mode 100644 index 0000000..d89df85 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_sensor_teste/jHome_sensor_teste.ino @@ -0,0 +1,303 @@ +#include +#include +#include +#include +#include "etherShield.h" +#include "ETHER_28J60.h" +#include "hrmi_funcs.h" +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 +#define MAX_IN_BUFFSIZE 16 +Device homeDevice=Device("sensor-device"); + +LiquidCrystal_I2C lcd(0x27,16,2); + + +#define BLUE 9 +#define GREEN 6 +#define RED 3 + +#define PING_PIN 5 + +#define LED 13 +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use + +long duration, inches, cm; +boolean connected = false; +long handTimer=0; + +char rgb='R'; +void setup() +{ + homeDevice.add("red", PWM, 3); + homeDevice.add("green", PWM, 6); + homeDevice.add("blue", PWM, 9); + + homeDevice.add("distance", LIB, 5); + + homeDevice.add("light", LIGHT, 3); + homeDevice.add("temp", TEMP, 2); + hrmi_open(); + + Kernel.setup(INTERRUPTION); + + Kernel.registerMode("M1", modo_default_setup); + Kernel.registerTask(modo_d efault); + Kernel.registerMode("MH", modo_heart_monitor_setup); + Kernel.registerTask(modo_heart_monitor); + + Kernel.registerMode("M2", modo_change_rgb_red_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M3", modo_change_rgb_green_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M4", modo_change_rgb_blue_setup); + Kernel.registerTask(modo_change_rgb); + + Serial.begin(115200); + pinMode(LED, OUTPUT); + //pinMode(RELAY1, OUTPUT); + //pinMode(RELAY2, OUTPUT); + lcd.init(); + lcd.setBacklight(0); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print("by Globalcode"); + delay(500); +} + + +void loop() +{ + Kernel.loop(); +} + +void modo_heart_monitor_setup() { +} + +void modo_heart_monitor() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + //} + Serial.println(" "); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Heart Monitor"); + lcd.setCursor(0, 1); + //char c*[]; + //toa(i2cRspArray[2],&c); + String n = String(i2cRspArray[2]); + + lcd.print(i2cRspArray[2],DEC); + + } + if (++numEntries > 30) numEntries = 0; + Kernel.wait(300); +} + +void modo_change_rgb_red_setup() { + lcd.setCursor(0, 1); + lcd.print("RED"); + rgb='R'; +} +void modo_change_rgb_green_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("GREEN"); + rgb='G'; +} +void modo_change_rgb_blue_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("BLUE"); + rgb='B'; +} +void modo_change_rgb() { + lcd.clear(); + lcd.setCursor(0, 0); + readPing(); + int port = 0; + if(rgb=='R') { + port = RED; + lcd.print("RGB Red"); + } + else if(rgb=='G') { + port = GREEN; + lcd.print("RGB Green"); + } + else if(rgb=='B') { + port = BLUE; + lcd.print("RGB Blue"); + } + if(cm<10) { + delay(200); + readPing(); + if(cm<10){ + blink(port, 3, 100); + while(cm<50) { + int cmok=cm; + cmok = cmok>25 ? 25 : cmok; + cmok = cmok<5 ? 5 : cmok; + + int amount = map(cmok,5,25,255,0); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(amount); + analogWrite(port, amount); + delay(50); + readPing(); + } + } + } + delay(150); +} +void modo_default_setup() { + lcd.setBacklight(15); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); +} +void modo_default() { + homeDevice.loop(); + //if(Serial.available()) receiveCommand(); + if(millis()-handTimer>1000) { + readPing(); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(readTemperatureCelsius()); + handTimer=millis(); + readDistance(); + } + +} + +float readTemperatureCelsius() { + float temperatura = (analogRead(2) * 0.00488); // 5V / 1023 = 0.00488 (precisão do A/D) + temperatura = temperatura * 100; //Converte milivolts para graus celcius, lembrando que a cada 10mV equivalem a 1 grau celcius + return temperatura; +} +void readHeartBeat() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + Serial.flush(); + } + if (++numEntries > 30) numEntries = 0; +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void readLight() { + String toSend = String(analogRead(3)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(2)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + Serial.print("|"); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + +void readDistance() { + readPing(); + sendToPC(String(cm)); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); + Serial.println(analogRead(3)); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + + + + + + + +void blink(int port, int n, int d) { + pinMode(port, OUTPUT); + for(int x=0;x + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.write(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_sensor_teste1/jHome_sensor_teste1.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_sensor_teste1/jHome_sensor_teste1.ino new file mode 100644 index 0000000..76f98b6 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/jHome_sensor_teste1/jHome_sensor_teste1.ino @@ -0,0 +1,304 @@ +#include +#include +#include +#include +#include "etherShield.h" +#include "ETHER_28J60.h" +#include "hrmi_funcs.h" +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 +#define MAX_IN_BUFFSIZE 16 +Device homeDevice=Device("sensor-device"); + +LiquidCrystal_I2C lcd(0x27,16,2); + + +#define BLUE 9 +#define GREEN 6 +#define RED 3 + +#define PING_PIN 5 + +#define LED 13 +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use + +long duration, inches, cm; +boolean connected = false; +long handTimer=0; + +char rgb='R'; +void setup() +{ + homeDevice.add("red", PWM, 3); + homeDevice.add("green", PWM, 6); + homeDevice.add("blue", PWM, 9); + + homeDevice.add("distance", PING, 5); + + homeDevice.add("light", LIGHT, 3); + homeDevice.add("temp", TEMP, 2); + hrmi_open(); + + + Kernel.setup(INTERRUPTION); + + Kernel.registerMode("M1", modo_default_setup); + Kernel.registerTask(modo_default); + Kernel.registerMode("MH", modo_heart_monitor_setup); + Kernel.registerTask(modo_heart_monitor); + + Kernel.registerMode("M2", modo_change_rgb_red_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M3", modo_change_rgb_green_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M4", modo_change_rgb_blue_setup); + Kernel.registerTask(modo_change_rgb); + + + Serial.begin(115200); + pinMode(LED, OUTPUT); + //pinMode(RELAY1, OUTPUT); + //pinMode(RELAY2, OUTPUT); + lcd.init(); + lcd.setBacklight(0); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print("by Globalcode"); + delay(500); +} + + +void loop() +{ + Kernel.loop(); + +} + +void modo_heart_monitor_setup() { +} + +void modo_heart_monitor() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + //} + Serial.println(" "); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Heart Monitor"); + lcd.setCursor(0, 1); + //char c*[]; + //toa(i2cRspArray[2],&c); + String n = String(i2cRspArray[2]); + + lcd.print(i2cRspArray[2],DEC); + + } + if (++numEntries > 30) numEntries = 0; + Kernel.wait(300); +} + +void modo_change_rgb_red_setup() { + lcd.setCursor(0, 1); + lcd.print("RED"); + rgb='R'; +} +void modo_change_rgb_green_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("GREEN"); + rgb='G'; +} +void modo_change_rgb_blue_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("BLUE"); + rgb='B'; +} +void modo_change_rgb() { + lcd.clear(); + lcd.setCursor(0, 0); + readPing(); + int port = 0; + if(rgb=='R') { + port = RED; + lcd.print("RGB Red"); + } + else if(rgb=='G') { + port = GREEN; + lcd.print("RGB Green"); + } + else if(rgb=='B') { + port = BLUE; + lcd.print("RGB Blue"); + } + if(cm<10) { + delay(200); + readPing(); + if(cm<10){ + blink(port, 3, 100); + while(cm<50) { + int cmok=cm; + cmok = cmok>25 ? 25 : cmok; + cmok = cmok<5 ? 5 : cmok; + + int amount = map(cmok,5,25,255,0); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(amount); + analogWrite(port, amount); + delay(50); + readPing(); + } + } + } + delay(150); +} +void modo_default_setup() { + lcd.setBacklight(15); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); +} +void modo_default() { + homeDevice.loop(); + //if(Serial.available()) receiveCommand(); + if(millis()-handTimer>1000) { + readPing(); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(readTemperatureCelsius()); + handTimer=millis(); + } + +} + +float readTemperatureCelsius() { + float temperatura = (analogRead(2) * 0.00488); // 5V / 1023 = 0.00488 (precisão do A/D) + temperatura = temperatura * 100; //Converte milivolts para graus celcius, lembrando que a cada 10mV equivalem a 1 grau celcius + return temperatura; +} +void readHeartBeat() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + Serial.flush(); + } + if (++numEntries > 30) numEntries = 0; +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void readLight() { + String toSend = String(analogRead(3)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(2)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + Serial.print("|"); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + +char* readDistance() { + readPing(); + + sendToPC(String(cm)); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + Serial.print("duration "); + Serial.println(duration); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + + + + + + + +void blink(int port, int n, int d) { + pinMode(port, OUTPUT); + for(int x=0;xanalogRead(POTENCIOMETRO_1)) { + digitalWrite(TOMADA, HIGH); + } + else { + digitalWrite(TOMADA, LOW); + } + Serial.println(ldr); + delay(200); + +} + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.cpp.o new file mode 100644 index 0000000..fe5656c Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.elf new file mode 100644 index 0000000..fec028f Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.hex new file mode 100644 index 0000000..d42652f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.hex @@ -0,0 +1,143 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C949B020C948A000C94C5000C948A00BA +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C00000007E0111241FBECFEFD8E0DEBFCDBF00 +:1000D00011E0A0E0B1E0ECECF8E002C005900D9278 +:1000E000A830B107D9F711E0A8E0B1E001C01D9236 +:1000F000AA3AB107E1F710E0C4ECD0E004C02297BF +:10010000FE010E946004C23CD107C9F70E94BE00F4 +:100110000C9464040C940000CF93DF9380E00E9461 +:100120006F03EC0181E00E946F038C179D071CF4A4 +:1001300082E161E002C082E160E00E94AD038CE8F0 +:1001400091E0BE010E948B0268EC70E080E090E0DC +:100150000E940B03DF91CF91089581E060E00E943F +:100160008D0382E161E00E948D038CE891E040E81C +:1001700055E260E070E00E94020108950E9435039C +:100180000E94AD000E948C00FDCF1F920F920FB60F +:100190000F9211242F933F934F935F936F937F930D +:1001A0008F939F93AF93BF93EF93FF934091C600BC +:1001B000E0918801F0918901CF01019660E870E03B +:1001C0000E94FA039C0180918A0190918B0128176B +:1001D000390739F0E85FFE4F40833093890120935F +:1001E0008801FF91EF91BF91AF919F918F917F9186 +:1001F0006F915F914F913F912F910F900FBE0F9094 +:100200001F901895AF92BF92CF92DF92EF92FF921C +:100210000F931F93CF93DF936C017A018B01DC0165 +:100220001496AD90BC901597CB01BA0122E030E056 +:1002300040E050E00E942F04205C3D4B404F5F4F58 +:10024000CA01B901A80197010E942F04C901DA016E +:100250000197A109B109292F3A2F4B2F552747FDA7 +:100260005A950196A11DB11DE5012883E601EE8195 +:10027000FF8181508083EA85FB85208141E050E049 +:10028000CA010E8402C0880F991F0A94E2F7282B36 +:100290002083EA85FB852081CA010F8402C0880F74 +:1002A000991F0A94E2F7282B2083EA85FB85808139 +:1002B000088802C0440F551F0A94E2F7842B8083FC +:1002C000DF91CF911F910F91FF90EF90DF90CF9032 +:1002D000BF90AF900895FC01A085B18521898C91D4 +:1002E00090E0022E02C0959587950A94E2F780FF70 +:1002F000F6CF0484F585E02D6083089585E091E0D4 +:1003000090938D0180938C0188E091E090938F0110 +:1003100080938E0185EC90E0909391018093900101 +:1003200084EC90E0909393018093920180EC90E0B4 +:10033000909395018093940181EC90E090939701C4 +:100340008093960186EC90E09093990180939801B8 +:1003500084E080939A0183E080939B0187E08093FF +:100360009C0185E080939D0108950F931F938C015C +:10037000DC01ED91FC910190F081E02D6DE009959B +:10038000D801ED91FC910190F081E02DC8016AE067 +:1003900009951F910F9108952F923F924F925F926E +:1003A0006F927F928F929F92AF92BF92CF92DF9285 +:1003B000EF92FF920F931F93DF93CF93CDB7DEB7EA +:1003C000A0970FB6F894DEBF0FBECDBF1C016A0127 +:1003D0007B01411551056105710549F4DC01ED9181 +:1003E000FC910190F081E02D60E3099554C08824D0 +:1003F00099245401422E55246624772401E010E00C +:100400000C0F1D1F080D191DC701B601A301920194 +:100410000E940D04F80160830894811C911CA11CAA +:10042000B11CC701B601A30192010E940D04C901CC +:10043000DA016C017D01C114D104E104F104F1F68B +:1004400081E0E82EF12CEC0EFD1EE80CF91C3E01BB +:100450000894611C711CD501C4010197A109B1095F +:100460006C01C818D90814C0F601EE0DFF1D60819B +:100470006A3010F4605D01C0695CD101ED91FC91BE +:100480000190F081E02DC10109950894E108F1087F +:100490006E147F0449F7A0960FB6F894DEBF0FBE26 +:1004A000CDBFCF91DF911F910F91FF90EF90DF9023 +:1004B000CF90BF90AF909F908F907F906F905F9004 +:1004C0004F903F902F900895EF92FF920F931F93BC +:1004D000CF93DF93EC017A018B0177FF0FC0E881A6 +:1004E000F9810190F081E02D6DE20995109500955C +:1004F000F094E094E11CF11C011D111DCE01B80126 +:10050000A7012AE00E94CC01DF91CF911F910F91AA +:10051000FF90EF9008950F931F938C01AB01662716 +:1005200057FD6095762F0E946402C8010E94B501B4 +:100530001F910F9108951F920F920FB60F921124E1 +:100540002F938F939F93AF93BF9380919E01909130 +:100550009F01A091A001B091A1010196A11DB11D23 +:1005600080939E0190939F01A093A001B093A1015D +:100570008091A2019091A301A091A401B091A50145 +:100580008050904CAF4FBF4F8093A2019093A30136 +:10059000A093A401B093A50127C08091A2019091DE +:1005A000A301A091A401B091A50180589E43A04051 +:1005B000B0408093A2019093A301A093A401B093B3 +:1005C000A5018091A6019091A701A091A801B091E9 +:1005D000A9010196A11DB11D8093A6019093A701C9 +:1005E000A093A801B093A9018091A2019091A301C9 +:1005F000A091A401B091A50181589E43A040B040B4 +:1006000060F6BF91AF919F918F912F910F900FBE88 +:100610000F901F901895EF92FF920F931F937B01FD +:100620008C018FB7F8944091A6015091A701609179 +:10063000A8017091A9018FBF2FB7F8948091A601EE +:100640009091A701A091A801B091A9012FBF841B8F +:10065000950BA60BB70BE816F9060A071B0760F700 +:100660001F910F91FF90EF900895789484B5826068 +:1006700084BD84B5816084BD85B5826085BD85B546 +:10068000816085BDEEE6F0E0808181608083E1E8F5 +:10069000F0E0808182608083808181608083E0E8F7 +:1006A000F0E0808181608083E1EBF0E08081846014 +:1006B0008083E0EBF0E0808181608083EAE7F0E016 +:1006C000808184608083808182608083808181607A +:1006D00080838081806880831092C1000895877034 +:1006E000909100019295990F990F907C982B90937F +:1006F0007C0080917A00806480937A0080917A00F7 +:1007000086FDFCCF2091780040917900942F80E005 +:1007100030E0282B392BC9010895282F30E0C9017A +:1007200086569F4FFC0194912A573F4FF9018491BF +:10073000882391F0E82FF0E0EE0FFF1FE859FF4FFC +:10074000A591B491662329F48C91909589238C937B +:1007500008958C91892B8C930895482F50E0CA01FD +:1007600082559F4FFC012491CA0186569F4FFC0180 +:1007700094914A575F4FFA0134913323D1F12223E8 +:1007800031F1233021F4809180008F7705C024302F +:1007900031F4809180008F7D8093800018C02130DB +:1007A00019F484B58F7704C0223021F484B58F7D8D +:1007B00084BD0DC0263021F48091B0008F7705C034 +:1007C000273029F48091B0008F7D8093B000E32F13 +:1007D000F0E0EE0FFF1FEE58FF4FA591B491662396 +:1007E00029F48C91909589238C9308958C91892B71 +:1007F0008C93089597FB092E07260AD077FD04D025 +:1008000049D006D000201AF4709561957F4F089565 +:10081000F6F7909581959F4F0895A1E21A2EAA1B95 +:10082000BB1BFD010DC0AA1FBB1FEE1FFF1FA217A0 +:10083000B307E407F50720F0A21BB30BE40BF50B9D +:10084000661F771F881F991F1A9469F76095709526 +:10085000809590959B01AC01BD01CF01089597FB58 +:10086000092E05260ED057FD04D0D7DF0AD0001C74 +:1008700038F450954095309521953F4F4F4F5F4F3D +:100880000895F6F790958095709561957F4F8F4FFD +:100890009F4F0895AA1BBB1B51E107C0AA1FBB1F96 +:1008A000A617B70710F0A61BB70B881F991F5A95FC +:1008B000A9F780959095BC01CD010895EE0FFF1F1B +:0C08C0000590F491E02D0994F894FFCF0E +:0808CC0001000000006B0100B7 +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.pde new file mode 100644 index 0000000..e9eb876 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/tomada.pde @@ -0,0 +1,21 @@ +#define TOMADA 18 +#define POTENCIOMETRO_1 1 +#define LDR 0 +void setup() { + pinMode(POTENCIOMETRO_1, INPUT); + pinMode(TOMADA, OUTPUT); + Serial.begin(9600); +} + +void loop() { + int ldr = analogRead(LDR); + if(ldr>analogRead(POTENCIOMETRO_1)) { + digitalWrite(TOMADA, HIGH); + } + else { + digitalWrite(TOMADA, LOW); + } + Serial.println(ldr); + delay(200); + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring.c.o new file mode 100644 index 0000000..acbd542 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_analog.c.o new file mode 100644 index 0000000..b56797d Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_digital.c.o new file mode 100644 index 0000000..3928ccd Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_pulse.c.o new file mode 100644 index 0000000..525eda2 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_serial.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_serial.c.o new file mode 100644 index 0000000..b8d4c17 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_serial.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_shift.c.o new file mode 100644 index 0000000..8e0db5b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/tomada.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/tomada.pde new file mode 100644 index 0000000..03aa143 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/tomada/tomada.pde @@ -0,0 +1,13 @@ +#define TOMADA 2 +void setup() { + pinMode(TOMADA, OUTPUT); + Serial.begin(9600); +} + +void loop() { + digitalWrite(TOMADA, HIGH); + delay(2000); + digitalWrite(TOMADA, LOW); + delay(2000); + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ubatubino_sample1/ubatubino_sample1.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ubatubino_sample1/ubatubino_sample1.pde new file mode 100644 index 0000000..31bb8b2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/ubatubino_sample1/ubatubino_sample1.pde @@ -0,0 +1,43 @@ +#define T1 3 +#define T2 9 +#define T3 11 +#define T4 12 + +void setup() { + pinMode(T1,OUTPUT); + pinMode(T2,OUTPUT); + pinMode(T3,OUTPUT); + pinMode(T4,OUTPUT); +} + +void loop() { + digitalWrite(T1, HIGH); + digitalWrite(T2, HIGH); + digitalWrite(T3, HIGH); + digitalWrite(T4, HIGH); + delay(1000); + digitalWrite(T1, LOW); + digitalWrite(T2, LOW); + digitalWrite(T3, LOW); + digitalWrite(T4, LOW); + delay(1000); + + digitalWrite(T1, HIGH); + delay(1000); + digitalWrite(T1, LOW); + delay(1000); + digitalWrite(T2, HIGH); + delay(1000); + digitalWrite(T2, LOW); + delay(1000); + digitalWrite(T3, HIGH); + delay(1000); + digitalWrite(T3, LOW); + delay(1000); + digitalWrite(T4, HIGH); + delay(1000); + digitalWrite(T4, LOW); + delay(1000); + + +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/xacualeitor/xacualeitor.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/xacualeitor/xacualeitor.pde new file mode 100644 index 0000000..0bfc07a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/xacualeitor/xacualeitor.pde @@ -0,0 +1,48 @@ +// Controlling a servo position using a potentiometer (variable resistor) +// by Michal Rinott + +#include + +Servo myservo; // create servo object to control a servo +Servo myservo1; // create servo object to control a servo + +int potpin = 1; // analog pin used to connect the potentiometer +int val; // variable to read the value from the analog pin + +void setup() +{ + Serial.begin(9600); + pinMode(9, OUTPUT); + pinMode(6, OUTPUT); + + myservo.attach(10); // attaches the servo on pin 9 to the servo object + myservo1.attach(11); // attaches the servo on pin 9 to the servo object +} + +void loop() +{ + /*for(int x=45;x<145;x++) { + if(x%10==0) { + myservo.write(x); + myservo1.write(x); + } + delay(300); + } + for(int x=145;x>45;x--) { + if(x%10==0) { + myservo.write(x); + myservo1.write(x); + } + delay(300); + }*/ + myservo.write(30); + myservo1.write(30); + delay(500); + myservo.write(70); + myservo1.write(70); + delay(500); + + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/xacualeitor/xacualeitor/xacualeitor.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/xacualeitor/xacualeitor/xacualeitor.pde new file mode 100644 index 0000000..163df66 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Projetos/xacualeitor/xacualeitor/xacualeitor.pde @@ -0,0 +1,32 @@ +#include + +Servo myservo9; // create servo object to control a servo +Servo myservo10; // create servo object to control a servo + +int pos = 0; // variable to store the servo position + +void setup() +{ + myservo9.attach(11); // attaches the servo on pin 9 to the servo object + myservo10.attach(10); // attaches the servo on pin 10 to the servo object +} + +void loop() +{ + myservo10.write(95); + delay(3000); + + myservo10.write(110); + delay(3000); + /* + for(int x=85;x<105;x+=5) { + myservo10.write(x); + delay(2500); + } + + for(int x=110;x>80;x-=5) { + myservo10.write(x); + delay(2500); + }*/ +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/RCTim/RCTim.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/RCTim/RCTim.pde new file mode 100644 index 0000000..e92540f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/RCTim/RCTim.pde @@ -0,0 +1,29 @@ +int sensorPin = 5; // 220 or 1k resistor connected to this pin +long result = 0; +void setup() // run once, when the sketch starts +{ + Serial.begin(9600); + Serial.println("start"); // a personal quirk +} +void loop() // run over and over again +{ + + Serial.println( RCtime(sensorPin) ); + delay(10); + +} + +long RCtime(int sensPin){ + long result = 0; + pinMode(sensPin, OUTPUT); // make pin OUTPUT + digitalWrite(sensPin, HIGH); // make pin HIGH to discharge capacitor - study the schematic + delay(1); // wait a ms to make sure cap is discharged + + pinMode(sensPin, INPUT); // turn pin into an input and time till pin goes low + digitalWrite(sensPin, LOW); // turn pullups off - or it won't work + while(digitalRead(sensPin)){ // wait for pin to go low + result++; + } + + return result; // report results +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robo_Competicao/Robo_Competicao.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robo_Competicao/Robo_Competicao.pde new file mode 100644 index 0000000..0a8e9bc --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robo_Competicao/Robo_Competicao.pde @@ -0,0 +1,128 @@ +#include +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define DISTANCIA 1 + +int sentido; +Servo servoV; +Servo servoH; +int contador=0; +int direcaoServo=0; +long distancia; +long distanciaEsquerda; +long distanciaDireita; + +void setup() { + servoH.attach(11); + servoV.attach(10); + Serial.begin(9600); + + +} +void loop() { + /*andarFrente(2500,4); + parar(); + andarTraz(2500,4); + parar(); + girarNoEixo(2000,4,1);*/ + Serial.println(analogRead(1)); + delay(10); +} + +void lerPing() { + distancia = analogRead(1); +} +void lerPingFull() { + servoH.write(30); + delay(400); + distanciaEsquerda = analogRead(1); + servoH.write(100); + delay(400); + distancia = analogRead(1); + servoH.write(150); + delay(400); + distanciaDireita = analogRead(1); + servoH.write(90); +} + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarTraz(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarFrente(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Android_Servo/Android_Servo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Android_Servo/Android_Servo.pde new file mode 100644 index 0000000..68c9087 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Android_Servo/Android_Servo.pde @@ -0,0 +1,127 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int SensorTemperatura = 1 ; +int LDR = 5; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo servoV; +Servo servoH; +int modo = 1; +int sentido; + + +void setup() { + Serial.begin(115200); + servoH.attach(10); + servoV.attach(11); + + meetAndroid.registerFunction(acelera, 'C'); + + /* set up the LCD's number of rows and columns: + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Aguardando");*/ + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + pinMode(LED_RED, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + //testeLeds(); + servoH.write(10); + delay(1000); + servoH.write(170); + delay(1000); + servoH.write(90); + delay(1000); + servoV.write(10); + delay(1000); + servoV.write(170); + delay(1000); + servoV.write(90); + delay(1000); + +} + +void loop() { + meetAndroid.receive(); + //meetAndroid.send(analogRead(1)); + //testeLeds(); +} +void leds(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + + if(comando[0]=='R') { + pinMode(LED_RED,INPUT); + int ligado = digitalRead(LED_RED); + pinMode(LED_RED,OUTPUT); + digitalWrite(LED_RED,!ligado); + + } + else if(comando[0]=='G') { + pinMode(LED_GREEN,INPUT); + int ligado = digitalRead(LED_GREEN); + pinMode(LED_GREEN,OUTPUT); + digitalWrite(LED_GREEN,!ligado); + } + else if(comando[0]=='B') { + pinMode(LED_BLUE,INPUT); + int ligado = digitalRead(LED_BLUE); + pinMode(LED_BLUE,OUTPUT); + digitalWrite(LED_BLUE,!ligado); + } + +} +void testeLeds() { + digitalWrite(LED_RED, HIGH); + delay(200); + digitalWrite(LED_RED, LOW); + delay(200); + digitalWrite(LED_BLUE, HIGH); + delay(200); + digitalWrite(LED_BLUE, LOW); + delay(200); + digitalWrite(LED_GREEN, HIGH); + delay(200); + digitalWrite(LED_GREEN, LOW); + delay(200); +} + +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + delay(5); +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Android_Servo/AtualizarDisplay.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Android_Servo/AtualizarDisplay.pde new file mode 100644 index 0000000..51b700a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Android_Servo/AtualizarDisplay.pde @@ -0,0 +1,46 @@ +/*void atualizaDisplay() { + lcd.clear(); + + //atualiza temperatura + //lcd.setCursor(col,row); + lcd.setCursor(8,1); + lcd.print(analogRead(SensorTemperatura)/2); + lcd.print("oC"); + + Serial.print("Temperatura= "); + Serial.println(analogRead(SensorTemperatura)/2); + + //atualiza luminosidade + //lcd.setCursor(col,row); + lcd.setCursor(0,1); + lcd.print(map((analogRead(LDR)), 0, 1023, 100,0)); + lcd.print(" %"); + + Serial.print("Luminosidade= "); + Serial.println(map((analogRead(LDR)), 0, 1023, 100,0)); + Serial.println(" "); + + + //lcd.setCursor(col,row); + lcd.setCursor(0,0); + lcd.print(DistanciaEsquerda); + lcd.print(" cms"); + + //atualiza distancia esquerda + Serial.print("Distancia Esquerda= "); + Serial.println(DistanciaEsquerda); + + //atualiza distancia direita + //lcd.setCursor(col,row); + lcd.setCursor(8,0); + lcd.print(DistanciaDireita); + lcd.print(" cms"); + + Serial.print("Distancia Direita= "); + Serial.println(DistanciaDireita); + + + +} +*/ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Android_Servo/Wask.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Android_Servo/Wask.pde new file mode 100644 index 0000000..3a66535 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Android_Servo/Wask.pde @@ -0,0 +1,277 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 +long duration, inches, cm; +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServoOK(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} +void changeServo(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1/BR1.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1/BR1.pde new file mode 100644 index 0000000..4c0491a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1/BR1.pde @@ -0,0 +1,63 @@ +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 + +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 5 + +#define SERVO_1 10 +#define SERVO_2 11 + +#define MODE_DEMO 3 +#define MODE_WALK 2 +#define MODE_SUNSPOT 1 +#define MODE_STOP 0 +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=3; +Servo myservo10; // create servo object to control a servo + + +void setup() { + setupEngines(); + + setupComponents(); + myservo10.attach(10); // attaches the servo on pin 10 to the servo object + Serial.begin(9600); +} +void setupComponents() { + pinMode(9, OUTPUT); +} + +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + //andarFrente(2000,5); + + +} + +void loop(){ + if(mode==MODE_DEMO) { + //Demo(); + //return; + } + else if(mode==MODE_WALK) { + //Walk(); + } +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1/Demo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1/Demo.pde new file mode 100644 index 0000000..541d53a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1/Demo.pde @@ -0,0 +1,194 @@ +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1/Walk.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1/Walk.pde new file mode 100644 index 0000000..519d1f3 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1/Walk.pde @@ -0,0 +1,253 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + readPing(); + if(cm<30) { + digitalWrite(9, HIGH); + delay(50); + digitalWrite(9, LOW); + + parar(); + while(cm<30) { + if(random(0,1)) { + girarNoEixo(200,3,random(0,1)); + } + else { + andarTraz(500,3); + } + readPing(); + } + } + else if(cm>30 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + + +void readPing() +{ + /* + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm);*/ +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1_Coracao/BR1_Coracao.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1_Coracao/BR1_Coracao.pde new file mode 100644 index 0000000..4c0491a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1_Coracao/BR1_Coracao.pde @@ -0,0 +1,63 @@ +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 + +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 5 + +#define SERVO_1 10 +#define SERVO_2 11 + +#define MODE_DEMO 3 +#define MODE_WALK 2 +#define MODE_SUNSPOT 1 +#define MODE_STOP 0 +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=3; +Servo myservo10; // create servo object to control a servo + + +void setup() { + setupEngines(); + + setupComponents(); + myservo10.attach(10); // attaches the servo on pin 10 to the servo object + Serial.begin(9600); +} +void setupComponents() { + pinMode(9, OUTPUT); +} + +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + //andarFrente(2000,5); + + +} + +void loop(){ + if(mode==MODE_DEMO) { + //Demo(); + //return; + } + else if(mode==MODE_WALK) { + //Walk(); + } +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1_Coracao/Demo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1_Coracao/Demo.pde new file mode 100644 index 0000000..541d53a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1_Coracao/Demo.pde @@ -0,0 +1,194 @@ +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1_Coracao/Walk.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1_Coracao/Walk.pde new file mode 100644 index 0000000..519d1f3 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1_Coracao/Walk.pde @@ -0,0 +1,253 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + readPing(); + if(cm<30) { + digitalWrite(9, HIGH); + delay(50); + digitalWrite(9, LOW); + + parar(); + while(cm<30) { + if(random(0,1)) { + girarNoEixo(200,3,random(0,1)); + } + else { + andarTraz(500,3); + } + readPing(); + } + } + else if(cm>30 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + + +void readPing() +{ + /* + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm);*/ +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1_Garra_LCD/BR1_Garra_LCD.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1_Garra_LCD/BR1_Garra_LCD.pde new file mode 100644 index 0000000..7b380ce --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR1_Garra_LCD/BR1_Garra_LCD.pde @@ -0,0 +1,53 @@ +#include +#include +LiquidCrystal_I2C lcd(0x27,16,2); + +void setup() { + lcd.init(); + lcd.backlight(); + lcd.setCursor(0, 1); + lcd.print("Program-ME v2"); + + Serial.begin(9600); + + Wire.begin(); + delay(1000); + Wire.beginTransmission(65); + Wire.send("1+"); + Wire.endTransmission(); + Wire.beginTransmission(65); + Wire.send("2-"); + Wire.endTransmission(); + + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1."); + Wire.endTransmission(); + Wire.beginTransmission(65); + Wire.send("2."); + Wire.endTransmission(); + + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1-"); + Wire.endTransmission(); + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1."); + Wire.endTransmission(); + delay(2000); + +} + +void loop() { + /*if(Serial.available()>0) Wire.beginTransmission(65); + while(Serial.available()>0) Wire.send(Serial.read()); + Wire.endTransmission(); */ + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/BR2.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/BR2.pde new file mode 100644 index 0000000..0f4b0a6 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/BR2.pde @@ -0,0 +1,27 @@ +boolean DEBUG_LIGADO = true; + +#define IDLE 1 +#define SEGUIR_LINHA 2 +#define DEMONSTRACAO 3 +#define CAMPEONATO 4 + +int modo=DEMONSTRACAO; + +void setup(){ + Serial.begin(115200); + setupMotor(); + setupGarra(); + setupInit(); + +} + +void loop(){ + if(modo==IDLE) modoZero(); + if(modo==SEGUIR_LINHA) seguirLinha(); + if(modo==CAMPEONATO) campeonato(); + if(modo==DEMONSTRACAO) demo1(); +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/Campeonato.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/Campeonato.pde new file mode 100644 index 0000000..f6cc304 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/Campeonato.pde @@ -0,0 +1,3 @@ +void campeonato() { +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/Demo1.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/Demo1.pde new file mode 100644 index 0000000..db1fa0b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/Demo1.pde @@ -0,0 +1,6 @@ +void demo1() { + Serial.println(lerSensor(1)); + delay(500); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/Garra.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/Garra.pde new file mode 100644 index 0000000..d89e0d0 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/Garra.pde @@ -0,0 +1,5 @@ +#include + +void setupGarra() { +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/Motores.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/Motores.pde new file mode 100644 index 0000000..74c970b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/Motores.pde @@ -0,0 +1,95 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + + +int sentido=0; +void setupMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/SeguidorLinha.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/SeguidorLinha.pde new file mode 100644 index 0000000..fc49972 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/SeguidorLinha.pde @@ -0,0 +1,136 @@ +#include +#include + +#define NUM_SENSORS 5 // number of sensors used +#define TIMEOUT 2500 // waits for 2500 us for sensor outputs to go low +#define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2 +unsigned int last_proportional = 0; +long integral = 0; +boolean calibrado = false; + +// sensores 1 a 5 estao conectados nas portas digitais 5, 9, 2, 3 e 4, respectivamente +PololuQTRSensorsRC qtrrc((unsigned char[]) {5, 9, 2, 3, 4}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); +unsigned int sensorValues[NUM_SENSORS]; + + +void calibrarSensorDeLinha() { + int i; + // Auto-calibration: turn right and left while calibrating the sensors. + for (i = 0; i < 155; i++) { // make the calibration take about 10 seconds + if (i < 40 || i > 110) + setSpeeds(60, -60); + else + setSpeeds(-60, 60); + qtrrc.calibrate(); // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call) + } + setSpeeds(0, 0); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMinimumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMaximumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + //Serial.println(); + calibrado=true; +} + +void seguirLinha() { + if(!calibrado) calibrarSensorDeLinha(); + if(modo!=SEGUIR_LINHA) return; + unsigned int position = qtrrc.readLine(sensorValues); // Get the position of the line. + int proportional = (int)position - 2000;// The "proportional" term should be 0 when we are on the line. + int derivative = proportional - last_proportional; // Compute the derivative (change) of the position. + integral += proportional; // Compute the integral (sum) of the position. + last_proportional = proportional; // Remember the last position. + + // Compute the difference between the two motor power settings, + // m1 - m2. If this is a positive number the robot will turn + // to the right. If it is a negative number, the robot will + // turn to the left, and the magnitude of the number determines + // the sharpness of the turn. You can adjust the constants by which + // the proportional, integral, and derivative terms are multiplied to + // improve performance. + int power_difference = proportional/20 + integral/10000 + derivative*3/2; + + // Compute the actual motor settings. We never set either motor + // to a negative value. + const int maximum = 70; + if (power_difference > maximum) + power_difference = maximum; + if (power_difference < -maximum) + power_difference = -maximum; + // Serial.print("power diference: "); + // Serial.println(power_difference); + //setSpeeds(70,70); + if (power_difference < 0){ + setSpeeds(maximum + power_difference, maximum); + // Serial.print("motores: "); + // Serial.println(maximum + power_difference); + // Serial.print(" : "); + // Serial.println(maximum); + } + else{ + setSpeeds(maximum, maximum - power_difference); + // Serial.print("motores: "); + // Serial.print(maximum); + // Serial.print(" : "); + // Serial.println(maximum - power_difference); + // Serial.println(" "); + } + if(DEBUG_LIGADO) { + Serial.print("position: "); + Serial.println(position); + delay(10); + Serial.println("sensor values: "); + for(int x=0;x 0){ + digitalWrite(MOTOR1_control_A,HIGH); + digitalWrite(MOTOR1_control_B,LOW); + } + else { + digitalWrite(MOTOR1_control_A,LOW); + digitalWrite(MOTOR1_control_B,HIGH); + } + if (M2 > 0){ + digitalWrite(MOTOR2_control_A,HIGH); + digitalWrite(MOTOR2_control_B,LOW); + } + else { + digitalWrite(MOTOR2_control_A,LOW); + digitalWrite(MOTOR2_control_B,HIGH); + } + analogWrite(MOTOR1_PWM,abs(M1) ); + analogWrite(MOTOR2_PWM,abs(M2) ); +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/SensorDistancia.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/SensorDistancia.pde new file mode 100644 index 0000000..f9ea32d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/SensorDistancia.pde @@ -0,0 +1,17 @@ +int lerSensor(int numeroSensor) { + int val = analogRead(numeroSensor); + float volts = (5.0/1024.0) * val; + Serial.print("Valor puro: "); + Serial.println(val); + Serial.print("Volts: "); + Serial.println(volts); + + if(volts>1.3 && volts<1.5) return 10; + if(volts>1.5 && volts<1.65) return 5; + if(volts>1.65 && volts<2.05) return 3; + if(volts>2.05) return 0; +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/xlib.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/xlib.pde new file mode 100644 index 0000000..13955b2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2/xlib.pde @@ -0,0 +1,29 @@ + +long lastDebounce=0; +long debounceDelay=50; + +void setupInit() { + //attachInterrupt(0, mudarModo, LOW); +} + +void mudarModo() { + if(millis()-lastDebounce>debounceDelay) { + modoReset(); + modo = modo>5? 1 : modo + 1; + lastDebounce=millis(); + } +} +void modoReset() { + parar(); +} + +void modoZero() { + piscaLed13(1000); +} + +void piscaLed13(long tempo) { + digitalWrite(13, HIGH); + delay(tempo); + digitalWrite(13, LOW); + delay(tempo); +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/BR2_Dante1.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/BR2_Dante1.pde new file mode 100644 index 0000000..8ef7726 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/BR2_Dante1.pde @@ -0,0 +1,28 @@ +boolean DEBUG_LIGADO = true; + +#define IDLE 1 +#define SEGUIR_LINHA 2 +#define DEMONSTRACAO 3 +#define CAMPEONATO 4 + +int modo=IDLE; + +void setup(){ + Serial.begin(115200); + setupMotor(); + setupGarra(); + setupInit(); + +} + +void loop(){ + andarFrente( + /*if(modo==IDLE) modoZero(); + if(modo==SEGUIR_LINHA) seguirLinha(); + if(modo==CAMPEONATO) campeonato(); + if(modo==DEMONSTRACAO) demo1();*/ +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/Campeonato.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/Campeonato.pde new file mode 100644 index 0000000..f56c146 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/Campeonato.pde @@ -0,0 +1,4 @@ +void campeonato() { + +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/Demo1.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/Demo1.pde new file mode 100644 index 0000000..f2f3a60 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/Demo1.pde @@ -0,0 +1,4 @@ +void demo1() { + Serial.println(lerSensor(1)); + delay(500); +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/Garra.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/Garra.pde new file mode 100644 index 0000000..d89e0d0 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/Garra.pde @@ -0,0 +1,5 @@ +#include + +void setupGarra() { +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/Motores.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/Motores.pde new file mode 100644 index 0000000..d91aaca --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/Motores.pde @@ -0,0 +1,94 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + +int sentido=0; +void setupMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTras(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/SeguidorLinha.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/SeguidorLinha.pde new file mode 100644 index 0000000..fc49972 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/SeguidorLinha.pde @@ -0,0 +1,136 @@ +#include +#include + +#define NUM_SENSORS 5 // number of sensors used +#define TIMEOUT 2500 // waits for 2500 us for sensor outputs to go low +#define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2 +unsigned int last_proportional = 0; +long integral = 0; +boolean calibrado = false; + +// sensores 1 a 5 estao conectados nas portas digitais 5, 9, 2, 3 e 4, respectivamente +PololuQTRSensorsRC qtrrc((unsigned char[]) {5, 9, 2, 3, 4}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); +unsigned int sensorValues[NUM_SENSORS]; + + +void calibrarSensorDeLinha() { + int i; + // Auto-calibration: turn right and left while calibrating the sensors. + for (i = 0; i < 155; i++) { // make the calibration take about 10 seconds + if (i < 40 || i > 110) + setSpeeds(60, -60); + else + setSpeeds(-60, 60); + qtrrc.calibrate(); // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call) + } + setSpeeds(0, 0); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMinimumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMaximumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + //Serial.println(); + calibrado=true; +} + +void seguirLinha() { + if(!calibrado) calibrarSensorDeLinha(); + if(modo!=SEGUIR_LINHA) return; + unsigned int position = qtrrc.readLine(sensorValues); // Get the position of the line. + int proportional = (int)position - 2000;// The "proportional" term should be 0 when we are on the line. + int derivative = proportional - last_proportional; // Compute the derivative (change) of the position. + integral += proportional; // Compute the integral (sum) of the position. + last_proportional = proportional; // Remember the last position. + + // Compute the difference between the two motor power settings, + // m1 - m2. If this is a positive number the robot will turn + // to the right. If it is a negative number, the robot will + // turn to the left, and the magnitude of the number determines + // the sharpness of the turn. You can adjust the constants by which + // the proportional, integral, and derivative terms are multiplied to + // improve performance. + int power_difference = proportional/20 + integral/10000 + derivative*3/2; + + // Compute the actual motor settings. We never set either motor + // to a negative value. + const int maximum = 70; + if (power_difference > maximum) + power_difference = maximum; + if (power_difference < -maximum) + power_difference = -maximum; + // Serial.print("power diference: "); + // Serial.println(power_difference); + //setSpeeds(70,70); + if (power_difference < 0){ + setSpeeds(maximum + power_difference, maximum); + // Serial.print("motores: "); + // Serial.println(maximum + power_difference); + // Serial.print(" : "); + // Serial.println(maximum); + } + else{ + setSpeeds(maximum, maximum - power_difference); + // Serial.print("motores: "); + // Serial.print(maximum); + // Serial.print(" : "); + // Serial.println(maximum - power_difference); + // Serial.println(" "); + } + if(DEBUG_LIGADO) { + Serial.print("position: "); + Serial.println(position); + delay(10); + Serial.println("sensor values: "); + for(int x=0;x 0){ + digitalWrite(MOTOR1_control_A,HIGH); + digitalWrite(MOTOR1_control_B,LOW); + } + else { + digitalWrite(MOTOR1_control_A,LOW); + digitalWrite(MOTOR1_control_B,HIGH); + } + if (M2 > 0){ + digitalWrite(MOTOR2_control_A,HIGH); + digitalWrite(MOTOR2_control_B,LOW); + } + else { + digitalWrite(MOTOR2_control_A,LOW); + digitalWrite(MOTOR2_control_B,HIGH); + } + analogWrite(MOTOR1_PWM,abs(M1) ); + analogWrite(MOTOR2_PWM,abs(M2) ); +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/SensorDistancia.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/SensorDistancia.pde new file mode 100644 index 0000000..f9ea32d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/SensorDistancia.pde @@ -0,0 +1,17 @@ +int lerSensor(int numeroSensor) { + int val = analogRead(numeroSensor); + float volts = (5.0/1024.0) * val; + Serial.print("Valor puro: "); + Serial.println(val); + Serial.print("Volts: "); + Serial.println(volts); + + if(volts>1.3 && volts<1.5) return 10; + if(volts>1.5 && volts<1.65) return 5; + if(volts>1.65 && volts<2.05) return 3; + if(volts>2.05) return 0; +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/xlib.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/xlib.pde new file mode 100644 index 0000000..ad153d8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante1/xlib.pde @@ -0,0 +1,29 @@ + +long lastDebounce=0; +long debounceDelay=50; + +void setupInit() { + attachInterrupt(0, mudarModo, LOW); +} + +void mudarModo() { + if(millis()-lastDebounce>debounceDelay) { + modoReset(); + modo = modo>5? 1 : modo + 1; + lastDebounce=millis(); + } +} +void modoReset() { + parar(); +} + +void modoZero() { + piscaLed13(1000); +} + +void piscaLed13(long tempo) { + digitalWrite(13, HIGH); + delay(tempo); + digitalWrite(13, LOW); + delay(tempo); +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante_V0/BR2_Dante_V0.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante_V0/BR2_Dante_V0.pde new file mode 100644 index 0000000..ee97b8b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante_V0/BR2_Dante_V0.pde @@ -0,0 +1,101 @@ +#include +#include +#include + +SensorLinha sensorLinha((unsigned char[]){14, 15, 3, 4, 5}, 5); + +Motores motores; //default para motores Program-ME + +void setup(){ + Serial.begin(115200); + + Kernel.setup(INTERRUPTION); + Kernel.registerChangeModeListener(pararMotores); + + Kernel.registerMode(0, "Idle"); + Kernel.registerTask(0, padrao); + + Kernel.registerMode(1, "Testar Motores",testarMotores); + Kernel.registerTask(1, padrao); + + Kernel.registerMode(2, "Testar Seguidor",testarSeguidor); + Kernel.registerTask(2, padrao); + +} + +void loop(){ + Kernel.loop(); +} + +void testarSeguidor() { + //calibrar uma so vez + sensorLinha.calibrarSensores(); + //ler os sensores + sensorLinha.lerSensores(); + + Serial.print(sensorLinha.sensor[0]); + Serial.print(" "); + Serial.print(sensorLinha.sensor[1]); + Serial.print(" "); + Serial.print(sensorLinha.sensor[2]); + Serial.print(" "); + Serial.print(sensorLinha.sensor[3]); + Serial.print(" "); + Serial.print(sensorLinha.sensor[4]); + Serial.print(" "); + +} + +void pararMotores() { + motores.parar(); +} +void padrao() { + Serial.println("modo padrao"); + delay(500); +} +void padrao_setup() { +} +void testarMotores() { + Serial.println("iniciando teste motores"); + motores.andarParaTras(200); + delay(1000); + //Kernel.wait(2000); + //if(Kernel.abortMode()) return; + motores.andarParaFrente(200); + delay(1000); + + //Kernel.wait(2000); + //if(Kernel.abortMode()) return; + motores.girarSentidoHorario(200); + //Kernel.wait(2000); + //if(Kernel.abortMode()) return; + delay(1000); + + motores.girarSentidoAntiHorario(200); + //Kernel.wait(2000); + delay(1000); + + motores.parar(); + //motores.ajustarVelocidade(50,100); + +} +void imprimirSensores() { + sensorLinha.lerSensores(); + imprimirSensorLinha(); + Kernel.wait(250); + +} +int lerSensor(int numeroSensor) { + int val = analogRead(numeroSensor); + float volts = (5.0/1024.0) * val; + Serial.print("Valor puro: "); + Serial.println(val); + Serial.print("Volts: "); + Serial.println(volts); + + if(volts>1.3 && volts<1.5) return 10; + if(volts>1.5 && volts<1.65) return 5; + if(volts>1.65 && volts<2.05) return 3; + if(volts>2.05) return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante_V0/Pilha.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante_V0/Pilha.pde new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante_V0/SeguidorLinha.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante_V0/SeguidorLinha.pde new file mode 100644 index 0000000..58526c7 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_Dante_V0/SeguidorLinha.pde @@ -0,0 +1,44 @@ +void calibrarSensorDeLinha() { + sensorLinha.calibrarSensores(); + sensorLinha.lerSensores(); + imprimirSensorLinha(); +} + + + +void imprimirSensorLinha() { + /*lcd.imprimir(" ",0,1); + lcd.imprimir(sensorLinha.sensor[0],0,1); + lcd.imprimir(sensorLinha.sensor[1],6,1); + lcd.imprimir(sensorLinha.sensor[2],11,1); */ +} + +void seguirLinha() { + sensorLinha.lerSensores(); + imprimirSensorLinha(); + /*sensorLinha.imprimirPID();*/ + motores.andarParaFrente(40); + + if(sensorLinha.sensor[0]!=0) { + motores.ajustarVelocidade(20,40); + } + else if(sensorLinha.sensor[1]!=1000 ) { + } + else if(sensorLinha.sensor[2]!=0) { + motores.ajustarVelocidade(40,20); + } + +} + +int caso() { + if(sensorLinha.sensor[1]==1000 && sensorLinha.sensor[0]==0 && sensorLinha.sensor[2]==0) return 1; + else if(sensorLinha.sensor[1]==0 && sensorLinha.sensor[0]==0 && sensorLinha.sensor[2]==0) return 2; + else if(sensorLinha.sensor[1]==1000 && sensorLinha.sensor[0]==1000 && sensorLinha.sensor[2]==1000) return 3; + else if(sensorLinha.sensor[1]==0 && sensorLinha.sensor[0]==0 && sensorLinha.sensor[2]==1000) return 4; + else if(sensorLinha.sensor[1]==0 && sensorLinha.sensor[0]==1000 && sensorLinha.sensor[2]==1000) return 5; +} + +void seguirLinha_setup(){ + //lcd.imprimir("Modo Seguir Linha"); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_V1_0_Beta/BR2_V1_0_Beta.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_V1_0_Beta/BR2_V1_0_Beta.pde new file mode 100644 index 0000000..f399e64 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_V1_0_Beta/BR2_V1_0_Beta.pde @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include + +Motores motores; //default para motores Program-ME +SensorLinha sensorLinha((unsigned char[]){3, 4, 5}, 3); +LCD lcd; + +void setup(){ + Serial.begin(115200); + lcd.iniciar(); + + Kernel.setup(); + + Kernel.registerChangeModeListener(pararMotores); + + Kernel.registerMode(0, "Idle", padrao_setup); + Kernel.registerTask(0, padrao); + + Kernel.registerMode(1, "Calibrate Sensor"); + Kernel.registerTask(calibrarSensorDeLinha); + + Kernel.registerMode("Print Sensor"); + + Kernel.registerTask(imprimirSensorDeLinha); + +} + +void imprimirSensores() { + lcd.imprimir(caso()); + sensorLinha.lerSensores(); + imprimirSensorLinha(); + Kernel.wait(250); + +} +void loop(){ + Kernel.loop(); +} +void pararMotores() { + motores.parar(); +} +void padrao() { +} +void padrao_setup() { + lcd.imprimir("Modo Padrao - IDLE"); +} +void testeMotor() { + lcd.imprimir("Modo Teste Motor"); + lcd.imprimir("Para Tras",1,0); + motores.andarParaTras(100); + Kernel.wait(2000); + if(Kernel.abortMode()) return; + lcd.imprimir("Para Frente",1,0); + motores.andarParaFrente(100); + Kernel.wait(2000); + if(Kernel.abortMode()) return; + lcd.imprimir("Girando horario",1,0); + motores.girarSentidoHorario(100); + Kernel.wait(2000); + if(Kernel.abortMode()) return; + lcd.imprimir("Girando antihorario",1,0); + motores.girarSentidoAntiHorario(100); + Kernel.wait(2000); + motores.parar(); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_V1_0_Beta/SeguidorLinha.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_V1_0_Beta/SeguidorLinha.pde new file mode 100644 index 0000000..7e8b1d8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/BR2_V1_0_Beta/SeguidorLinha.pde @@ -0,0 +1,46 @@ +void calibrarSensorDeLinha() { + lcd.imprimir("Calibrando..."); + sensorLinha.calibrarSensores(); + lcd.imprimir("Calibrado OK"); + sensorLinha.lerSensores(); + imprimirSensorLinha(); +} + + + +void imprimirSensorLinha() { + lcd.imprimir(" ",0,1); + lcd.imprimir(sensorLinha.sensor[0],0,1); + lcd.imprimir(sensorLinha.sensor[1],6,1); + lcd.imprimir(sensorLinha.sensor[2],11,1); +} + +void seguirLinha() { + sensorLinha.lerSensores(); + imprimirSensorLinha(); + /*sensorLinha.imprimirPID();*/ + motores.andarParaFrente(40); + + if(sensorLinha.sensor[0]!=0) { + motores.ajustarVelocidade(20,40); + } + else if(sensorLinha.sensor[1]!=1000 ) { + } + else if(sensorLinha.sensor[2]!=0) { + motores.ajustarVelocidade(40,20); + } + +} + +int caso() { + if(sensorLinha.sensor[1]==1000 && sensorLinha.sensor[0]==0 && sensorLinha.sensor[2]==0) return 1; + else if(sensorLinha.sensor[1]==0 && sensorLinha.sensor[0]==0 && sensorLinha.sensor[2]==0) return 2; + else if(sensorLinha.sensor[1]==1000 && sensorLinha.sensor[0]==1000 && sensorLinha.sensor[2]==1000) return 3; + else if(sensorLinha.sensor[1]==0 && sensorLinha.sensor[0]==0 && sensorLinha.sensor[2]==1000) return 4; + else if(sensorLinha.sensor[1]==0 && sensorLinha.sensor[0]==1000 && sensorLinha.sensor[2]==1000) return 5; +} + +void seguirLinha_setup(){ + lcd.imprimir("Modo Seguir Linha"); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/Lab_Capitulo_3_Item_1_Micro_Chave.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/Lab_Capitulo_3_Item_1_Micro_Chave.pde new file mode 100644 index 0000000..be9dc48 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/Lab_Capitulo_3_Item_1_Micro_Chave.pde @@ -0,0 +1,127 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +//Incluir na solucao +#include + +int pino_leitura = P6; +int limpa = CHAVE; +int pino_escrita = P14; +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int contador = -1; +int ja_leu = 0; +// Instancia um objeto Debounce com tempo de debounce de 20 milisegundos +Debounce leitura_micro_chave = Debounce( 20 , pino_leitura); + + +void setup () { + int i; + pinMode(pino_leitura, INPUT); // configura o pino como entrada + pinMode(limpa, INPUT); + digitalWrite(pino_leitura, HIGH); // ativa o resistor () interno de pullup + + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + //pinMode(pino_escrita, OUTPUT); +} + +void bipa(){ +} + +void loop () { + int i; + int leitura; + + //problema + leitura = digitalRead(pino_leitura); + + //solucao + leitura_micro_chave.update ( ); + leitura = leitura_micro_chave.read (); + + + if (leitura == LOW && ja_leu == 0) { + contador++; + contador = contador%num_pins; + if (contador >= 0 ){ + digitalWrite(led[contador], HIGH); + } + ja_leu = 1; + } else { + if (leitura == HIGH){ + ja_leu = 0; + } + } + + if (digitalRead(limpa) == LOW){ + contador = -1; + for (i = 0; i < num_pins; i++){ + digitalWrite(led[i], LOW); + } + } + +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Debounce/Debounce.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Debounce/Debounce.cpp.o new file mode 100644 index 0000000..9889c84 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Debounce/Debounce.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp new file mode 100644 index 0000000..70dde1c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp @@ -0,0 +1,144 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +//Incluir na solucao +#include + +#include "WProgram.h" +void setup (); +void bipa(); +void loop (); +int pino_leitura = P6; +int limpa = CHAVE; +int pino_escrita = P14; +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int contador = -1; +int ja_leu = 0; +// Instancia um objeto Debounce com tempo de debounce de 20 milisegundos +Debounce leitura_micro_chave = Debounce( 20 , pino_leitura); + + +void setup () { + int i; + pinMode(pino_leitura, INPUT); // configura o pino como entrada + pinMode(limpa, INPUT); + digitalWrite(pino_leitura, HIGH); // ativa o resistor () interno de pullup + + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + //pinMode(pino_escrita, OUTPUT); +} + +void bipa(){ +} + +void loop () { + int i; + int leitura; + + //problema + leitura = digitalRead(pino_leitura); + + //solucao + leitura_micro_chave.update ( ); + leitura = leitura_micro_chave.read (); + + + if (leitura == LOW && ja_leu == 0) { + contador++; + contador = contador%num_pins; + if (contador >= 0 ){ + digitalWrite(led[contador], HIGH); + } + ja_leu = 1; + } else { + if (leitura == HIGH){ + ja_leu = 0; + } + } + + if (digitalRead(limpa) == LOW){ + contador = -1; + for (i = 0; i < num_pins; i++){ + digitalWrite(led[i], LOW); + } + } + +} + + + + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.elf new file mode 100644 index 0000000..dd45060 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.hex new file mode 100644 index 0000000..296ef3e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.hex @@ -0,0 +1,99 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C947E010C948A000C948A000C948A0013 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000DA0011241FBECFEFD8E0DEBFCDBFA5 +:1000D00011E0A0E0B1E0E2EFF5E002C005900D9282 +:1000E000A831B107D9F711E0A8E1B1E001C01D9234 +:1000F000AF32B107E1F710E0C4ECD0E004C02297C2 +:10010000FE010E94F302C23CD107C9F70E947701A9 +:100110000C94F7020C940000FC01808590E0089597 +:100120001F93CF93DF93EC0189850E947B02182FE8 +:1001300088858117E9F00E94C601288139814A81AA +:100140005B81621B730B840B950B2C813D814E816F +:100150005F81621773078407950750F00E94C601FC +:10016000688379838A839B83188721E030E002C00B +:1001700020E030E0C901DF91CF911F910895FF92F7 +:100180000F931F938C01F22EFC01448355836683E9 +:1001900077830E94C601F801608371838283938311 +:1001A0008F2D0E947B02F8018087F1861F910F91AD +:1001B000FF9008958CE191E044E150E060E070E050 +:1001C000209100010E94BF0008950F931F93CF93C9 +:1001D000DF93809100010E947B028CE191E00E94FC +:1001E00090008CE191E00E948C009C01009739F511 +:1001F00080911A0190911B01892B09F580911601BC +:1002000090911701609114017091150101960E945F +:10021000CA02FC01909317018093160197FD08C054 +:10022000EE0FFF1FEE5FFE4F808161E00E942E0205 +:1002300081E090E090931B0180931A0107C0213068 +:10024000310521F410921B0110921A0180911801BE +:100250000E947B02892BD1F48FEF9FEF90931701BF +:100260008093160102E011E0C0E0D0E008C0F80180 +:10027000808160E00E942E0221960E5F1F4F8091C8 +:10028000140190911501C817D9078CF3DF91CF9114 +:100290001F910F9108950F931F93CF93DF93809138 +:1002A000000160E00E940E028091180160E00E944F +:1002B0000E028091000161E00E942E0202E011E036 +:1002C000C0E0D0E008C0F801808161E00E940E0229 +:1002D00021960E5F1F4F8091140190911501C81750 +:1002E000D9078CF3DF91CF911F910F9108950E9450 +:1002F000D4010E944B010E94E500FDCF1F920F9296 +:100300000FB60F9211242F933F938F939F93AF9328 +:10031000BF9380912A0190912B01A0912C01B09163 +:100320002D0130912E010196A11DB11D232F2D5FAE +:100330002D3720F02D570196A11DB11D20932E01C0 +:1003400080932A0190932B01A0932C01B0932D014F +:100350008091260190912701A0912801B091290157 +:100360000196A11DB11D8093260190932701A093B2 +:100370002801B0932901BF91AF919F918F913F9137 +:100380002F910F900FBE0F901F9018958FB7F89474 +:1003900020912A0130912B0140912C0150912D0187 +:1003A0008FBFB901CA010895789484B5826084BD75 +:1003B00084B5816084BD85B5826085BD85B5816069 +:1003C00085BDEEE6F0E0808181608083E1E8F0E0C9 +:1003D000808182608083808181608083E0E8F0E0BA +:1003E000808181608083E1EBF0E0808184608083A4 +:1003F000E0EBF0E0808181608083EAE7F0E08081DB +:10040000846080838081826080838081816080833A +:100410008081806880831092C1000895282F30E089 +:10042000C90186569F4FFC0194912A573F4FF9010D +:100430008491882391F0E82FF0E0EE0FFF1FE85938 +:10044000FF4FA591B491662329F48C91909589234F +:100450008C9308958C91892B8C930895482F50E0AC +:10046000CA0182559F4FFC012491CA0186569F4FB5 +:10047000FC0194914A575F4FFA0134913323D1F133 +:10048000222331F1233021F4809180008F7705C041 +:10049000243031F4809180008F7D8093800018C0DB +:1004A000213019F484B58F7704C0223021F484B54B +:1004B0008F7D84BD0DC0263021F48091B0008F77F0 +:1004C00005C0273029F48091B0008F7D8093B00063 +:1004D000E32FF0E0EE0FFF1FEE58FF4FA591B49110 +:1004E000662329F48C91909589238C9308958C919F +:1004F000892B8C930895682F70E0CB0182559F4F14 +:10050000FC012491CB0186569F4FFC0144916A5710 +:100510007F4FFB019491992319F420E030E038C01B +:10052000222331F1233021F4809180008F7705C0A0 +:10053000243031F4809180008F7D8093800018C03A +:10054000213019F484B58F7704C0223021F484B5AA +:100550008F7D84BD0DC0263021F48091B0008F774F +:1005600005C0273029F48091B0008F7D8093B000C2 +:10057000892F90E0880F991F84589F4FFC01A59107 +:10058000B4918C9120E030E0842311F021E030E040 +:10059000C901089597FB092E07260AD077FD04D0DC +:1005A0000CD006D000201AF4709561957F4F089505 +:1005B000F6F7909581959F4F0895AA1BBB1B51E1BB +:1005C00007C0AA1FBB1FA617B70710F0A61BB70BC3 +:1005D000881F991F5A95A9F780959095BC01CD0168 +:1005E0000895EE0FFF1F0590F491E02D0994F89403 +:0205F000FFCF3B +:1005F20006000E00010002000300040005000800CE +:0806020007000D000900FFFFD5 +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.o new file mode 100644 index 0000000..91e9f6d Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/core.a new file mode 100644 index 0000000..1034ae1 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/Lab_Capitulo_3_Item_2_LDR.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/Lab_Capitulo_3_Item_2_LDR.pde new file mode 100644 index 0000000..a362e7d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/Lab_Capitulo_3_Item_2_LDR.pde @@ -0,0 +1,88 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = LED_9; + +void setup() { + int i; + pinMode(LDR, INPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura = 0; + + leitura = analogRead(LDR); // Le o valor analogico da entrada com o divisor resistivo LDR + + digitalWrite(LED, HIGH); // Liga o LED 1 + delay(leitura); // Espera o total de tempo da leitura analogica x 1ms + + digitalWrite(LED, LOW); // Desliga o LED + delay(leitura); // Espera o total de tempo da leitura analogica x 1ms + Serial.print("Valor do LDR: "); + Serial.println(leitura); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp new file mode 100644 index 0000000..10f3555 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp @@ -0,0 +1,104 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +#include "WProgram.h" +void setup(); +void loop(); +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = LED_9; + +void setup() { + int i; + pinMode(LDR, INPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura = 0; + + leitura = analogRead(LDR); // Le o valor analogico da entrada com o divisor resistivo LDR + + digitalWrite(LED, HIGH); // Liga o LED 1 + delay(leitura); // Espera o total de tempo da leitura analogica x 1ms + + digitalWrite(LED, LOW); // Desliga o LED + delay(leitura); // Espera o total de tempo da leitura analogica x 1ms + Serial.print("Valor do LDR: "); + Serial.println(leitura); +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.elf new file mode 100644 index 0000000..38bf49e Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.hex new file mode 100644 index 0000000..e31fd8b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.hex @@ -0,0 +1,176 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C94F1000C948A000C9428020C948A0001 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000710311241FBECFEFD8E0DEBFCDBF0B +:1000D00011E0A0E0B1E0E6EBFAE002C005900D927D +:1000E000A033B107D9F711E0A0E3B1E001C01D9240 +:1000F000A03DB107E1F710E0C4ECD0E004C02297C6 +:10010000FE010E945505C23CD107C9F70E94EA00D2 +:100110000C9459050C940000CF92DF92EF92FF925D +:100120000F931F9385E00E949D018C018091230114 +:1001300061E00E94DB016801EE24D7FCE094FE2C14 +:10014000C701B6010E9439018091230160E00E943D +:10015000DB01C701B6010E9439018DEBE82E81E079 +:10016000F82EC70160E071E00E94E203C701B80108 +:100170000E94C0041F910F91FF90EF90DF90CF90ED +:1001800008950F931F93CF93DF9385E060E00E9463 +:10019000BB010FE011E0C0E0D0E008C0F8018081B1 +:1001A00061E00E94BB0121960E5F1F4F80912101EB +:1001B00090912201C817D9078CF38DEB91E040E8AC +:1001C00055E260E070E00E946502DF91CF911F91DF +:1001D0000F9108950E9463010E94C1000E948C004B +:1001E000FDCF1F920F920FB60F9211242F933F93C2 +:1001F0008F939F93AF93BF9380913401909135017A +:10020000A0913601B0913701309138010196A11DBE +:10021000B11D232F2D5F2D3720F02D570196A11DE5 +:10022000B11D209338018093340190933501A09340 +:100230003601B09337018091300190913101A09146 +:100240003201B09133010196A11DB11D809330019F +:1002500090933101A0933201B0933301BF91AF91DC +:100260009F918F913F912F910F900FBE0F901F90F4 +:100270001895EF92FF920F931F937B018C018FB71C +:10028000F89440913401509135016091360170919C +:1002900037018FBF2FB7F8948091340190913501C9 +:1002A000A0913601B09137012FBF841B950BA60B8F +:1002B000B70BE816F9060A071B0760F71F910F91A5 +:1002C000FF90EF900895789484B5826084BD84B5E2 +:1002D000816084BD85B5826085BD85B5816085BD41 +:1002E000EEE6F0E0808181608083E1E8F0E08081EB +:1002F00082608083808181608083E0E8F0E080819B +:1003000081608083E1EBF0E0808184608083E0EBBA +:10031000F0E0808181608083EAE7F0E080818460A2 +:1003200080838081826080838081816080838081FE +:10033000806880831092C10008958F70909125018C +:100340009295990F990F907C982B90937C008091B7 +:100350007A00806480937A0080917A0086FDFCCFD9 +:100360002091780040917900942F80E030E0282B94 +:10037000392BC9010895282F30E0C90186569F4FB7 +:10038000FC0194912A573F4FF9018491882391F001 +:10039000E82FF0E0EE0FFF1FE859FF4FA591B49151 +:1003A000662329F48C91909589238C9308958C91E0 +:1003B000892B8C930895482F50E0CA0182559F4F96 +:1003C000FC012491CA0186569F4FFC0194914A5723 +:1003D0005F4FFA0134913323D1F1222331F12330DD +:1003E00021F4809180008F7705C0243031F4809112 +:1003F00080008F7D8093800018C0213019F484B56F +:100400008F7704C0223021F484B58F7D84BD0DC068 +:10041000263021F48091B0008F7705C0273029F471 +:100420008091B0008F7D8093B000E32FF0E0EE0F5D +:10043000FF1FEE58FF4FA591B491662329F48C91CC +:10044000909589238C9308958C91892B8C93089592 +:100450001F920F920FB60F9211242F933F934F9339 +:100460005F936F937F938F939F93AF93BF93EF931C +:10047000FF934091C600E091B901F091BA01CF011C +:10048000019660E870E00E94EF049C018091BB013E +:100490009091BC012817390739F0E75CFE4F408383 +:1004A0003093BA012093B901FF91EF91BF91AF91C1 +:1004B0009F918F917F916F915F914F913F912F917C +:1004C0000F900FBE0F901F9018955F926F927F92C2 +:1004D0008F929F92AF92BF92CF92DF92EF92FF9254 +:1004E0000F931F93CF93DF93EC013A014B014134FB +:1004F00082E458078FE0680780E078070CF07FC03F +:1005000060E874E88EE190E0A40193010E94240564 +:100510002150304040405040CA01B90122E030E053 +:1005200040E050E00E94240559016A01A6019501AE +:10053000209530954095509594E0220F331F441F2D +:10054000551F9A95D1F760E074E284EF90E00E9425 +:100550002405CA01B9012FEF30E040E050E00E94CD +:10056000D004A40193010E942405C90181509F4F2A +:10057000181619061CF4522E5A9403C0552453948D +:10058000521A60E079E08DE390E0A40193010E94AB +:1005900024052150304040405040CA01B90122E0BA +:1005A00030E040E050E00E942405209530954095D1 +:1005B000509583E0220F331F441F551F8A95D1F7B2 +:1005C00060E074E284EF90E00E942405CA01B90162 +:1005D0002FEF30E040E050E00E94D004A4019301EE +:1005E0000E942405C90181509F4F181619061CF45A +:1005F000822F815002C081E0821B851500F5E885BD +:10060000F98581E090E00A8802C0880F991F0A945A +:10061000E2F7808360E079E08DE390E0A40193014C +:100620000E9424052150304040405040CA01B90189 +:1006300022E030E040E050E00E94240504C0E8855C +:10064000F98510829501EC81FD813083EE81FF8177 +:100650002083EA85FB85208141E050E0CA010E84B9 +:1006600002C0880F991F0A94E2F7282B2083EA859D +:10067000FB852081CA010F8402C0880F991F0A944C +:10068000E2F7282B2083EA85FB858081088802C059 +:10069000440F551F0A94E2F7842B8083DF91CF919A +:1006A0001F910F91FF90EF90DF90CF90BF90AF9090 +:1006B0009F908F907F906F905F900895FC01A08530 +:1006C000B18521898C9190E0022E02C09595879585 +:1006D0000A94E2F780FFF6CF0484F585E02D60836D +:1006E00008958AE291E09093BE018093BD0189E371 +:1006F00091E09093C0018093BF0185EC90E09093CE +:10070000C2018093C10184EC90E09093C401809376 +:10071000C30180EC90E09093C6018093C50181EC09 +:1007200090E09093C8018093C70186EC90E090938D +:10073000CA018093C90184E08093CB0183E0809358 +:10074000CC0187E08093CD0185E08093CE0181E0EC +:100750008093CF0108950F931F93CF93DF938C0164 +:10076000EB0109C02196D801ED91FC910190F08137 +:10077000E02DC801099568816623A1F7DF91CF912B +:100780001F910F910895EF92FF920F931F93CF93B4 +:10079000DF938C017B01EA010CC0D7016D917D01D3 +:1007A000D801ED91FC910190F081E02DC8010995EF +:1007B0002197209791F7DF91CF911F910F91FF9093 +:1007C000EF900895DC01ED91FC910280F381E02D22 +:1007D000099508950F931F938C01DC01ED91FC9115 +:1007E0000190F081E02D6DE00995D801ED91FC912B +:1007F0000190F081E02DC8016AE009951F910F91E9 +:1008000008952F923F924F925F926F927F928F92B4 +:100810009F92AF92BF92CF92DF92EF92FF920F938F +:100820001F93DF93CF93CDB7DEB7A0970FB6F894A1 +:10083000DEBF0FBECDBF1C016A017B014115510512 +:100840006105710549F4DC01ED91FC910190F081A5 +:10085000E02D60E3099554C0882499245401422E68 +:1008600055246624772401E010E00C0F1D1F080DAD +:10087000191DC701B601A30192010E940205F801EA +:1008800060830894811C911CA11CB11CC701B60196 +:10089000A30192010E940205C901DA016C017D01E8 +:1008A000C114D104E104F104F1F681E0E82EF12C49 +:1008B000EC0EFD1EE80CF91C3E010894611C711C35 +:1008C000D501C4010197A109B1096C01C818D90863 +:1008D00014C0F601EE0DFF1D60816A3010F4605DFA +:1008E00001C0695CD101ED91FC910190F081E02D96 +:1008F000C10109950894E108F1086E147F0449F7D5 +:10090000A0960FB6F894DEBF0FBECDBFCF91DF919A +:100910001F910F91FF90EF90DF90CF90BF90AF901D +:100920009F908F907F906F905F904F903F902F900F +:100930000895EF92FF920F931F93CF93DF93EC01F3 +:100940007A018B0177FF0FC0E881F9810190F08176 +:10095000E02D6DE2099510950095F094E094E11C6E +:10096000F11C011D111DCE01B801A7012AE00E9452 +:100970000104DF91CF911F910F91FF90EF900895A7 +:100980000F931F938C01AB01662757FD6095762F5F +:100990000E949904C8010E94EA031F910F910895D3 +:1009A000629FD001739FF001829FE00DF11D649F53 +:1009B000E00DF11D929FF00D839FF00D749FF00DDF +:1009C000659FF00D9927729FB00DE11DF91F639F80 +:1009D000B00DE11DF91FBD01CF011124089597FB52 +:1009E000092E07260AD077FD04D049D006D0002072 +:1009F0001AF4709561957F4F0895F6F7909581955B +:100A00009F4F0895A1E21A2EAA1BBB1BFD010DC02A +:100A1000AA1FBB1FEE1FFF1FA217B307E407F507AE +:100A200020F0A21BB30BE40BF50B661F771F881F8A +:100A3000991F1A9469F760957095809590959B0120 +:100A4000AC01BD01CF01089597FB092E05260ED0FC +:100A500057FD04D0D7DF0AD0001C38F450954095DC +:100A6000309521953F4F4F4F5F4F0895F6F7909582 +:100A70008095709561957F4F8F4F9F4F0895AA1B6A +:100A8000BB1B51E107C0AA1FBB1FA617B70710F079 +:100A9000A61BB70B881F991F5A95A9F780959095AB +:100AA000BC01CD010895EE0FFF1F0590F491E02DDC +:060AB0000994F894FFCF49 +:100AB60056616C6F7220646F204C44523A20000ECF +:100AC6000001000200030004000500080007000DF5 +:100AD6000009000D0001000000005E03AB03C30324 +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.o new file mode 100644 index 0000000..9ca45d6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/core.a new file mode 100644 index 0000000..d97a584 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/Lab_Capitulo_3_Item_3_FotoDiodo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/Lab_Capitulo_3_Item_3_FotoDiodo.pde new file mode 100644 index 0000000..09d0367 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/Lab_Capitulo_3_Item_3_FotoDiodo.pde @@ -0,0 +1,93 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = AP4; + +void setup() { + int i; + pinMode(A3, INPUT); + pinMode(LED, OUTPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura_analogica = 0; + int leitura_digital = 0; + + Serial.println(""); + digitalWrite(LED, LOW); // Desliga o LED + delay (100); + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led apagado: "); + Serial.println(leitura_analogica); + digitalWrite(LED, HIGH); // Liga o LED 1 + delay(100); // Espera + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led aceso: "); + Serial.println(leitura_analogica); + delay (2000); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp new file mode 100644 index 0000000..2ef516d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp @@ -0,0 +1,109 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +#include "WProgram.h" +void setup(); +void loop(); +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = AP4; + +void setup() { + int i; + pinMode(A3, INPUT); + pinMode(LED, OUTPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura_analogica = 0; + int leitura_digital = 0; + + Serial.println(""); + digitalWrite(LED, LOW); // Desliga o LED + delay (100); + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led apagado: "); + Serial.println(leitura_analogica); + digitalWrite(LED, HIGH); // Liga o LED 1 + delay(100); // Espera + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led aceso: "); + Serial.println(leitura_analogica); + delay (2000); +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.elf new file mode 100644 index 0000000..0c7b91a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.hex new file mode 100644 index 0000000..bd2ecd0 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.hex @@ -0,0 +1,186 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C9407010C948A000C943E020C948A00D4 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000870311241FBECFEFD8E0DEBFCDBFF5 +:1000D00011E0A0E0B1E0E8EFFAE002C005900D9277 +:1000E000A438B107D9F712E0A4E8B1E001C01D922D +:1000F000A432B107E1F710E0C4ECD0E004C02297CD +:10010000FE010E947605C23CD107C9F70E9400019A +:100110000C947A050C940000EF92FF920F931F93BA +:1001200001E112E0C80160E071E00E9417048091D3 +:10013000770160E00E94F10164E670E080E090E009 +:100140000E944F0183E00E94B3017C01C80161E07D +:1001500071E00E94F803C801B7010E94E104809198 +:10016000770161E00E94F10164E670E080E090E0D8 +:100170000E944F0183E00E94B3017C01C80163E348 +:1001800071E00E94F803C801B7010E94E10460ED2C +:1001900077E080E090E00E944F011F910F91FF9067 +:1001A000EF9008950F931F93CF93DF9383E060E068 +:1001B0000E94D1018091770161E00E94D10103E6A4 +:1001C00011E0C0E0D0E008C0F801808161E00E9449 +:1001D000D10121960E5F1F4F80917501909176019C +:1001E000C817D9078CF381E192E040E855E260E05E +:1001F00070E00E947B02DF91CF911F910F910895D3 +:100200000E9479010E94D2000E948C00FDCF1F92B3 +:100210000F920FB60F9211242F933F938F939F93BA +:10022000AF93BF938091880190918901A0918A0139 +:10023000B0918B0130918C010196A11DB11D232F2E +:100240002D5F2D3720F02D570196A11DB11D209354 +:100250008C018093880190938901A0938A01B093C7 +:100260008B018091840190918501A0918601B091CC +:1002700087010196A11DB11D809384019093850192 +:10028000A0938601B0938701BF91AF919F918F9109 +:100290003F912F910F900FBE0F901F901895EF92E6 +:1002A000FF920F931F937B018C018FB7F8944091BD +:1002B00088015091890160918A0170918B018FBFF3 +:1002C0002FB7F8948091880190918901A0918A01BB +:1002D000B0918B012FBF841B950BA60BB70BE816B3 +:1002E000F9060A071B0760F71F910F91FF90EF9027 +:1002F0000895789484B5826084BD84B5816084BD9E +:1003000085B5826085BD85B5816085BDEEE6F0E08E +:10031000808181608083E1E8F0E080818260808379 +:10032000808181608083E0E8F0E08081816080836B +:10033000E1EBF0E0808184608083E0EBF0E080819D +:1003400081608083EAE7F0E080818460808380813F +:1003500082608083808181608083808180688083E7 +:100360001092C10008958F70909179019295990F24 +:10037000990F907C982B90937C0080917A008064F8 +:1003800080937A0080917A0086FDFCCF20917800DE +:1003900040917900942F80E030E0282B392BC9015F +:1003A0000895282F30E0C90186569F4FFC01949193 +:1003B0002A573F4FF9018491882391F0E82FF0E00C +:1003C000EE0FFF1FE859FF4FA591B491662329F462 +:1003D0008C91909589238C9308958C91892B8C9383 +:1003E0000895482F50E0CA0182559F4FFC01249187 +:1003F000CA0186569F4FFC0194914A575F4FFA01FC +:1004000034913323D1F1222331F1233021F480912F +:1004100080008F7705C0243031F4809180008F7D7B +:100420008093800018C0213019F484B58F7704C000 +:10043000223021F484B58F7D84BD0DC0263021F497 +:100440008091B0008F7705C0273029F48091B000EB +:100450008F7D8093B000E32FF0E0EE0FFF1FEE588A +:10046000FF4FA591B491662329F48C91909589232F +:100470008C9308958C91892B8C9308951F920F92E1 +:100480000FB60F9211242F933F934F935F936F9367 +:100490007F938F939F93AF93BF93EF93FF9340917D +:1004A000C600E0910D02F0910E02CF01019660E8C6 +:1004B00070E00E9410059C0180910F029091100243 +:1004C0002817390739F0E357FE4F408330930E0267 +:1004D00020930D02FF91EF91BF91AF919F918F916A +:1004E0007F916F915F914F913F912F910F900FBE30 +:1004F0000F901F9018955F926F927F928F929F92AC +:10050000AF92BF92CF92DF92EF92FF920F931F9321 +:10051000CF93DF93EC013A014B01413482E4580759 +:100520008FE0680780E078070CF07FC060E874E82F +:100530008EE190E0A40193010E94450521503040D6 +:1005400040405040CA01B90122E030E040E050E0B4 +:100550000E94450559016A01A60195012095309533 +:100560004095509594E0220F331F441F551F9A95D4 +:10057000D1F760E074E284EF90E00E944505CA0183 +:10058000B9012FEF30E040E050E00E94F104A401F7 +:1005900093010E944505C90181509F4F1816190605 +:1005A0001CF4522E5A9403C055245394521A60E0FE +:1005B00079E08DE390E0A40193010E94450521506C +:1005C000304040405040CA01B90122E030E040E0F4 +:1005D00050E00E944505209530954095509583E068 +:1005E000220F331F441F551F8A95D1F760E074E234 +:1005F00084EF90E00E944505CA01B9012FEF30E079 +:1006000040E050E00E94F104A40193010E944505DE +:10061000C90181509F4F181619061CF4822F815072 +:1006200002C081E0821B851500F5E885F98581E02F +:1006300090E00A8802C0880F991F0A94E2F780832D +:1006400060E079E08DE390E0A40193010E9445050C +:100650002150304040405040CA01B90122E030E012 +:1006600040E050E00E94450504C0E885F98510820D +:100670009501EC81FD813083EE81FF812083EA8545 +:10068000FB85208141E050E0CA010E8402C0880F42 +:10069000991F0A94E2F7282B2083EA85FB852081A5 +:1006A000CA010F8402C0880F991F0A94E2F7282B11 +:1006B0002083EA85FB858081088802C0440F551F8E +:1006C0000A94E2F7842B8083DF91CF911F910F91E1 +:1006D000FF90EF90DF90CF90BF90AF909F908F9062 +:1006E0007F906F905F900895FC01A085B18521896E +:1006F0008C9190E0022E02C0959587950A94E2F7BE +:1007000080FFF6CF0484F585E02D608308958EE7A1 +:1007100091E090931202809311028DE891E0909302 +:1007200014028093130285EC90E09093160280935C +:10073000150284EC90E0909318028093170280ECED +:1007400090E090931A028093190281EC90E09093CC +:100750001C0280931B0286EC90E090931E02809313 +:100760001D0284E080931F0283E08093200287E0D3 +:100770008093210285E08093220281E0809323020E +:1007800008950F931F93CF93DF938C01EB0109C062 +:100790002196D801ED91FC910190F081E02DC801E6 +:1007A000099568816623A1F7DF91CF911F910F9181 +:1007B0000895EF92FF920F931F93CF93DF938C01D5 +:1007C0007B01EA010CC0D7016D917D01D801ED914B +:1007D000FC910190F081E02DC801099521972097A7 +:1007E00091F7DF91CF911F910F91FF90EF900895B6 +:1007F000DC01ED91FC910280F381E02D09950895D3 +:100800000F931F938C01DC01ED91FC910190F0811D +:10081000E02D6DE00995D801ED91FC910190F081FA +:10082000E02DC8016AE009951F910F9108950F937B +:100830001F938C010E94F803C8010E9400041F91BD +:100840000F9108952F923F924F925F926F927F92F5 +:100850008F929F92AF92BF92CF92DF92EF92FF92D0 +:100860000F931F93DF93CF93CDB7DEB7A0970FB64B +:10087000F894DEBF0FBECDBF1C016A017B0141159C +:1008800051056105710549F4DC01ED91FC91019080 +:10089000F081E02D60E3099554C088249924540127 +:1008A000422E55246624772401E010E00C0F1D1F12 +:1008B000080D191DC701B601A30192010E9423056D +:1008C000F80160830894811C911CA11CB11CC70114 +:1008D000B601A30192010E942305C901DA016C014E +:1008E0007D01C114D104E104F104F1F681E0E82EA8 +:1008F000F12CEC0EFD1EE80CF91C3E010894611C65 +:10090000711CD501C4010197A109B1096C01C81876 +:10091000D90814C0F601EE0DFF1D60816A3010F495 +:10092000605D01C0695CD101ED91FC910190F081A5 +:10093000E02DC10109950894E108F1086E147F04C7 +:1009400049F7A0960FB6F894DEBF0FBECDBFCF918A +:10095000DF911F910F91FF90EF90DF90CF90BF90AC +:10096000AF909F908F907F906F905F904F903F904F +:100970002F900895EF92FF920F931F93CF93DF93E1 +:10098000EC017A018B0177FF0FC0E881F9810190BA +:10099000F081E02D6DE2099510950095F094E094BA +:1009A000E11CF11C011D111DCE01B801A7012AE0B7 +:1009B0000E942204DF91CF911F910F91FF90EF9041 +:1009C00008950F931F938C01AB01662757FD609527 +:1009D000762F0E94BA04C8010E9400041F910F9153 +:1009E0000895629FD001739FF001829FE00DF11D79 +:1009F000649FE00DF11D929FF00D839FF00D749F99 +:100A0000F00D659FF00D9927729FB00DE11DF91F44 +:100A1000639FB00DE11DF91FBD01CF0111240895A1 +:100A200097FB092E07260AD077FD04D049D006D0BF +:100A300000201AF4709561957F4F0895F6F7909510 +:100A400081959F4F0895A1E21A2EAA1BBB1BFD01A1 +:100A50000DC0AA1FBB1FEE1FFF1FA217B307E4079D +:100A6000F50720F0A21BB30BE40BF50B661F771FF5 +:100A7000881F991F1A9469F76095709580959095D5 +:100A80009B01AC01BD01CF01089597FB092E0526FE +:100A90000ED057FD04D0D7DF0AD0001C38F4509593 +:100AA0004095309521953F4F4F4F5F4F0895F6F792 +:100AB00090958095709561957F4F8F4F9F4F0895CA +:100AC000AA1BBB1B51E107C0AA1FBB1FA617B70774 +:100AD00010F0A61BB70B881F991F5A95A9F7809590 +:100AE0009095BC01CD010895EE0FFF1F0590F49184 +:080AF000E02D0994F894FFCFFA +:100AF8000056616C6F7220416E616C6F6769636F3D +:100B080020646F20466F746F5265636570746F72EE +:100B180020636F6D206C6564206170616761646F2C +:100B28003A200056616C6F7220416E616C6F676984 +:100B3800636F20646F20466F746F526563657074CD +:100B48006F7220636F6D206C656420616365736FDD +:100B58003A20000E0001000200030004000500080E +:100B68000007000D000900120001000000007403D6 +:040B7800C103D903D9 +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.o new file mode 100644 index 0000000..749c140 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/core.a new file mode 100644 index 0000000..96ebf14 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.pde new file mode 100644 index 0000000..09d0367 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.pde @@ -0,0 +1,93 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = AP4; + +void setup() { + int i; + pinMode(A3, INPUT); + pinMode(LED, OUTPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura_analogica = 0; + int leitura_digital = 0; + + Serial.println(""); + digitalWrite(LED, LOW); // Desliga o LED + delay (100); + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led apagado: "); + Serial.println(leitura_analogica); + digitalWrite(LED, HIGH); // Liga o LED 1 + delay(100); // Espera + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led aceso: "); + Serial.println(leitura_analogica); + delay (2000); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp new file mode 100644 index 0000000..2ef516d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp @@ -0,0 +1,109 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +#include "WProgram.h" +void setup(); +void loop(); +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = AP4; + +void setup() { + int i; + pinMode(A3, INPUT); + pinMode(LED, OUTPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura_analogica = 0; + int leitura_digital = 0; + + Serial.println(""); + digitalWrite(LED, LOW); // Desliga o LED + delay (100); + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led apagado: "); + Serial.println(leitura_analogica); + digitalWrite(LED, HIGH); // Liga o LED 1 + delay(100); // Espera + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led aceso: "); + Serial.println(leitura_analogica); + delay (2000); +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.elf new file mode 100644 index 0000000..e1ea89f Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.hex new file mode 100644 index 0000000..bd2ecd0 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.hex @@ -0,0 +1,186 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C9407010C948A000C943E020C948A00D4 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000870311241FBECFEFD8E0DEBFCDBFF5 +:1000D00011E0A0E0B1E0E8EFFAE002C005900D9277 +:1000E000A438B107D9F712E0A4E8B1E001C01D922D +:1000F000A432B107E1F710E0C4ECD0E004C02297CD +:10010000FE010E947605C23CD107C9F70E9400019A +:100110000C947A050C940000EF92FF920F931F93BA +:1001200001E112E0C80160E071E00E9417048091D3 +:10013000770160E00E94F10164E670E080E090E009 +:100140000E944F0183E00E94B3017C01C80161E07D +:1001500071E00E94F803C801B7010E94E104809198 +:10016000770161E00E94F10164E670E080E090E0D8 +:100170000E944F0183E00E94B3017C01C80163E348 +:1001800071E00E94F803C801B7010E94E10460ED2C +:1001900077E080E090E00E944F011F910F91FF9067 +:1001A000EF9008950F931F93CF93DF9383E060E068 +:1001B0000E94D1018091770161E00E94D10103E6A4 +:1001C00011E0C0E0D0E008C0F801808161E00E9449 +:1001D000D10121960E5F1F4F80917501909176019C +:1001E000C817D9078CF381E192E040E855E260E05E +:1001F00070E00E947B02DF91CF911F910F910895D3 +:100200000E9479010E94D2000E948C00FDCF1F92B3 +:100210000F920FB60F9211242F933F938F939F93BA +:10022000AF93BF938091880190918901A0918A0139 +:10023000B0918B0130918C010196A11DB11D232F2E +:100240002D5F2D3720F02D570196A11DB11D209354 +:100250008C018093880190938901A0938A01B093C7 +:100260008B018091840190918501A0918601B091CC +:1002700087010196A11DB11D809384019093850192 +:10028000A0938601B0938701BF91AF919F918F9109 +:100290003F912F910F900FBE0F901F901895EF92E6 +:1002A000FF920F931F937B018C018FB7F8944091BD +:1002B00088015091890160918A0170918B018FBFF3 +:1002C0002FB7F8948091880190918901A0918A01BB +:1002D000B0918B012FBF841B950BA60BB70BE816B3 +:1002E000F9060A071B0760F71F910F91FF90EF9027 +:1002F0000895789484B5826084BD84B5816084BD9E +:1003000085B5826085BD85B5816085BDEEE6F0E08E +:10031000808181608083E1E8F0E080818260808379 +:10032000808181608083E0E8F0E08081816080836B +:10033000E1EBF0E0808184608083E0EBF0E080819D +:1003400081608083EAE7F0E080818460808380813F +:1003500082608083808181608083808180688083E7 +:100360001092C10008958F70909179019295990F24 +:10037000990F907C982B90937C0080917A008064F8 +:1003800080937A0080917A0086FDFCCF20917800DE +:1003900040917900942F80E030E0282B392BC9015F +:1003A0000895282F30E0C90186569F4FFC01949193 +:1003B0002A573F4FF9018491882391F0E82FF0E00C +:1003C000EE0FFF1FE859FF4FA591B491662329F462 +:1003D0008C91909589238C9308958C91892B8C9383 +:1003E0000895482F50E0CA0182559F4FFC01249187 +:1003F000CA0186569F4FFC0194914A575F4FFA01FC +:1004000034913323D1F1222331F1233021F480912F +:1004100080008F7705C0243031F4809180008F7D7B +:100420008093800018C0213019F484B58F7704C000 +:10043000223021F484B58F7D84BD0DC0263021F497 +:100440008091B0008F7705C0273029F48091B000EB +:100450008F7D8093B000E32FF0E0EE0FFF1FEE588A +:10046000FF4FA591B491662329F48C91909589232F +:100470008C9308958C91892B8C9308951F920F92E1 +:100480000FB60F9211242F933F934F935F936F9367 +:100490007F938F939F93AF93BF93EF93FF9340917D +:1004A000C600E0910D02F0910E02CF01019660E8C6 +:1004B00070E00E9410059C0180910F029091100243 +:1004C0002817390739F0E357FE4F408330930E0267 +:1004D00020930D02FF91EF91BF91AF919F918F916A +:1004E0007F916F915F914F913F912F910F900FBE30 +:1004F0000F901F9018955F926F927F928F929F92AC +:10050000AF92BF92CF92DF92EF92FF920F931F9321 +:10051000CF93DF93EC013A014B01413482E4580759 +:100520008FE0680780E078070CF07FC060E874E82F +:100530008EE190E0A40193010E94450521503040D6 +:1005400040405040CA01B90122E030E040E050E0B4 +:100550000E94450559016A01A60195012095309533 +:100560004095509594E0220F331F441F551F9A95D4 +:10057000D1F760E074E284EF90E00E944505CA0183 +:10058000B9012FEF30E040E050E00E94F104A401F7 +:1005900093010E944505C90181509F4F1816190605 +:1005A0001CF4522E5A9403C055245394521A60E0FE +:1005B00079E08DE390E0A40193010E94450521506C +:1005C000304040405040CA01B90122E030E040E0F4 +:1005D00050E00E944505209530954095509583E068 +:1005E000220F331F441F551F8A95D1F760E074E234 +:1005F00084EF90E00E944505CA01B9012FEF30E079 +:1006000040E050E00E94F104A40193010E944505DE +:10061000C90181509F4F181619061CF4822F815072 +:1006200002C081E0821B851500F5E885F98581E02F +:1006300090E00A8802C0880F991F0A94E2F780832D +:1006400060E079E08DE390E0A40193010E9445050C +:100650002150304040405040CA01B90122E030E012 +:1006600040E050E00E94450504C0E885F98510820D +:100670009501EC81FD813083EE81FF812083EA8545 +:10068000FB85208141E050E0CA010E8402C0880F42 +:10069000991F0A94E2F7282B2083EA85FB852081A5 +:1006A000CA010F8402C0880F991F0A94E2F7282B11 +:1006B0002083EA85FB858081088802C0440F551F8E +:1006C0000A94E2F7842B8083DF91CF911F910F91E1 +:1006D000FF90EF90DF90CF90BF90AF909F908F9062 +:1006E0007F906F905F900895FC01A085B18521896E +:1006F0008C9190E0022E02C0959587950A94E2F7BE +:1007000080FFF6CF0484F585E02D608308958EE7A1 +:1007100091E090931202809311028DE891E0909302 +:1007200014028093130285EC90E09093160280935C +:10073000150284EC90E0909318028093170280ECED +:1007400090E090931A028093190281EC90E09093CC +:100750001C0280931B0286EC90E090931E02809313 +:100760001D0284E080931F0283E08093200287E0D3 +:100770008093210285E08093220281E0809323020E +:1007800008950F931F93CF93DF938C01EB0109C062 +:100790002196D801ED91FC910190F081E02DC801E6 +:1007A000099568816623A1F7DF91CF911F910F9181 +:1007B0000895EF92FF920F931F93CF93DF938C01D5 +:1007C0007B01EA010CC0D7016D917D01D801ED914B +:1007D000FC910190F081E02DC801099521972097A7 +:1007E00091F7DF91CF911F910F91FF90EF900895B6 +:1007F000DC01ED91FC910280F381E02D09950895D3 +:100800000F931F938C01DC01ED91FC910190F0811D +:10081000E02D6DE00995D801ED91FC910190F081FA +:10082000E02DC8016AE009951F910F9108950F937B +:100830001F938C010E94F803C8010E9400041F91BD +:100840000F9108952F923F924F925F926F927F92F5 +:100850008F929F92AF92BF92CF92DF92EF92FF92D0 +:100860000F931F93DF93CF93CDB7DEB7A0970FB64B +:10087000F894DEBF0FBECDBF1C016A017B0141159C +:1008800051056105710549F4DC01ED91FC91019080 +:10089000F081E02D60E3099554C088249924540127 +:1008A000422E55246624772401E010E00C0F1D1F12 +:1008B000080D191DC701B601A30192010E9423056D +:1008C000F80160830894811C911CA11CB11CC70114 +:1008D000B601A30192010E942305C901DA016C014E +:1008E0007D01C114D104E104F104F1F681E0E82EA8 +:1008F000F12CEC0EFD1EE80CF91C3E010894611C65 +:10090000711CD501C4010197A109B1096C01C81876 +:10091000D90814C0F601EE0DFF1D60816A3010F495 +:10092000605D01C0695CD101ED91FC910190F081A5 +:10093000E02DC10109950894E108F1086E147F04C7 +:1009400049F7A0960FB6F894DEBF0FBECDBFCF918A +:10095000DF911F910F91FF90EF90DF90CF90BF90AC +:10096000AF909F908F907F906F905F904F903F904F +:100970002F900895EF92FF920F931F93CF93DF93E1 +:10098000EC017A018B0177FF0FC0E881F9810190BA +:10099000F081E02D6DE2099510950095F094E094BA +:1009A000E11CF11C011D111DCE01B801A7012AE0B7 +:1009B0000E942204DF91CF911F910F91FF90EF9041 +:1009C00008950F931F938C01AB01662757FD609527 +:1009D000762F0E94BA04C8010E9400041F910F9153 +:1009E0000895629FD001739FF001829FE00DF11D79 +:1009F000649FE00DF11D929FF00D839FF00D749F99 +:100A0000F00D659FF00D9927729FB00DE11DF91F44 +:100A1000639FB00DE11DF91FBD01CF0111240895A1 +:100A200097FB092E07260AD077FD04D049D006D0BF +:100A300000201AF4709561957F4F0895F6F7909510 +:100A400081959F4F0895A1E21A2EAA1BBB1BFD01A1 +:100A50000DC0AA1FBB1FEE1FFF1FA217B307E4079D +:100A6000F50720F0A21BB30BE40BF50B661F771FF5 +:100A7000881F991F1A9469F76095709580959095D5 +:100A80009B01AC01BD01CF01089597FB092E0526FE +:100A90000ED057FD04D0D7DF0AD0001C38F4509593 +:100AA0004095309521953F4F4F4F5F4F0895F6F792 +:100AB00090958095709561957F4F8F4F9F4F0895CA +:100AC000AA1BBB1B51E107C0AA1FBB1FA617B70774 +:100AD00010F0A61BB70B881F991F5A95A9F7809590 +:100AE0009095BC01CD010895EE0FFF1F0590F49184 +:080AF000E02D0994F894FFCFFA +:100AF8000056616C6F7220416E616C6F6769636F3D +:100B080020646F20466F746F5265636570746F72EE +:100B180020636F6D206C6564206170616761646F2C +:100B28003A200056616C6F7220416E616C6F676984 +:100B3800636F20646F20466F746F526563657074CD +:100B48006F7220636F6D206C656420616365736FDD +:100B58003A20000E0001000200030004000500080E +:100B68000007000D000900120001000000007403D6 +:040B7800C103D903D9 +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.o new file mode 100644 index 0000000..4f019e3 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/core.a new file mode 100644 index 0000000..9d840eb Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/Lab_Capitulo_3_Item_5_Sensor_Temperatura.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/Lab_Capitulo_3_Item_5_Sensor_Temperatura.pde new file mode 100644 index 0000000..db9430d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/Lab_Capitulo_3_Item_5_Sensor_Temperatura.pde @@ -0,0 +1,87 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = AP4; + +void setup() { + int i; + pinMode(A3, INPUT); + pinMode(LED, OUTPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura_analogica = 0; + int leitura_digital = 0; + + //Serial.println(""); + //delay (200); + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo NTC + Serial.print("Valor Analogico do Sensor de Temperatura: "); + Serial.println(leitura_analogica); + delay (500); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp new file mode 100644 index 0000000..adbe1d3 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp @@ -0,0 +1,103 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +#include "WProgram.h" +void setup(); +void loop(); +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = AP4; + +void setup() { + int i; + pinMode(A3, INPUT); + pinMode(LED, OUTPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura_analogica = 0; + int leitura_digital = 0; + + //Serial.println(""); + //delay (200); + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo NTC + Serial.print("Valor Analogico do Sensor de Temperatura: "); + Serial.println(leitura_analogica); + delay (500); +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.elf new file mode 100644 index 0000000..cc3f21a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.hex new file mode 100644 index 0000000..e3073af --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.hex @@ -0,0 +1,166 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C94DF000C948A000C94C9010C948A0073 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000120311241FBECFEFD8E0DEBFCDBF6A +:1000D00011E0A0E0B1E0E8EFF9E002C005900D9278 +:1000E000AC34B107D9F711E0ACE4B1E001C01D9226 +:1000F000AC3EB107E1F710E0C4ECD0E004C02297B9 +:10010000FE010E94F604C23CD107C9F70E94D80044 +:100110000C94FA040C940000EF92FF920F931F933B +:1001200083E00E948B017C0109ED11E0C80160E0D1 +:1001300071E00E948303C801B7010E94610464EF6B +:1001400071E080E090E00E9427011F910F91FF90E5 +:10015000EF9008950F931F93CF93DF9383E060E0B8 +:100160000E94A90180913F0161E00E94A9010BE278 +:1001700011E0C0E0D0E008C0F801808161E00E9499 +:10018000A90121960E5F1F4F80913D0190913E0184 +:10019000C817D9078CF389ED91E040E855E260E09B +:1001A00070E00E940602DF91CF911F910F91089598 +:1001B0000E9451010E94AA000E948C00FDCF1F9254 +:1001C0000F920FB60F9211242F933F938F939F930B +:1001D000AF93BF938091500190915101A091520132 +:1001E000B0915301309154010196A11DB11D232FEF +:1001F0002D5F2D3720F02D570196A11DB11D2093A5 +:1002000054018093500190935101A0935201B093F7 +:10021000530180914C0190914D01A0914E01B091FC +:100220004F010196A11DB11D80934C0190934D018A +:10023000A0934E01B0934F01BF91AF919F918F91C9 +:100240003F912F910F900FBE0F901F901895EF9236 +:10025000FF920F931F937B018C018FB7F89440910D +:1002600050015091510160915201709153018FBF23 +:100270002FB7F8948091500190915101A0915201B3 +:10028000B09153012FBF841B950BA60BB70BE8163B +:10029000F9060A071B0760F71F910F91FF90EF9077 +:1002A0000895789484B5826084BD84B5816084BDEE +:1002B00085B5826085BD85B5816085BDEEE6F0E0DF +:1002C000808181608083E1E8F0E0808182608083CA +:1002D000808181608083E0E8F0E0808181608083BC +:1002E000E1EBF0E0808184608083E0EBF0E08081EE +:1002F00081608083EAE7F0E0808184608083808190 +:100300008260808380818160808380818068808337 +:100310001092C10008958F70909141019295990FAC +:10032000990F907C982B90937C0080917A00806448 +:1003300080937A0080917A0086FDFCCF209178002E +:1003400040917900942F80E030E0282B392BC901AF +:100350000895282F30E0C90186569F4FFC019491E3 +:100360002A573F4FF9018491882391F0E82FF0E05C +:10037000EE0FFF1FE859FF4FA591B491662329F4B2 +:100380008C91909589238C9308958C91892B8C93D3 +:1003900008951F920F920FB60F9211242F933F933F +:1003A0004F935F936F937F938F939F93AF93BF937D +:1003B000EF93FF934091C600E091D501F091D601F3 +:1003C000CF01019660E870E00E9490049C0180914A +:1003D000D7019091D8012817390739F0EB5AFE4F11 +:1003E00040833093D6012093D501FF91EF91BF91C7 +:1003F000AF919F918F917F916F915F914F913F91BD +:100400002F910F900FBE0F901F9018955F926F92D3 +:100410007F928F929F92AF92BF92CF92DF92EF9294 +:10042000FF920F931F93CF93DF93EC013A014B019F +:10043000413482E458078FE0680780E078070CF0C9 +:100440007FC060E874E88EE190E0A40193010E940F +:10045000C5042150304040405040CA01B90122E05B +:1004600030E040E050E00E94C50459016A01A60155 +:100470009501209530954095509594E0220F331FBB +:10048000441F551F9A95D1F760E074E284EF90E025 +:100490000E94C504CA01B9012FEF30E040E050E0EE +:1004A0000E947104A40193010E94C504C9018150F6 +:1004B0009F4F181619061CF4522E5A9403C0552447 +:1004C0005394521A60E079E08DE390E0A401930127 +:1004D0000E94C5042150304040405040CA01B9013B +:1004E00022E030E040E050E00E94C50420953095C5 +:1004F0004095509583E0220F331F441F551F8A9566 +:10050000D1F760E074E284EF90E00E94C504CA0174 +:10051000B9012FEF30E040E050E00E947104A401E7 +:1005200093010E94C504C90181509F4F18161906F6 +:100530001CF4822F815002C081E0821B851500F5DA +:10054000E885F98581E090E00A8802C0880F991F4C +:100550000A94E2F7808360E079E08DE390E0A40103 +:1005600093010E94C5042150304040405040CA01D0 +:10057000B90122E030E040E050E00E94C50404C030 +:10058000E885F98510829501EC81FD813083EE814B +:10059000FF812083EA85FB85208141E050E0CA018C +:1005A0000E8402C0880F991F0A94E2F7282B20833B +:1005B000EA85FB852081CA010F8402C0880F991F3C +:1005C0000A94E2F7282B2083EA85FB85808108883E +:1005D00002C0440F551F0A94E2F7842B8083DF91F9 +:1005E000CF911F910F91FF90EF90DF90CF90BF9030 +:1005F000AF909F908F907F906F905F900895FC01D7 +:10060000A085B18521898C9190E0022E02C095953C +:1006100087950A94E2F780FFF6CF0484F585E02DF4 +:100620006083089586E491E09093DA018093D90184 +:1006300085E591E09093DC018093DB0185EC90E00F +:100640009093DE018093DD0184EC90E09093E001D3 +:100650008093DF0180EC90E09093E2018093E101D0 +:1006600081EC90E09093E4018093E30186EC90E0CC +:100670009093E6018093E50184E08093E70183E0B5 +:100680008093E80187E08093E90185E08093EA01A7 +:1006900081E08093EB0108950F931F93CF93DF9335 +:1006A0008C01EB0109C02196D801ED91FC910190DC +:1006B000F081E02DC801099568816623A1F7DF91DB +:1006C000CF911F910F910895EF92FF920F931F9377 +:1006D000CF93DF938C017B01EA010CC0D7016D91B0 +:1006E0007D01D801ED91FC910190F081E02DC801D0 +:1006F00009952197209791F7DF91CF911F910F9145 +:10070000FF90EF900895DC01ED91FC910280F38160 +:10071000E02D099508950F931F938C01DC01ED9155 +:10072000FC910190F081E02D6DE00995D801ED91EB +:10073000FC910190F081E02DC8016AE009951F91BC +:100740000F9108952F923F924F925F926F927F92F6 +:100750008F929F92AF92BF92CF92DF92EF92FF92D1 +:100760000F931F93DF93CF93CDB7DEB7A0970FB64C +:10077000F894DEBF0FBECDBF1C016A017B0141159D +:1007800051056105710549F4DC01ED91FC91019081 +:10079000F081E02D60E3099554C088249924540128 +:1007A000422E55246624772401E010E00C0F1D1F13 +:1007B000080D191DC701B601A30192010E94A304EF +:1007C000F80160830894811C911CA11CB11CC70115 +:1007D000B601A30192010E94A304C901DA016C01D0 +:1007E0007D01C114D104E104F104F1F681E0E82EA9 +:1007F000F12CEC0EFD1EE80CF91C3E010894611C66 +:10080000711CD501C4010197A109B1096C01C81877 +:10081000D90814C0F601EE0DFF1D60816A3010F496 +:10082000605D01C0695CD101ED91FC910190F081A6 +:10083000E02DC10109950894E108F1086E147F04C8 +:1008400049F7A0960FB6F894DEBF0FBECDBFCF918B +:10085000DF911F910F91FF90EF90DF90CF90BF90AD +:10086000AF909F908F907F906F905F904F903F9050 +:100870002F900895EF92FF920F931F93CF93DF93E2 +:10088000EC017A018B0177FF0FC0E881F9810190BB +:10089000F081E02D6DE2099510950095F094E094BB +:1008A000E11CF11C011D111DCE01B801A7012AE0B8 +:1008B0000E94A203DF91CF911F910F91FF90EF90C3 +:1008C00008950F931F938C01AB01662757FD609528 +:1008D000762F0E943A04C8010E948B031F910F914A +:1008E0000895629FD001739FF001829FE00DF11D7A +:1008F000649FE00DF11D929FF00D839FF00D749F9A +:10090000F00D659FF00D9927729FB00DE11DF91F45 +:10091000639FB00DE11DF91FBD01CF0111240895A2 +:1009200097FB092E07260AD077FD04D049D006D0C0 +:1009300000201AF4709561957F4F0895F6F7909511 +:1009400081959F4F0895A1E21A2EAA1BBB1BFD01A2 +:100950000DC0AA1FBB1FEE1FFF1FA217B307E4079E +:10096000F50720F0A21BB30BE40BF50B661F771FF6 +:10097000881F991F1A9469F76095709580959095D6 +:100980009B01AC01BD01CF01089597FB092E0526FF +:100990000ED057FD04D0D7DF0AD0001C38F4509594 +:1009A0004095309521953F4F4F4F5F4F0895F6F793 +:1009B00090958095709561957F4F8F4F9F4F0895CB +:1009C000AA1BBB1B51E107C0AA1FBB1FA617B70775 +:1009D00010F0A61BB70B881F991F5A95A9F7809591 +:1009E0009095BC01CD010895EE0FFF1F0590F49185 +:0809F000E02D0994F894FFCFFB +:1009F80056616C6F7220416E616C6F6769636F201E +:100A0800646F2053656E736F722064652054656D42 +:100A180070657261747572613A20000E00010002FF +:100A280000030004000500080007000D000900127B +:0C0A3800000100000000FF024C036403FA +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.o new file mode 100644 index 0000000..f8019d6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/core.a new file mode 100644 index 0000000..6a817b2 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/Lab_Capitulo_3_Item_6_UltraSom_Ping.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/Lab_Capitulo_3_Item_6_UltraSom_Ping.pde new file mode 100644 index 0000000..9b0b60e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/Lab_Capitulo_3_Item_6_UltraSom_Ping.pde @@ -0,0 +1,122 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + + +const int pingPin = 7; + + void setup() { + // initialize serial communication: + Serial.begin(9600); + } + + void loop() + { + // establish variables for duration of the ping, + // and the distance result in inches and centimeters: + long duration, inches, cm; + + // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. + // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: + pinMode(pingPin, OUTPUT); + digitalWrite(pingPin, LOW); + delayMicroseconds(2); + digitalWrite(pingPin, HIGH); + delayMicroseconds(5); + digitalWrite(pingPin, LOW); + + // The same pin is used to read the signal from the PING))): a HIGH + // pulse whose duration is the time (in microseconds) from the sending + // of the ping to the reception of its echo off of an object. + pinMode(pingPin, INPUT); + duration = pulseIn(pingPin, HIGH); + + // convert the time into a distance + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + + Serial.print(inches); + Serial.print("in, "); + Serial.print(cm); + Serial.print("cm"); + Serial.println(); + + delay(100); + } + + long microsecondsToInches(long microseconds) + { + // According to Parallax's datasheet for the PING))), there are + // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per + // second). This gives the distance travelled by the ping, outbound + // and return, so we divide by 2 to get the distance of the obstacle. + // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf + return microseconds / 74 / 2; + } + + long microsecondsToCentimeters(long microseconds) + { + // The speed of sound is 340 m/s or 29 microseconds per centimeter. + // The ping travels out and back, so to find the distance of the + // object we take half of the distance travelled. + return microseconds / 29 / 2; + } + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp new file mode 100644 index 0000000..50047bc --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp @@ -0,0 +1,140 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +#include "WProgram.h" +void setup(); +void loop(); +long microsecondsToInches(long microseconds); +long microsecondsToCentimeters(long microseconds); +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + + +const int pingPin = 7; + + void setup() { + // initialize serial communication: + Serial.begin(9600); + } + + void loop() + { + // establish variables for duration of the ping, + // and the distance result in inches and centimeters: + long duration, inches, cm; + + // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. + // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: + pinMode(pingPin, OUTPUT); + digitalWrite(pingPin, LOW); + delayMicroseconds(2); + digitalWrite(pingPin, HIGH); + delayMicroseconds(5); + digitalWrite(pingPin, LOW); + + // The same pin is used to read the signal from the PING))): a HIGH + // pulse whose duration is the time (in microseconds) from the sending + // of the ping to the reception of its echo off of an object. + pinMode(pingPin, INPUT); + duration = pulseIn(pingPin, HIGH); + + // convert the time into a distance + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + + Serial.print(inches); + Serial.print("in, "); + Serial.print(cm); + Serial.print("cm"); + Serial.println(); + + delay(100); + } + + long microsecondsToInches(long microseconds) + { + // According to Parallax's datasheet for the PING))), there are + // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per + // second). This gives the distance travelled by the ping, outbound + // and return, so we divide by 2 to get the distance of the obstacle. + // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf + return microseconds / 74 / 2; + } + + long microsecondsToCentimeters(long microseconds) + { + // The speed of sound is 340 m/s or 29 microseconds per centimeter. + // The ping travels out and back, so to find the distance of the + // object we take half of the distance travelled. + return microseconds / 29 / 2; + } + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.elf new file mode 100644 index 0000000..ecbe4a6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.hex new file mode 100644 index 0000000..9a58a16 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.hex @@ -0,0 +1,189 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C9400010C948A000C94A8020C948A0071 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000F10311241FBECFEFD8E0DEBFCDBF8B +:1000D00011E0A0E0B1E0E6E9FBE002C005900D927E +:1000E000A231B107D9F711E0A2E1B1E001C01D9240 +:1000F000A23BB107E1F710E0C4ECD0E004C02297C6 +:10010000FE010E94C505C23CD107C9F70E94F90053 +:100110000C94C9050C940000CF92DF92EF92FF92ED +:100120000F931F9387E061E00E94BA0187E060E0CF +:100130000E94DA0182E090E00E94720187E061E0B3 +:100140000E94DA0185E090E00E94720187E060E0A1 +:100150000E94DA0187E060E00E94BA0187E061E076 +:1001600020E432E44FE050E00E942702F62EE72E12 +:10017000D82EC92E0FE911E024E930E040E050E02C +:100180000E949405C801BA01A9010E941905C8017D +:1001900060E071E00E9462046F2D7E2D8D2D9C2DFC +:1001A0002AE330E040E050E00E949405C801BA0123 +:1001B000A9010E941905C80165E071E00E9462046E +:1001C000C8010E946A0464E670E080E090E00E944A +:1001D00048011F910F91FF90EF90DF90CF9008950D +:1001E0008FE991E040E855E260E070E00E94E502AE +:1001F00008950E9480010E94F0000E948C00FDCFB3 +:100200001F920F920FB60F9211242F933F938F934B +:100210009F93AF93BF938091160190911701A09186 +:100220001801B091190130911A010196A11DB11D5B +:10023000232F2D5F2D3720F02D570196A11DB11DC5 +:1002400020931A018093160190931701A09318012F +:10025000B09319018091120190911301A0911401A2 +:10026000B09115010196A11DB11D809312019093CB +:100270001301A0931401B0931501BF91AF919F9109 +:100280008F913F912F910F900FBE0F901F90189557 +:10029000EF92FF920F931F937B018C018FB7F8941D +:1002A0004091160150911701609118017091190148 +:1002B0008FBF2FB7F8948091160190911701A091EC +:1002C0001801B09119012FBF841B950BA60BB70B1A +:1002D000E816F9060A071B0760F71F910F91FF90B8 +:1002E000EF900895019759F0FC01EE0FFF1FEE0FFC +:1002F000FF1F32978FB7F8943197F1F78FBF0895AA +:10030000789484B5826084BD84B5816084BD85B5F0 +:10031000826085BD85B5816085BDEEE6F0E08081B7 +:1003200081608083E1E8F0E0808182608083808169 +:1003300081608083E0E8F0E0808181608083E1EB90 +:10034000F0E0808184608083E0EBF0E08081816078 +:100350008083EAE7F0E0808184608083808182602E +:100360008083808181608083808180688083109217 +:10037000C1000895282F30E0C90186569F4FFC0127 +:1003800094912A573F4FF9018491882391F0E82FE7 +:10039000F0E0EE0FFF1FE859FF4FA591B4916623DF +:1003A00029F48C91909589238C9308958C91892BB5 +:1003B0008C930895482F50E0CA0182559F4FFC014D +:1003C0002491CA0186569F4FFC0194914A575F4F72 +:1003D000FA0134913323D1F1222331F1233021F476 +:1003E000809180008F7705C0243031F480918000A7 +:1003F0008F7D8093800018C0213019F484B58F77E9 +:1004000004C0223021F484B58F7D84BD0DC0263018 +:1004100021F48091B0008F7705C0273029F48091B6 +:10042000B0008F7D8093B000E32FF0E0EE0FFF1F50 +:10043000EE58FF4FA591B491662329F48C919095C5 +:1004400089238C9308958C91892B8C930895DF9246 +:10045000EF92FF920F931F93A82FB0E0CD01865625 +:100460009F4FFC01D490AA57BF4FFD018491662392 +:1004700011F490E001C09D2D6FEFE62E6FEFF62E88 +:100480006FEF062F6FE0162FE222F32204231523CD +:10049000682F70E0660F771F64587F4F20E030E0D0 +:1004A00040E050E0FB01A591B4910AC02E153F0534 +:1004B0004007510709F440C02F5F3F4F4F4F5F4F38 +:1004C0008C918D21891791F30AC02E153F054007A5 +:1004D000510791F12F5F3F4F4F4F5F4F03C0FB011B +:1004E000A591B4918C918D21891779F720E030E0A6 +:1004F00040E050E0FB01A591B49104C02F5F3F4F55 +:100500004F4F5F4F8C918D218917C1F3CA01B901FB +:100510002AE030E040E050E00E9440059B01AC0141 +:10052000205F3F4F4F4F5F4F84E05695479537957B +:1005300027958A95D1F704C020E030E040E050E0F4 +:10054000B901CA011F910F91FF90EF90DF900895BC +:100550001F920F920FB60F9211242F933F934F9338 +:100560005F936F937F938F939F93AF93BF93EF931B +:10057000FF934091C600E0919B01F0919C01CF0157 +:10058000019660E870E00E945F059C0180919D01EA +:1005900090919E012817390739F0E55EFE4F4083A0 +:1005A00030939C0120939B01FF91EF91BF91AF91FC +:1005B0009F918F917F916F915F914F913F912F917B +:1005C0000F900FBE0F901F9018955F926F927F92C1 +:1005D0008F929F92AF92BF92CF92DF92EF92FF9253 +:1005E0000F931F93CF93DF93EC013A014B014134FA +:1005F00082E458078FE0680780E078070CF07FC03E +:1006000060E874E88EE190E0A40193010E949405F3 +:100610002150304040405040CA01B90122E030E052 +:1006200040E050E00E94940559016A01A60195013D +:10063000209530954095509594E0220F331F441F2C +:10064000551F9A95D1F760E074E284EF90E00E9424 +:100650009405CA01B9012FEF30E040E050E00E945C +:100660004005A40193010E949405C90181509F4F48 +:10067000181619061CF4522E5A9403C0552453948C +:10068000521A60E079E08DE390E0A40193010E94AA +:1006900094052150304040405040CA01B90122E049 +:1006A00030E040E050E00E94940520953095409560 +:1006B000509583E0220F331F441F551F8A95D1F7B1 +:1006C00060E074E284EF90E00E949405CA01B901F1 +:1006D0002FEF30E040E050E00E944005A40193017C +:1006E0000E949405C90181509F4F181619061CF4E9 +:1006F000822F815002C081E0821B851500F5E885BC +:10070000F98581E090E00A8802C0880F991F0A9459 +:10071000E2F7808360E079E08DE390E0A40193014B +:100720000E9494052150304040405040CA01B90118 +:1007300022E030E040E050E00E94940504C0E885EB +:10074000F98510829501EC81FD813083EE81FF8176 +:100750002083EA85FB85208141E050E0CA010E84B8 +:1007600002C0880F991F0A94E2F7282B2083EA859C +:10077000FB852081CA010F8402C0880F991F0A944B +:10078000E2F7282B2083EA85FB858081088802C058 +:10079000440F551F0A94E2F7842B8083DF91CF9199 +:1007A0001F910F91FF90EF90DF90CF90BF90AF908F +:1007B0009F908F907F906F905F900895FC01A0852F +:1007C000B18521898C9190E0022E02C09595879584 +:1007D0000A94E2F780FFF6CF0484F585E02D60836C +:1007E00008958CE091E09093A00180939F018BE1AC +:1007F00091E09093A2018093A10185EC90E0909309 +:10080000A4018093A30184EC90E09093A6018093CF +:10081000A50180EC90E09093A8018093A70181EC62 +:1008200090E09093AA018093A90186EC90E09093C8 +:10083000AC018093AB0184E08093AD0183E08093B1 +:10084000AE0187E08093AF0185E08093B00181E045 +:100850008093B10108950F931F93CF93DF938C0181 +:10086000EB0109C02196D801ED91FC910190F08136 +:10087000E02DC801099568816623A1F7DF91CF912A +:100880001F910F910895EF92FF920F931F93CF93B3 +:10089000DF938C017B01EA010CC0D7016D917D01D2 +:1008A000D801ED91FC910190F081E02DC8010995EE +:1008B0002197209791F7DF91CF911F910F91FF9092 +:1008C000EF900895DC01ED91FC910280F381E02D21 +:1008D000099508950F931F938C01DC01ED91FC9114 +:1008E0000190F081E02D6DE00995D801ED91FC912A +:1008F0000190F081E02DC8016AE009951F910F91E8 +:1009000008952F923F924F925F926F927F928F92B3 +:100910009F92AF92BF92CF92DF92EF92FF920F938E +:100920001F93DF93CF93CDB7DEB7A0970FB6F894A0 +:10093000DEBF0FBECDBF1C016A017B014115510511 +:100940006105710549F4DC01ED91FC910190F081A4 +:10095000E02D60E3099554C0882499245401422E67 +:1009600055246624772401E010E00C0F1D1F080DAC +:10097000191DC701B601A30192010E947205F80179 +:1009800060830894811C911CA11CB11CC701B60195 +:10099000A30192010E947205C901DA016C017D0177 +:1009A000C114D104E104F104F1F681E0E82EF12C48 +:1009B000EC0EFD1EE80CF91C3E010894611C711C34 +:1009C000D501C4010197A109B1096C01C818D90862 +:1009D00014C0F601EE0DFF1D60816A3010F4605DF9 +:1009E00001C0695CD101ED91FC910190F081E02D95 +:1009F000C10109950894E108F1086E147F0449F7D4 +:100A0000A0960FB6F894DEBF0FBECDBFCF91DF9199 +:100A10001F910F91FF90EF90DF90CF90BF90AF901C +:100A20009F908F907F906F905F904F903F902F900E +:100A30000895EF92FF920F931F93CF93DF93EC01F2 +:100A40007A018B0177FF0FC0E881F9810190F08175 +:100A5000E02D6DE2099510950095F094E094E11C6D +:100A6000F11C011D111DCE01B801A7012AE00E9451 +:100A70008104DF91CF911F910F91FF90EF90089526 +:100A8000629FD001739FF001829FE00DF11D649F72 +:100A9000E00DF11D929FF00D839FF00D749FF00DFE +:100AA000659FF00D9927729FB00DE11DF91F639F9F +:100AB000B00DE11DF91FBD01CF011124089597FB71 +:100AC000092E07260AD077FD04D049D006D0002091 +:100AD0001AF4709561957F4F0895F6F7909581957A +:100AE0009F4F0895A1E21A2EAA1BBB1BFD010DC04A +:100AF000AA1FBB1FEE1FFF1FA217B307E407F507CE +:100B000020F0A21BB30BE40BF50B661F771F881FA9 +:100B1000991F1A9469F760957095809590959B013F +:100B2000AC01BD01CF01089597FB092E05260ED01B +:100B300057FD04D0D7DF0AD0001C38F450954095FB +:100B4000309521953F4F4F4F5F4F0895F6F79095A1 +:100B50008095709561957F4F8F4F9F4F0895AA1B89 +:100B6000BB1B51E107C0AA1FBB1FA617B70710F098 +:100B7000A61BB70B881F991F5A95A9F780959095CA +:100B8000BC01CD010895EE0FFF1F0590F491E02DFB +:060B90000994F894FFCF68 +:100B9600696E2C2000636D0000000000DE032B044C +:020BA600430406 +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.o new file mode 100644 index 0000000..1a3d3d0 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/core.a new file mode 100644 index 0000000..2605c28 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.pde new file mode 100644 index 0000000..7901b4d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.pde @@ -0,0 +1,127 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + + + /* + Memsic2125 + + Read the Memsic 2125 two-axis accelerometer. Converts the + pulses output by the 2125 into milli-g's (1/1000 of earth's + gravity) and prints them over the serial connection to the + computer. + + The circuit: + * X output of accelerometer to digital pin 2 + * Y output of accelerometer to digital pin 3 + * +V of accelerometer to +5V + * GND of accelerometer to ground + + http://www.arduino.cc/en/Tutorial/Memsic2125 + + created 6 Nov 2008 + by David A. Mellis + modified 30 Jun 2009 + by Tom Igoe + + */ + + // these constants won't change: + const int xPin = 2; // X output of the accelerometer + const int yPin = 3; // Y output of the accelerometer + + void setup() { + // initialize serial communications: + Serial.begin(9600); + // initialize the pins connected to the accelerometer + // as inputs: + pinMode(xPin, INPUT); + pinMode(yPin, INPUT); + } + + void loop() { + // variables to read the pulse widths: + int pulseX, pulseY; + // variables to contain the resulting accelerations + int accelerationX, accelerationY; + + // read pulse from x- and y-axes: + pulseX = pulseIn(xPin,HIGH); + pulseY = pulseIn(yPin,HIGH); + + // convert the pulse width into acceleration + // accelerationX and accelerationY are in milli-g's: + // earth's gravity is 1000 milli-g's, or 1g. + accelerationX = ((pulseX / 10) - 500) * 8; + accelerationY = ((pulseY / 10) - 500) * 8; + + // print the acceleration + Serial.print("X= "); + Serial.print(accelerationX); + // print a tab character: + Serial.print("\t"); + Serial.print("Y= "); + Serial.print(accelerationY); + Serial.println(); + + delay(100); + } + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp new file mode 100644 index 0000000..63b3051 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp @@ -0,0 +1,143 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +#include "WProgram.h" +void setup(); +void loop(); +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + + + /* + Memsic2125 + + Read the Memsic 2125 two-axis accelerometer. Converts the + pulses output by the 2125 into milli-g's (1/1000 of earth's + gravity) and prints them over the serial connection to the + computer. + + The circuit: + * X output of accelerometer to digital pin 2 + * Y output of accelerometer to digital pin 3 + * +V of accelerometer to +5V + * GND of accelerometer to ground + + http://www.arduino.cc/en/Tutorial/Memsic2125 + + created 6 Nov 2008 + by David A. Mellis + modified 30 Jun 2009 + by Tom Igoe + + */ + + // these constants won't change: + const int xPin = 2; // X output of the accelerometer + const int yPin = 3; // Y output of the accelerometer + + void setup() { + // initialize serial communications: + Serial.begin(9600); + // initialize the pins connected to the accelerometer + // as inputs: + pinMode(xPin, INPUT); + pinMode(yPin, INPUT); + } + + void loop() { + // variables to read the pulse widths: + int pulseX, pulseY; + // variables to contain the resulting accelerations + int accelerationX, accelerationY; + + // read pulse from x- and y-axes: + pulseX = pulseIn(xPin,HIGH); + pulseY = pulseIn(yPin,HIGH); + + // convert the pulse width into acceleration + // accelerationX and accelerationY are in milli-g's: + // earth's gravity is 1000 milli-g's, or 1g. + accelerationX = ((pulseX / 10) - 500) * 8; + accelerationY = ((pulseY / 10) - 500) * 8; + + // print the acceleration + Serial.print("X= "); + Serial.print(accelerationX); + // print a tab character: + Serial.print("\t"); + Serial.print("Y= "); + Serial.print(accelerationY); + Serial.println(); + + delay(100); + } + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.elf new file mode 100644 index 0000000..799e868 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.hex new file mode 100644 index 0000000..37535af --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.hex @@ -0,0 +1,179 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C9405010C948A000C9452020C948A00C2 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C00000009B0311241FBECFEFD8E0DEBFCDBFE1 +:1000D00011E0A0E0B1E0EAEFFAE002C005900D9275 +:1000E000A431B107D9F711E0A4E1B1E001C01D923C +:1000F000A43BB107E1F710E0C4ECD0E004C02297C4 +:10010000FE010E947705C23CD107C9F70E94FE009C +:100110000C947B050C9400008F929F92AF92BF923B +:10012000CF92DF92EF92FF920F931F9382E061E0F4 +:1001300020E432E44FE050E00E94D1016B017C01E9 +:1001400083E061E020E432E44FE050E00E94D1011E +:100150004B015C0101EA11E0C80160E071E00E941E +:100160000C04C6016AE070E00E941105645F7140F2 +:1001700093E0660F771F9A95E1F7C8010E94EA04A1 +:10018000C80164E071E00E940C04C80166E071E0FF +:100190000E940C04C4016AE070E00E941105645FD3 +:1001A000714083E0660F771F8A95E1F7C8010E94CE +:1001B000EA04C8010E94140464E670E080E090E064 +:1001C0000E944D011F910F91FF90EF90DF90CF9013 +:1001D000BF90AF909F908F90089581EA91E040E8A2 +:1001E00055E260E070E00E948F0282E060E00E94D1 +:1001F000B10183E060E00E94B10108950E9477019F +:100200000E94ED000E948C00FDCF1F920F920FB64E +:100210000F9211242F933F938F939F93AF93BF938C +:100220008091180190911901A0911A01B0911B01C0 +:1002300030911C010196A11DB11D232F2D5F2D377B +:1002400020F02D570196A11DB11D20931C01809314 +:10025000180190931901A0931A01B0931B0180918A +:10026000140190911501A0911601B091170101960A +:10027000A11DB11D8093140190931501A093160147 +:10028000B0931701BF91AF919F918F913F912F91A3 +:100290000F900FBE0F901F901895EF92FF920F9343 +:1002A0001F937B018C018FB7F894409118015091F6 +:1002B000190160911A0170911B018FBF2FB7F8943B +:1002C0008091180190911901A0911A01B0911B0120 +:1002D0002FBF841B950BA60BB70BE816F9060A0770 +:1002E0001B0760F71F910F91FF90EF90089578948E +:1002F00084B5826084BD84B5816084BD85B582602B +:1003000085BD85B5816085BDEEE6F0E080818160C8 +:100310008083E1E8F0E08081826080838081816079 +:100320008083E0E8F0E0808181608083E1EBF0E0B1 +:10033000808184608083E0EBF0E080818160808355 +:10034000EAE7F0E08081846080838081826080833E +:100350008081816080838081806880831092C10069 +:100360000895282F30E0C90186569F4FFC019491D3 +:100370002A573F4FF9018491882391F0E82FF0E04C +:10038000EE0FFF1FE859FF4FA591B491662329F4A2 +:100390008C91909589238C9308958C91892B8C93C3 +:1003A0000895DF92EF92FF920F931F93A82FB0E072 +:1003B000CD0186569F4FFC01D490AA57BF4FFD0137 +:1003C0008491662311F490E001C09D2D6FEFE62E1D +:1003D0006FEFF62E6FEF062F6FE0162FE222F3225B +:1003E00004231523682F70E0660F771F64587F4F32 +:1003F00020E030E040E050E0FB01A591B4910AC05C +:100400002E153F054007510709F440C02F5F3F4FAD +:100410004F4F5F4F8C918D21891791F30AC02E1594 +:100420003F054007510791F12F5F3F4F4F4F5F4FFF +:1004300003C0FB01A591B4918C918D21891779F7A7 +:1004400020E030E040E050E0FB01A591B49104C011 +:100450002F5F3F4F4F4F5F4F8C918D218917C1F315 +:10046000CA01B9012AE030E040E050E00E94F20405 +:100470009B01AC01205F3F4F4F4F5F4F84E056958B +:100480004795379527958A95D1F704C020E030E04D +:1004900040E050E0B901CA011F910F91FF90EF9029 +:1004A000DF9008951F920F920FB60F9211242F9391 +:1004B0003F934F935F936F937F938F939F93AF93EC +:1004C000BF93EF93FF934091C600E0919D01F0919F +:1004D0009E01CF01019660E870E00E9411059C0129 +:1004E00080919F019091A0012817390739F0E35EB0 +:1004F000FE4F408330939E0120939D01FF91EF9129 +:10050000BF91AF919F918F917F916F915F914F912B +:100510003F912F910F900FBE0F901F9018955F92F3 +:100520006F927F928F929F92AF92BF92CF92DF9203 +:10053000EF92FF920F931F93CF93DF93EC013A0159 +:100540004B01413482E458078FE0680780E0780768 +:100550000CF07FC060E874E88EE190E0A4019301A4 +:100560000E9446052150304040405040CA01B90128 +:1005700022E030E040E050E00E94460559016A0167 +:10058000A6019501209530954095509594E0220F55 +:10059000331F441F551F9A95D1F760E074E284EF32 +:1005A00090E00E944605CA01B9012FEF30E040E01B +:1005B00050E00E94F204A40193010E944605C90183 +:1005C00081509F4F181619061CF4522E5A9403C0DE +:1005D00055245394521A60E079E08DE390E0A40131 +:1005E00093010E9446052150304040405040CA01CE +:1005F000B90122E030E040E050E00E94460520953D +:1006000030954095509583E0220F331F441F551FAE +:100610008A95D1F760E074E284EF90E00E9446058D +:10062000CA01B9012FEF30E040E050E00E94F2042F +:10063000A40193010E944605C90181509F4F1816DD +:1006400019061CF4822F815002C081E0821B85159F +:1006500000F5E885F98581E090E00A8802C0880FFE +:10066000991F0A94E2F7808360E079E08DE390E0DF +:10067000A40193010E944605215030404040504063 +:10068000CA01B90122E030E040E050E00E94460596 +:1006900004C0E885F98510829501EC81FD813083E5 +:1006A000EE81FF812083EA85FB85208141E050E0D7 +:1006B000CA010E8402C0880F991F0A94E2F7282B02 +:1006C0002083EA85FB852081CA010F8402C0880F40 +:1006D000991F0A94E2F7282B2083EA85FB85808105 +:1006E000088802C0440F551F0A94E2F7842B8083C8 +:1006F000DF91CF911F910F91FF90EF90DF90CF90FE +:10070000BF90AF909F908F907F906F905F90089573 +:10071000FC01A085B18521898C9190E0022E02C058 +:10072000959587950A94E2F780FFF6CF0484F585C6 +:10073000E02D608308958EE091E09093A201809374 +:10074000A1018DE191E09093A4018093A30185EC38 +:1007500090E09093A6018093A50184EC90E09093A3 +:10076000A8018093A70180EC90E09093AA01809368 +:10077000A90181EC90E09093AC018093AB0186ECF1 +:1007800090E09093AE018093AD0184E08093AF013F +:1007900083E08093B00187E08093B10185E080938E +:1007A000B20181E08093B30108950F931F93CF931B +:1007B000DF938C01EB0109C02196D801ED91FC91EA +:1007C0000190F081E02DC801099568816623A1F7A9 +:1007D000DF91CF911F910F910895EF92FF920F93A8 +:1007E0001F93CF93DF938C017B01EA010CC0D701EB +:1007F0006D917D01D801ED91FC910190F081E02D8A +:10080000C80109952197209791F7DF91CF911F910A +:100810000F91FF90EF900895DC01ED91FC91028023 +:10082000F381E02D099508950F931F938C01DC014E +:10083000ED91FC910190F081E02D6DE00995D801DA +:10084000ED91FC910190F081E02DC8016AE00995DD +:100850001F910F9108952F923F924F925F926F9246 +:100860007F928F929F92AF92BF92CF92DF92EF9240 +:10087000FF920F931F93DF93CF93CDB7DEB7A0976F +:100880000FB6F894DEBF0FBECDBF1C016A017B011D +:10089000411551056105710549F4DC01ED91FC91AB +:1008A0000190F081E02D60E3099554C088249924DB +:1008B0005401422E55246624772401E010E00C0FE9 +:1008C0001D1F080D191DC701B601A30192010E9449 +:1008D0002405F80160830894811C911CA11CB11CA3 +:1008E000C701B601A30192010E942405C901DA01E2 +:1008F0006C017D01C114D104E104F104F1F681E041 +:10090000E82EF12CEC0EFD1EE80CF91C3E010894BB +:10091000611C711CD501C4010197A109B1096C01C9 +:10092000C818D90814C0F601EE0DFF1D60816A30A9 +:1009300010F4605D01C0695CD101ED91FC91019002 +:10094000F081E02DC10109950894E108F1086E14C9 +:100950007F0449F7A0960FB6F894DEBF0FBECDBF57 +:10096000CF91DF911F910F91FF90EF90DF90CF908B +:10097000BF90AF909F908F907F906F905F904F90BF +:100980003F902F900895EF92FF920F931F93CF9374 +:10099000DF93EC017A018B0177FF0FC0E881F981C9 +:1009A0000190F081E02D6DE2099510950095F0948D +:1009B000E094E11CF11C011D111DCE01B801A7013D +:1009C0002AE00E942B04DF91CF911F910F91FF909D +:1009D000EF900895AB01662757FD6095762F0E9432 +:1009E000C3040895629FD001739FF001829FE00DC0 +:1009F000F11D649FE00DF11D929FF00D839FF00D9E +:100A0000749FF00D659FF00D9927729FB00DE11D49 +:100A1000F91F639FB00DE11DF91FBD01CF01112426 +:100A2000089597FB092E07260AD077FD04D049D0F8 +:100A300006D000201AF4709561957F4F0895F6F75F +:100A4000909581959F4F0895A1E21A2EAA1BBB1B7A +:100A5000FD010DC0AA1FBB1FEE1FFF1FA217B3078A +:100A6000E407F50720F0A21BB30BE40BF50B661FA0 +:100A7000771F881F991F1A9469F760957095809564 +:100A800090959B01AC01BD01CF01089597FB092E04 +:100A900005260ED057FD04D0D7DF0AD0001C38F44D +:100AA00050954095309521953F4F4F4F5F4F08959A +:100AB000F6F790958095709561957F4F8F4F9F4F7A +:100AC0000895AA1BBB1B51E107C0AA1FBB1FA61795 +:100AD000B70710F0A61BB70B881F991F5A95A9F7E7 +:100AE00080959095BC01CD010895EE0FFF1F0590F4 +:0A0AF000F491E02D0994F894FFCF73 +:100AFA00583D20000900593D2000000000008803ED +:040B0A00D503ED031F +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.o new file mode 100644 index 0000000..207d759 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/core.a new file mode 100644 index 0000000..ebeaca4 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/Lab_Capitulo_3_Item_8_Bussula_HM55B.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/Lab_Capitulo_3_Item_8_Bussula_HM55B.pde new file mode 100644 index 0000000..17a6f51 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/Lab_Capitulo_3_Item_8_Bussula_HM55B.pde @@ -0,0 +1,194 @@ +/* #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + +*/ +/* +///////////////////////////////// +Htachi HM55B Compass +parallax (#) + +AUTHOR: kiilo kiilo@kiilo.org +License: http://creativecommons.org/licenses/by-nc-sa/2.5/ch/ + +http://parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/hm55b/List/1/ProductID/98/Default.aspx?SortField=ProductName%2cProductName +http://sage.medienkunst.ch/tiki-index.php?page=HowTo_Arduino_Parallax_HM55B_Kompass +http://arduino.cc/playground/HM55B + +///////////////////////////////// +*/ +#include // (no semicolon) +//// VARS +byte CLK_pin = 8; +byte EN_pin = 9; +byte DIO_pin = 10; + +int X_Data = 0; +int Y_Data = 0; +int angle; + +//// FUNCTIONS + +void ShiftOut(int Value, int BitsCount) { + for(int i = BitsCount; i >= 0; i--) { + digitalWrite(CLK_pin, LOW); // pino de clock vai para 0 + if ((Value & 1 << i) == ( 1 << i)) { //testa o bit a ser enviado + digitalWrite(DIO_pin, HIGH); + //Serial.print("1"); + } + else { + digitalWrite(DIO_pin, LOW); + //Serial.print("0"); + } + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + } +//Serial.print(" "); +} + +int ShiftIn(int BitsCount) { + int ShiftIn_result; + ShiftIn_result = 0; + pinMode(DIO_pin, INPUT); + for(int i = BitsCount; i >= 0; i--) { + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + if (digitalRead(DIO_pin) == HIGH) { + ShiftIn_result = (ShiftIn_result << 1) + 1; + //Serial.print("x"); + } + else { + ShiftIn_result = (ShiftIn_result << 1) + 0; + //Serial.print("_"); + } + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + } + //Serial.print(":"); + +// below is difficult to understand: +// if bit 11 is Set the value is negative +// the representation of negative values you +// have to add B11111000 in the upper Byte of +// the integer. +// see: http://en.wikipedia.org/wiki/Two%27s_complement + if ((ShiftIn_result & 1 << 11) == 1 << 11) { + ShiftIn_result = (B11111000 << 8) | ShiftIn_result; + } + + + return ShiftIn_result; +} + +void HM55B_Reset() { + pinMode(DIO_pin, OUTPUT); + digitalWrite(EN_pin, LOW); + ShiftOut(B0000, 3); + digitalWrite(EN_pin, HIGH); +} + +void HM55B_StartMeasurementCommand() { + pinMode(DIO_pin, OUTPUT); + digitalWrite(EN_pin, LOW); + ShiftOut(B1000, 3); + digitalWrite(EN_pin, HIGH); +} + +int HM55B_ReadCommand() { + int result = 0; + pinMode(DIO_pin, OUTPUT); + digitalWrite(EN_pin, LOW); + ShiftOut(B1100, 3); + result = ShiftIn(3); + return result; +} + + +void setup() { + Serial.begin(115200); + //Serial.begin(9600); + pinMode(EN_pin, OUTPUT); + pinMode(CLK_pin, OUTPUT); + pinMode(DIO_pin, INPUT); + + HM55B_Reset(); +} + +void loop() { + HM55B_StartMeasurementCommand(); // necessary!! + delay(40); // the data is 40ms later ready + Serial.print(HM55B_ReadCommand()); // read data and print Status + Serial.print(" "); + X_Data = ShiftIn(11); // Field strength in X + Y_Data = ShiftIn(11); // and Y direction + Serial.print(X_Data); // print X strength + Serial.print(" "); + Serial.print(Y_Data); // print Y strength + Serial.print(" "); + digitalWrite(EN_pin, HIGH); // ok deselect chip + angle = 180 * (atan2(-1 * Y_Data , X_Data) / M_PI); // angle is atan( -y/x) !!! + Serial.print(angle); // print angle + Serial.println(""); + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp new file mode 100644 index 0000000..35dd736 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp @@ -0,0 +1,215 @@ +/* #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + +*/ +/* +///////////////////////////////// +Htachi HM55B Compass +parallax (#) + +AUTHOR: kiilo kiilo@kiilo.org +License: http://creativecommons.org/licenses/by-nc-sa/2.5/ch/ + +http://parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/hm55b/List/1/ProductID/98/Default.aspx?SortField=ProductName%2cProductName +http://sage.medienkunst.ch/tiki-index.php?page=HowTo_Arduino_Parallax_HM55B_Kompass +http://arduino.cc/playground/HM55B + +///////////////////////////////// +*/ +#include // (no semicolon) +//// VARS +#include "WProgram.h" +void ShiftOut(int Value, int BitsCount); +int ShiftIn(int BitsCount); +void HM55B_Reset(); +void HM55B_StartMeasurementCommand(); +int HM55B_ReadCommand(); +void setup(); +void loop(); +byte CLK_pin = 8; +byte EN_pin = 9; +byte DIO_pin = 10; + +int X_Data = 0; +int Y_Data = 0; +int angle; + +//// FUNCTIONS + +void ShiftOut(int Value, int BitsCount) { + for(int i = BitsCount; i >= 0; i--) { + digitalWrite(CLK_pin, LOW); + if ((Value & 1 << i) == ( 1 << i)) { + digitalWrite(DIO_pin, HIGH); + //Serial.print("1"); + } + else { + digitalWrite(DIO_pin, LOW); + //Serial.print("0"); + } + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + } +//Serial.print(" "); +} + +int ShiftIn(int BitsCount) { + int ShiftIn_result; + ShiftIn_result = 0; + pinMode(DIO_pin, INPUT); + for(int i = BitsCount; i >= 0; i--) { + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + if (digitalRead(DIO_pin) == HIGH) { + ShiftIn_result = (ShiftIn_result << 1) + 1; + //Serial.print("x"); + } + else { + ShiftIn_result = (ShiftIn_result << 1) + 0; + //Serial.print("_"); + } + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + } + //Serial.print(":"); + +// below is difficult to understand: +// if bit 11 is Set the value is negative +// the representation of negative values you +// have to add B11111000 in the upper Byte of +// the integer. +// see: http://en.wikipedia.org/wiki/Two%27s_complement + if ((ShiftIn_result & 1 << 11) == 1 << 11) { + ShiftIn_result = (B11111000 << 8) | ShiftIn_result; + } + + + return ShiftIn_result; +} + +void HM55B_Reset() { + pinMode(DIO_pin, OUTPUT); + digitalWrite(EN_pin, LOW); + ShiftOut(B0000, 3); + digitalWrite(EN_pin, HIGH); +} + +void HM55B_StartMeasurementCommand() { + pinMode(DIO_pin, OUTPUT); + digitalWrite(EN_pin, LOW); + ShiftOut(B1000, 3); + digitalWrite(EN_pin, HIGH); +} + +int HM55B_ReadCommand() { + int result = 0; + pinMode(DIO_pin, OUTPUT); + digitalWrite(EN_pin, LOW); + ShiftOut(B1100, 3); + result = ShiftIn(3); + return result; +} + + +void setup() { + Serial.begin(115200); + //Serial.begin(9600); + pinMode(EN_pin, OUTPUT); + pinMode(CLK_pin, OUTPUT); + pinMode(DIO_pin, INPUT); + + HM55B_Reset(); +} + +void loop() { + HM55B_StartMeasurementCommand(); // necessary!! + delay(40); // the data is 40ms later ready + Serial.print(HM55B_ReadCommand()); // read data and print Status + Serial.print(" "); + X_Data = ShiftIn(11); // Field strength in X + Y_Data = ShiftIn(11); // and Y direction + Serial.print(X_Data); // print X strength + Serial.print(" "); + Serial.print(Y_Data); // print Y strength + Serial.print(" "); + digitalWrite(EN_pin, HIGH); // ok deselect chip + angle = 180 * (atan2(-1 * Y_Data , X_Data) / M_PI); // angle is atan( -y/x) !!! + Serial.print(angle); // print angle + Serial.println(""); + +} + + + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.elf new file mode 100644 index 0000000..4160f6e Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.hex new file mode 100644 index 0000000..b90414c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.hex @@ -0,0 +1,297 @@ +:100000000C9479000C94A1000C94A1000C94A10014 +:100010000C94A1000C94A1000C94A1000C94A100DC +:100020000C94A1000C94A1000C94A1000C94A100CC +:100030000C94A1000C94A1000C94A1000C94A100BC +:100040000C9408020C94A1000C947E030C94A10063 +:100050000C94A1000C94A1000C94A1000C94A1009C +:100060000C94A1000C94A100084AD73B3BCE016E32 +:1000700084BCBFFDC12F3D6C74319ABD56833DDAFF +:100080003D00C77F11BED9E4BB4C3E916BAAAABE0E +:10009000000000803F00000000240027002A00002C +:1000A000000000250028002B00000000002300268F +:1000B00000290004040404040404040202020202ED +:1000C000020303030303030102040810204080011C +:1000D000020408102001020408102000000007009C +:1000E0000201000003040600000000000000000000 +:1000F000C70411241FBECFEFD8E0DEBFCDBF11E093 +:10010000A0E0B1E0E8E6F2E102C005900D92A03176 +:10011000B107D9F711E0A0E1B1E001C01D92A63B03 +:10012000B107E1F710E0C2EFD0E004C02297FE0172 +:100130000E942E09C03FD107C9F70E9401020C940A +:1001400032090C940000EF92FF920F931F93CF930C +:10015000DF938C01EB0181E0E82EF12C25C080912A +:10016000030160E00E94E20297010C2E02C0220F00 +:10017000331F0A94E2F7C901802391238217930762 +:1001800021F48091050161E003C08091050160E0E8 +:100190000E94E2028091030161E00E94E20281E09C +:1001A00090E00E947A022197D7FFD9CFDF91CF91BB +:1001B0001F910F91FF90EF9008958091050161E0EC +:1001C0000E94C2028091040160E00E94E20288E085 +:1001D00090E063E070E00E94A3008091040161E080 +:1001E0000E94E20208958091050161E00E94C2022E +:1001F0008091040160E00E94E20280E090E063E010 +:1002000070E00E94A3008091040161E00E94E2027C +:10021000089583EA91E040E052EC61E070E00E94D2 +:10022000BB038091040161E00E94C202809103013E +:1002300061E00E94C2028091050160E00E94C2025A +:100240000E94F30008950F931F93CF93DF93182F0D +:10025000092F8091050160E00E94C202212F302FFA +:10026000C901EC0100E010E021C08091030161E0D0 +:100270000E94E20281E090E00E947A0280910501F2 +:100280000E942F039801220F331F019721F4890147 +:100290000F5F1F4F01C089018091030160E00E9440 +:1002A000E20281E090E00E947A022197D7FFDDCF41 +:1002B00013FD186FC801DF91CF911F910F91089521 +:1002C0008091050161E00E94C2028091040160E01A +:1002D0000E94E2028CE090E063E070E00E94A300E4 +:1002E00083E090E00E9423010895CF92DF92EF9285 +:1002F000FF920F931F930E94DD0068E270E080E0A0 +:1003000090E00E9450020E946001BC0153EAC52E99 +:1003100051E0D52EC6010E94210600E011E0C60181 +:10032000B8010E9438058BE090E00E942301909371 +:100330001101809310018BE090E00E9423019093C3 +:100340001301809312016091100170911101C60197 +:100350000E942106C601B8010E9438056091120171 +:1003600070911301C6010E942106C601B8010E94C6 +:1003700038058091040161E00E94E202609112015F +:1003800070911301709561957F4F882777FD809557 +:10039000982F0E948B077B018C0160911001709156 +:1003A0001101882777FD8095982F0E948B079B016C +:1003B000AC01C801B7010E949D062BED3FE049E466 +:1003C00050E40E94F00620E030E044E353E40E9451 +:1003D00043080E9458079B01AC017093150160937C +:1003E0001401C601B9010E942106C60162E071E054 +:1003F0000E9457051F910F91FF90EF90DF90CF90D3 +:1004000008950E9488020E9409010E947501FDCF93 +:100410001F920F920FB60F9211242F933F938F9339 +:100420009F93AF93BF9380911A0190911B01A0916C +:100430001C01B0911D0130911E010196A11DB11D3D +:10044000232F2D5F2D3720F02D570196A11DB11DB3 +:1004500020931E0180931A0190931B01A0931C010D +:10046000B0931D018091160190911701A091180180 +:10047000B09119010196A11DB11D809316019093B1 +:100480001701A0931801B0931901BF91AF919F91EB +:100490008F913F912F910F900FBE0F901F90189545 +:1004A000EF92FF920F931F937B018C018FB7F8940B +:1004B00040911A0150911B0160911C0170911D0126 +:1004C0008FBF2FB7F89480911A0190911B01A091D2 +:1004D0001C01B0911D012FBF841B950BA60BB70B00 +:1004E000E816F9060A071B0760F71F910F91FF90A6 +:1004F000EF900895019759F0FC01EE0FFF1FEE0FEA +:10050000FF1F32978FB7F8943197F1F78FBF089597 +:10051000789484B5826084BD84B5816084BD85B5DE +:10052000826085BD85B5816085BDEEE6F0E08081A5 +:1005300081608083E1E8F0E0808182608083808157 +:1005400081608083E0E8F0E0808181608083E1EB7E +:10055000F0E0808184608083E0EBF0E08081816066 +:100560008083EAE7F0E0808184608083808182601C +:100570008083808181608083808180688083109205 +:10058000C1000895282F30E0C90189539F4FFC0115 +:1005900094912D543F4FF9018491882391F0E82FD5 +:1005A000F0E0EE0FFF1FEB56FF4FA591B4916623CD +:1005B00029F48C91909589238C9308958C91892BA3 +:1005C0008C930895482F50E0CA0185529F4FFC013B +:1005D0002491CA0189539F4FFC0194914D545F4F60 +:1005E000FA0134913323D1F1222331F1233021F464 +:1005F000809180008F7705C0243031F48091800095 +:100600008F7D8093800018C0213019F484B58F77D6 +:1006100004C0223021F484B58F7D84BD0DC0263006 +:1006200021F48091B0008F7705C0273029F48091A4 +:10063000B0008F7D8093B000E32FF0E0EE0FFF1F3E +:10064000E156FF4FA591B491662329F48C919095C2 +:1006500089238C9308958C91892B8C930895682F0E +:1006600070E0CB0185529F4FFC012491CB0189534F +:100670009F4FFC0144916D547F4FFB01949199234E +:1006800019F420E030E038C0222331F1233021F486 +:10069000809180008F7705C0243031F480918000F4 +:1006A0008F7D8093800018C0213019F484B58F7736 +:1006B00004C0223021F484B58F7D84BD0DC0263066 +:1006C00021F48091B0008F7705C0273029F4809104 +:1006D000B0008F7D8093B000892F90E0880F991F24 +:1006E00087559F4FFC01A591B4918C9120E030E09B +:1006F000842311F021E030E0C90108951F920F9288 +:100700000FB60F9211242F933F934F935F936F93E4 +:100710007F938F939F93AF93BF93EF93FF934091FA +:10072000C600E0919F01F091A001CF01019660E821 +:1007300070E00E94C8089C018091A1019091A201E3 +:100740002817390739F0E15EFE4F40833093A0014E +:1007500020939F01FF91EF91BF91AF919F918F9156 +:100760007F916F915F914F913F912F910F900FBEAD +:100770000F901F9018955F926F927F928F929F9229 +:10078000AF92BF92CF92DF92EF92FF920F931F939F +:10079000CF93DF93EC013A014B01413482E45807D7 +:1007A0008FE0680780E078070CF07FC060E874E8AD +:1007B0008EE190E0A40193010E94FD082150304099 +:1007C00040405040CA01B90122E030E040E050E032 +:1007D0000E94FD0859016A01A601950120953095F6 +:1007E0004095509594E0220F331F441F551F9A9552 +:1007F000D1F760E074E284EF90E00E94FD08CA0146 +:10080000B9012FEF30E040E050E00E94A908A401B8 +:1008100093010E94FD08C90181509F4F18161906C7 +:100820001CF4522E5A9403C055245394521A60E07B +:1008300079E08DE390E0A40193010E94FD0821502E +:10084000304040405040CA01B90122E030E040E071 +:1008500050E00E94FD08209530954095509583E02A +:10086000220F331F441F551F8A95D1F760E074E2B1 +:1008700084EF90E00E94FD08CA01B9012FEF30E03B +:1008800040E050E00E94A908A40193010E94FD08E5 +:10089000C90181509F4F181619061CF4822F8150F0 +:1008A00002C081E0821B851500F5E885F98581E0AD +:1008B00090E00A8802C0880F991F0A94E2F78083AB +:1008C00060E079E08DE390E0A40193010E94FD08CF +:1008D0002150304040405040CA01B90122E030E090 +:1008E00040E050E00E94FD0804C0E885F9851082D0 +:1008F0009501EC81FD813083EE81FF812083EA85C3 +:10090000FB85208141E050E0CA010E8402C0880FBF +:10091000991F0A94E2F7282B2083EA85FB85208122 +:10092000CA010F8402C0880F991F0A94E2F7282B8E +:100930002083EA85FB858081088802C0440F551F0B +:100940000A94E2F7842B8083DF91CF911F910F915E +:10095000FF90EF90DF90CF90BF90AF909F908F90DF +:100960007F906F905F900895FC01A085B1852189EB +:100970008C9190E0022E02C0959587950A94E2F73B +:1009800080FFF6CF0484F585E02D608308958AE02A +:1009900091E09093A4018093A3018FE191E0909363 +:1009A000A6018093A50185EC90E09093A801809327 +:1009B000A70184EC90E09093AA018093A90180ECB8 +:1009C00090E09093AC018093AB0181EC90E0909328 +:1009D000AE018093AD0186EC90E09093B0018093DE +:1009E000AF0184E08093B10183E08093B20187E09E +:1009F0008093B30185E08093B40181E08093B501D9 +:100A000008950F931F93CF93DF938C01EB0109C0DF +:100A10002196D801ED91FC910190F081E02DC80163 +:100A2000099568816623A1F7DF91CF911F910F91FE +:100A30000895EF92FF920F931F93CF93DF938C0152 +:100A40007B01EA010CC0D7016D917D01D801ED91C8 +:100A5000FC910190F081E02DC80109952197209724 +:100A600091F7DF91CF911F910F91FF90EF90089533 +:100A7000DC01ED91FC910280F381E02D0995089550 +:100A80000F931F938C01DC01ED91FC910190F0819B +:100A9000E02D6DE00995D801ED91FC910190F08178 +:100AA000E02DC8016AE009951F910F9108950F93F9 +:100AB0001F938C010E943805C8010E9440051F91B8 +:100AC0000F9108952F923F924F925F926F927F9273 +:100AD0008F929F92AF92BF92CF92DF92EF92FF924E +:100AE0000F931F93DF93CF93CDB7DEB7A0970FB6C9 +:100AF000F894DEBF0FBECDBF1C016A017B0141151A +:100B000051056105710549F4DC01ED91FC910190FD +:100B1000F081E02D60E3099554C0882499245401A4 +:100B2000422E55246624772401E010E00C0F1D1F8F +:100B3000080D191DC701B601A30192010E94DB082F +:100B4000F80160830894811C911CA11CB11CC70191 +:100B5000B601A30192010E94DB08C901DA016C0110 +:100B60007D01C114D104E104F104F1F681E0E82E25 +:100B7000F12CEC0EFD1EE80CF91C3E010894611CE2 +:100B8000711CD501C4010197A109B1096C01C818F4 +:100B9000D90814C0F601EE0DFF1D60816A3010F413 +:100BA000605D01C0695CD101ED91FC910190F08123 +:100BB000E02DC10109950894E108F1086E147F0445 +:100BC00049F7A0960FB6F894DEBF0FBECDBFCF9108 +:100BD000DF911F910F91FF90EF90DF90CF90BF902A +:100BE000AF909F908F907F906F905F904F903F90CD +:100BF0002F900895EF92FF920F931F93CF93DF935F +:100C0000EC017A018B0177FF0FC0E881F981019037 +:100C1000F081E02D6DE2099510950095F094E09437 +:100C2000E11CF11C011D111DCE01B801A7012AE034 +:100C30000E946205DF91CF911F910F91FF90EF907D +:100C40000895AB01662757FD6095762F0E94FA053F +:100C500008955058BB27AA270ED0D4C1C5D130F073 +:100C6000CAD120F031F49F3F11F41EF495C10EF467 +:100C7000E095E7FB8BC1E92FD6D180F3BA17620765 +:100C800073078407950718F071F49EF5EEC10EF412 +:100C9000E0950B2EBA2FA02D0B01B90190010C018C +:100CA000CA01A0011124FF27591B99F0593F50F4A4 +:100CB000503E68F11A16F040A22F232F342F4427FC +:100CC000585FF3CF469537952795A795F0405395F4 +:100CD000C9F77EF41F16BA0B620B730B840BBAF0C4 +:100CE0009150A1F0FF0FBB1F661F771F881FC2F72F +:100CF0000EC0BA0F621F731F841F48F48795779543 +:100D00006795B795F7959E3F08F0B3CF9395880FF9 +:100D100008F09927EE0F97958795089565D158F0BB +:100D200080E891E009F49EEF66D128F040E851E0B8 +:100D300059F45EEF09C030C198C1E92FE07873D152 +:100D400068F3092E052AC1F3261737074807590704 +:100D500038F00E2E07F8E02569F0E025E0640AC0BF +:100D6000EF6307F8009407FADB01B9019D01DC018C +:100D7000CA01AD01EF9343D045D10AD05F9155230D +:100D800031F02BED3FE049E450FD49EC63CF08958D +:100D9000DF93DD27B92FBF7740E85FE3161617060C +:100DA00048075B0710F4D92F67D19F938F937F93E8 +:100DB0006F93CCD1E8E6F0E0F2D024D12F913F91AF +:100DC0004F915F916CD1DD2349F09058A2EA2AED52 +:100DD0003FE049EC5FE3D0785D274DDFDF9112C142 +:100DE0000CD010C108D140F0FFD030F021F45F3FAB +:100DF00019F0CCC051113AC1CFC015D198F3992345 +:100E0000C9F35523B1F3951B550BBB27AA276217CE +:100E10007307840738F09F5F5F4F220F331F441F13 +:100E2000AA1FA9F333D00E2E3AF0E0E830D091504B +:100E30005040E695001CCAF729D0FE2F27D0660F38 +:100E4000771F881FBB1F261737074807AB07B0E877 +:100E500009F0BB0B802DBF01FF2793585F4F2AF08D +:100E60009E3F510568F092C001C15F3FECF3983E90 +:100E7000DCF3869577956795B795F7959F5FC9F7EA +:100E8000880F911D9695879597F90895E1E0660F73 +:100E9000771F881FBB1F621773078407BA0720F0EC +:100EA000621B730B840BBA0BEE1F88F7E095089555 +:100EB00004D06894B111DAC00895BDD088F09F576E +:100EC00090F0B92F9927B751A0F0D1F0660F771F96 +:100ED000881F991F1AF0BA95C9F712C0B13081F076 +:100EE000C4D0B1E00895C1C0672F782F8827B85FBC +:100EF00039F0B93FCCF3869577956795B395D9F7D7 +:100F00003EF490958095709561957F4F8F4F9F4FE0 +:100F10000895E89409C097FB3EF4909580957095EC +:100F200061957F4F8F4F9F4F9923A9F0F92F96E935 +:100F3000BB279395F695879577956795B795F111AA +:100F4000F8CFFAF4BB0F11F460FF1BC06F5F7F4F47 +:100F50008F4F9F4F16C0882311F096E911C0772359 +:100F600021F09EE8872F762F05C0662371F096E862 +:100F7000862F70E060E02AF09A95660F771F881F31 +:100F8000DAF7880F9695879597F9089597F99F67EF +:100F900080E870E060E008959FEF80EC0895DF93B3 +:100FA000CF931F930F93FF92EF92DF927B018C01FF +:100FB000689405C0DA2EEF0172D0FE01E894A59185 +:100FC0002591359145915591AEF3EF0154DEFE0127 +:100FD0009701A801DA9479F7DF90EF90FF900F91D5 +:100FE0001F91CF91DF91089500240A9416161706D9 +:100FF00018060906089500240A941216130614060A +:1010000005060895092E0394000C11F4882352F06C +:10101000BB0F40F4BF2B11F460FF04C06F5F7F4F24 +:101020008F4F9F4F089557FD9058440F551F59F00B +:101030005F3F71F04795880F97FB991F61F09F3FC5 +:1010400079F087950895121613061406551FF2CFEE +:101050004695F1DF08C0161617061806991FF1CF3E +:1010600086957105610508940895E894BB27662765 +:101070007727CB0197F908959B01AC0160E070E000 +:1010800080E89FE3ADCE0BD0BDCFAEDF28F0B3DF5D +:1010900018F0952309F07ACF7FCF1124E7CFC3DF73 +:1010A000A0F3959FD1F3950F50E0551F629FF0017B +:1010B000729FBB27F00DB11D639FAA27F00DB11DD4 +:1010C000AA1F649F6627B00DA11D661F829F22275D +:1010D000B00DA11D621F739FB00DA11D621F839FE4 +:1010E000A00D611D221F749F3327A00D611D231FBA +:1010F000849F600D211D822F762F6A2F11249F5708 +:1011000050408AF0E1F088234AF0EE0FFF1FBB1F2A +:10111000661F771F881F91505040A9F79E3F5105C9 +:1011200070F034CFA3CF5F3FECF3983EDCF38695AD +:1011300077956795B795F795E7959F5FC1F7FE2B74 +:10114000880F911D9695879597F908959B01AC019D +:101150009ACF629FD001739FF001829FE00DF11D35 +:10116000649FE00DF11D929FF00D839FF00D749F21 +:10117000F00D659FF00D9927729FB00DE11DF91FCD +:10118000639FB00DE11DF91FBD01CF01112408952A +:1011900097FB092E07260AD077FD04D049D006D048 +:1011A00000201AF4709561957F4F0895F6F7909599 +:1011B00081959F4F0895A1E21A2EAA1BBB1BFD012A +:1011C0000DC0AA1FBB1FEE1FFF1FA217B307E40726 +:1011D000F50720F0A21BB30BE40BF50B661F771F7E +:1011E000881F991F1A9469F760957095809590955E +:1011F0009B01AC01BD01CF01089597FB092E052687 +:101200000ED057FD04D0D7DF0AD0001C38F450951B +:101210004095309521953F4F4F4F5F4F0895F6F71A +:1012200090958095709561957F4F8F4F9F4F089552 +:10123000AA1BBB1B51E107C0AA1FBB1FA617B707FC +:1012400010F0A61BB70B881F991F5A95A9F7809518 +:101250009095BC01CD010895EE0FFF1F0590F4910C +:08126000E02D0994F894FFCF82 +:1012680020000008090A00000000B404010519055F +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.o new file mode 100644 index 0000000..75d2e80 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/core.a new file mode 100644 index 0000000..adf85b9 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/Lab_Capitulo_4_Item_1_Buzzer.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/Lab_Capitulo_4_Item_1_Buzzer.pde new file mode 100644 index 0000000..34a83aa --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/Lab_Capitulo_4_Item_1_Buzzer.pde @@ -0,0 +1,114 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +//Incluir na solucao +#include + +int pino_leitura = P6; +int limpa = CHAVE; +int pino_escrita = P14; +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + +int speakerPin = 12; + +int length = 15; // the number of notes +char notes[] = "ccggaagffeeddc "; // a space represents a rest +int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 }; +int tempo = 300; + +void playTone(int tone, int duration) { + for (long i = 0; i < duration * 1000L; i += tone * 2) { + digitalWrite(speakerPin, HIGH); + delayMicroseconds(tone); + digitalWrite(speakerPin, LOW); + delayMicroseconds(tone); + } +} + +void playNote(char note, int duration) { + char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' }; + int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 }; + + // play the tone corresponding to the note name + for (int i = 0; i < 8; i++) { + if (names[i] == note) { + playTone(tones[i], duration); + } + } +} + +void setup() { + pinMode(speakerPin, OUTPUT); +} + +void loop() { + for (int i = 0; i < length; i++) { + if (notes[i] == ' ') { + delay(beats[i] * tempo); // rest + } else { + playNote(notes[i], beats[i] * tempo); + } + // pause between notes + delay(tempo / 2); + } +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Debounce/Debounce.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Debounce/Debounce.cpp.o new file mode 100644 index 0000000..9889c84 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Debounce/Debounce.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp new file mode 100644 index 0000000..081e182 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp @@ -0,0 +1,132 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +//Incluir na solucao +#include + +#include "WProgram.h" +void playTone(int tone, int duration); +void playNote(char note, int duration); +void setup(); +void loop(); +int pino_leitura = P6; +int limpa = CHAVE; +int pino_escrita = P14; +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + +int speakerPin = 12; + +int length = 15; // the number of notes +char notes[] = "ccggaagffeeddc "; // a space represents a rest +int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 }; +int tempo = 300; + +void playTone(int tone, int duration) { + for (long i = 0; i < duration * 1000L; i += tone * 2) { + digitalWrite(speakerPin, HIGH); + delayMicroseconds(tone); + digitalWrite(speakerPin, LOW); + delayMicroseconds(tone); + } +} + +void playNote(char note, int duration) { + char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' }; + int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 }; + + // play the tone corresponding to the note name + for (int i = 0; i < 8; i++) { + if (names[i] == note) { + playTone(tones[i], duration); + } + } +} + +void setup() { + pinMode(speakerPin, OUTPUT); +} + +void loop() { + for (int i = 0; i < length; i++) { + if (notes[i] == ' ') { + delay(beats[i] * tempo); // rest + } else { + playNote(notes[i], beats[i] * tempo); + } + // pause between notes + delay(tempo / 2); + } +} + + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.elf new file mode 100644 index 0000000..509c9ba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.hex new file mode 100644 index 0000000..1ad805a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.hex @@ -0,0 +1,99 @@ +:100000000C9461000C947E000C947E000C947E0095 +:100010000C947E000C947E000C947E000C947E0068 +:100020000C947E000C947E000C947E000C947E0058 +:100030000C947E000C947E000C947E000C947E0048 +:100040000C9479010C947E000C947E000C947E003C +:100050000C947E000C947E000C947E000C947E0028 +:100060000C947E000C947E00000000002400270009 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C000000011241FBECFEFD8E0DEBFCDBF11E08E +:1000D000A0E0B1E0E0EDF5E002C005900D92AC3497 +:1000E000B107D9F711E0ACE4B1E001C01D92A5352C +:1000F000B107E1F70E9472010C94E6020C94000033 +:100100008091000161E00E94330208956F927F9216 +:100110008F929F92AF92BF92CF92DF92EF92FF9217 +:100120000F931F93CF93DF93EC01882777FD809582 +:10013000982F28EE33E040E050E00E94A0023B01FF +:100140004C01CE01880F991F5C01CC24B7FCC094F0 +:10015000DC2CEE24FF24870114C08091000161E0B3 +:100160000E945302CE010E94EB018091000160E0E9 +:100170000E945302CE010E94EB01EA0CFB1C0C1DF5 +:100180001D1DE614F704080519053CF3DF91CF9116 +:100190001F910F91FF90EF90DF90CF90BF90AF90A5 +:1001A0009F908F907F906F9008959F92AF92BF9293 +:1001B000CF92DF92EF92FF920F931F93DF93CF9333 +:1001C000CDB7DEB768970FB6F894DEBF0FBECDBFD0 +:1001D000982E5B01DE011196E4E4F1E088E00190E5 +:1001E0000D928150E1F7DE011996E4E3F1E080E140 +:1001F00001900D928150E1F77E010894E11CF11C01 +:100200008E01075F1F4F6801F7018081891531F466 +:10021000F80180819181B5010E9486000894E11C5B +:10022000F11C0E5F1F4FEC14FD0471F768960FB6BA +:10023000F894DEBF0FBECDBFCF91DF911F910F911C +:10024000FF90EF90DF90CF90BF90AF909F90089578 +:100250000F931F93CF93DF9304E111E0C0E0D0E050 +:1002600035C0FE01EC5FFE4F80814091320150911C +:100270003301F80120813181803271F4429FB00155 +:10028000439F700D529F700D1124882777FD809534 +:10029000982F0E94C10109C0429FB001439F700D79 +:1002A000529F700D11240E94D500809132019091CF +:1002B000330162E070E00E94BF02882777FD8095DD +:1002C000982F0E94C10121960E5F1F4F809102015D +:1002D00090910301C817D90724F2DF91CF911F91A4 +:1002E0000F9108950E94F9010E9480000E94280148 +:1002F000FDCF1F920F920FB60F9211242F933F93B1 +:100300008F939F93AF93BF93809150019091510130 +:10031000A0915201B0915301309154010196A11D59 +:10032000B11D232F2D5F2D3720F02D570196A11DD4 +:10033000B11D209354018093500190935101A093DB +:100340005201B093530180914C0190914D01A091C5 +:100350004E01B0914F010196A11DB11D80934C013A +:1003600090934D01A0934E01B0934F01BF91AF9177 +:100370009F918F913F912F910F900FBE0F901F90E3 +:100380001895EF92FF920F931F937B018C018FB70B +:10039000F894409150015091510160915201709137 +:1003A00053018FBF2FB7F894809150019091510164 +:1003B000A0915201B09153012FBF841B950BA60B46 +:1003C000B70BE816F9060A071B0760F71F910F9194 +:1003D000FF90EF900895019759F0FC01EE0FFF1F79 +:1003E000EE0FFF1F32978FB7F8943197F1F78FBF59 +:1003F0000895789484B5826084BD84B5816084BD9D +:1004000085B5826085BD85B5816085BDEEE6F0E08D +:10041000808181608083E1E8F0E080818260808378 +:10042000808181608083E0E8F0E08081816080836A +:10043000E1EBF0E0808184608083E0EBF0E080819C +:1004400081608083EAE7F0E080818460808380813E +:1004500082608083808181608083808180688083E6 +:100460001092C1000895282F30E0C90186569F4F91 +:10047000FC0194912A573F4FF9018491882391F010 +:10048000E82FF0E0EE0FFF1FE859FF4FA591B49160 +:10049000662329F48C91909589238C9308958C91EF +:1004A000892B8C930895482F50E0CA0182559F4FA5 +:1004B000FC012491CA0186569F4FFC0194914A5732 +:1004C0005F4FFA0134913323D1F1222331F12330EC +:1004D00021F4809180008F7705C0243031F4809121 +:1004E00080008F7D8093800018C0213019F484B57E +:1004F0008F7704C0223021F484B58F7D84BD0DC078 +:10050000263021F48091B0008F7705C0273029F480 +:100510008091B0008F7D8093B000E32FF0E0EE0F6C +:10052000FF1FEE58FF4FA591B491662329F48C91DB +:10053000909589238C9308958C91892B8C930895A1 +:10054000629FD001739FF001829FE00DF11D649FB7 +:10055000E00DF11D929FF00D839FF00D749FF00D43 +:10056000659FF00D9927729FB00DE11DF91F639FE4 +:10057000B00DE11DF91FBD01CF011124089597FBB6 +:10058000092E07260AD077FD04D00CD006D0002013 +:100590001AF4709561957F4F0895F6F790958195BF +:1005A0009F4F0895AA1BBB1B51E107C0AA1FBB1F89 +:1005B000A617B70710F0A61BB70B881F991F5A95EF +:1005C000A9F780959095BC01CD010895F894FFCFCF +:1005D0000C000F0063636767616167666665656449 +:1005E000646320000100010001000100010001001E +:1005F00002000100010001000100010001000200F1 +:1006000004002C017B07A406EF059805FB04700489 +:0C061000F603BC03636465666761624327 +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.o new file mode 100644 index 0000000..e6b47e5 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/core.a new file mode 100644 index 0000000..b5bb42d Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/Lab_Capitulo_4_Item_2_Solenoide.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/Lab_Capitulo_4_Item_2_Solenoide.pde new file mode 100644 index 0000000..5498c14 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/Lab_Capitulo_4_Item_2_Solenoide.pde @@ -0,0 +1,102 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + + #define TEMPO_ATIVADO 1000 + +int ja_ativou = 0; +int contando_tempo = 0; +unsigned long inicio = 0; +unsigned long agora = 0; + +void setup () { + + pinMode(CHAVE, INPUT); // configura o pino como entrada + pinMode(Q4, OUTPUT); + pinMode(LED_9, OUTPUT); +} + + +void loop () { + + int leitura = digitalRead(CHAVE); + + if (leitura == LOW && ja_ativou == 0 && contando_tempo == 0) { + digitalWrite(LED_9, HIGH); + digitalWrite(Q4, HIGH); + ja_ativou = 1; + contando_tempo = 1; + inicio = millis(); + //delay (1000); + } else { + if (leitura == HIGH){ + ja_ativou = 0; + } + } + + if (contando_tempo == 1) { + agora = millis(); + if ( (agora - inicio) > TEMPO_ATIVADO ){ + contando_tempo = 0; + digitalWrite(LED_9, LOW); + digitalWrite(Q4, LOW); + } + } +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp new file mode 100644 index 0000000..d730099 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp @@ -0,0 +1,118 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + + #define TEMPO_ATIVADO 1000 + +#include "WProgram.h" +void setup (); +void loop (); +int ja_ativou = 0; +int contando_tempo = 0; +unsigned long inicio = 0; +unsigned long agora = 0; + +void setup () { + + pinMode(CHAVE, INPUT); // configura o pino como entrada + pinMode(Q4, OUTPUT); + pinMode(LED_9, OUTPUT); +} + + +void loop () { + + int leitura = digitalRead(CHAVE); + + if (leitura == LOW && ja_ativou == 0 && contando_tempo == 0) { + digitalWrite(LED_9, HIGH); + digitalWrite(Q4, HIGH); + ja_ativou = 1; + contando_tempo = 1; + inicio = millis(); + //delay (1000); + } else { + if (leitura == HIGH){ + ja_ativou = 0; + } + } + + if (contando_tempo == 1) { + agora = millis(); + if ( (agora - inicio) > TEMPO_ATIVADO ){ + contando_tempo = 0; + digitalWrite(LED_9, LOW); + digitalWrite(Q4, LOW); + } + } +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.elf new file mode 100644 index 0000000..ad5f31d Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.hex new file mode 100644 index 0000000..3b1a4d2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.hex @@ -0,0 +1,74 @@ +:100000000C9461000C947E000C947E000C947E0095 +:100010000C947E000C947E000C947E000C947E0068 +:100020000C947E000C947E000C947E000C947E0058 +:100030000C947E000C947E000C947E000C947E0048 +:100040000C94F8000C947E000C947E000C947E00BE +:100050000C947E000C947E000C947E000C947E0028 +:100060000C947E000C947E00000000002400270009 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C000000011241FBECFEFD8E0DEBFCDBF11E08E +:1000D000A0E0B1E0ECE8F4E002C005900D92A030A1 +:1000E000B107D9F711E0A0E0B1E001C01D92A53140 +:1000F000B107E1F70E94F1000C9444020C94000057 +:1001000080E00E94F5019C01009749F58091000173 +:1001100090910101892B19F58091020190910301C1 +:10012000892B21F58DE061E00E94A80182E161E068 +:100130000E94A80181E090E090930101809300016A +:1001400090930301809302010E9440016093040197 +:1001500070930501809306019093070107C0213039 +:10016000310521F4109201011092000180910201E9 +:1001700090910301019739F50E94400160930801B5 +:100180007093090180930A0190930B01209104015F +:10019000309105014091060150910701621B730BDC +:1001A000840B950B695E73408040904060F0109224 +:1001B0000301109202018DE060E00E94A80182E13B +:1001C00060E00E94A801089580E060E00E9488013C +:1001D00082E161E00E9488018DE061E00E94880177 +:1001E00008950E944E010E94E4000E948000FDCF0D +:1001F0001F920F920FB60F9211242F933F938F935C +:100200009F93AF93BF938091100190911101A091A2 +:100210001201B0911301309114010196A11DB11D7D +:10022000232F2D5F2D3720F02D570196A11DB11DD5 +:10023000209314018093100190931101A093120157 +:10024000B093130180910C0190910D01A0910E01CA +:10025000B0910F010196A11DB11D80930C019093E7 +:100260000D01A0930E01B0930F01BF91AF919F912B +:100270008F913F912F910F900FBE0F901F90189567 +:100280008FB7F89420911001309111014091120123 +:10029000509113018FBFB901CA010895789484B5B4 +:1002A000826084BD84B5816084BD85B5826085BD72 +:1002B00085B5816085BDEEE6F0E080818160808358 +:1002C000E1E8F0E0808182608083808181608083CA +:1002D000E0E8F0E0808181608083E1EBF0E0808104 +:1002E00084608083E0EBF0E0808181608083EAE7D6 +:1002F000F0E080818460808380818260808380815F +:10030000816080838081806880831092C10008951D +:10031000282F30E0C90186569F4FFC0194912A573F +:100320003F4FF9018491882391F0E82FF0E0EE0F20 +:10033000FF1FE859FF4FA591B491662329F48C91D2 +:10034000909589238C9308958C91892B8C93089593 +:10035000482F50E0CA0182559F4FFC012491CA01E9 +:1003600086569F4FFC0194914A575F4FFA01349192 +:100370003323D1F1222331F1233021F48091800005 +:100380008F7705C0243031F4809180008F7D809379 +:10039000800018C0213019F484B58F7704C0223052 +:1003A00021F484B58F7D84BD0DC0263021F4809169 +:1003B000B0008F7705C0273029F48091B0008F7D81 +:1003C0008093B000E32FF0E0EE0FFF1FEE58FF4FD9 +:1003D000A591B491662329F48C91909589238C93EF +:1003E00008958C91892B8C930895682F70E0CB0130 +:1003F00082559F4FFC012491CB0186569F4FFC01F3 +:1004000044916A577F4FFB019491992319F420E09E +:1004100030E038C0222331F1233021F48091800074 +:100420008F7705C0243031F4809180008F7D8093D8 +:10043000800018C0213019F484B58F7704C02230B1 +:1004400021F484B58F7D84BD0DC0263021F48091C8 +:10045000B0008F7705C0273029F48091B0008F7DE0 +:100460008093B000892F90E0880F991F84589F4F88 +:10047000FC01A591B4918C9120E030E0842311F02F +:0C04800021E030E0C9010895F894FFCF9E +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.o new file mode 100644 index 0000000..9618a06 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/core.a new file mode 100644 index 0000000..6e8077a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_5_ServoMotor_2/Lab_Capitulo_4_Item_5_ServoMotor_2.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_5_ServoMotor_2/Lab_Capitulo_4_Item_5_ServoMotor_2.pde new file mode 100644 index 0000000..2968478 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_5_ServoMotor_2/Lab_Capitulo_4_Item_5_ServoMotor_2.pde @@ -0,0 +1,41 @@ +/* +0.5 - 2.5 milisegundos funcionou bem para o servo. +Tente valores diferentes de acordo com o seu servo +*/ +int servoPino = 10; // Pino de controle para o servo1 +int tempoMinimo = 500; // Posição mínima do servomotor +int tempoMaximo = 2500; // Posição máxima do servomotor +int posicao_servo = 0; // posição do servo +int valor_posicao = tempoMinimo; +int i = 0; + +long ultimoControle = 0; // tempo em milisegundos em que ocorreu o último controle +long ultima_atualizacao = 0; + +int intervaloControle = 20; // intervalo de tempo entre os pulsos de controle +int tempo_movimentacao = 500; + +void setup() { + pinMode(servoPino, OUTPUT); + posicao_servo = 0; // Coloca o servo na posicao minima +} + +void loop() { + + if (millis() - ultima_atualizacao >= tempo_movimentacao) { + i+=5; + i = i % 180; + posicao_servo = i; + ultima_atualizacao = millis(); + } + valor_posicao = map(posicao_servo,0, 180, tempoMinimo, tempoMaximo); // mapeia o valor de 0 a 180 + // para a faixa entre tempo Minimo e Maximo +// atualiza o servo se o intervalo de tempo para controle passou + if (millis() - ultimoControle >= intervaloControle) { + digitalWrite(servoPino, HIGH); // Liga o sinal de controle + delayMicroseconds(valor_posicao); // Tempo em que mantem o sinal alto para controlar o servo + digitalWrite(servoPino, LOW); // Desliga o sinal de controle do servo + ultimoControle = millis(); // atualiza o momento do ultimo controle (em milissegundos) + } +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/Lab_Capitulo_4_Item_6_Motor_Passo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/Lab_Capitulo_4_Item_6_Motor_Passo.pde new file mode 100644 index 0000000..3d1eb49 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/Lab_Capitulo_4_Item_6_Motor_Passo.pde @@ -0,0 +1,203 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + + #define TEMPO_ATIVADO 100 + #define NUM_PASSOS 4 +int ja_ativou = 0; +int contando_tempo = 0; +unsigned long inicio = 0; + +int passo = 0; +int anda = 0; + +void setup () { + + pinMode(CHAVE, INPUT); // configura o pino como entrada + pinMode(Q2, OUTPUT); + pinMode(Q3, OUTPUT); + pinMode(Q4, OUTPUT); + pinMode(Q5, OUTPUT); + pinMode(LED_9, OUTPUT); +} + +void escreve_motor (boolean b_q2, boolean b_q3, boolean b_q4, boolean b_q5) { + + digitalWrite(Q2, b_q2); + digitalWrite(Q3, b_q3); + digitalWrite(Q4, b_q4); + digitalWrite(Q5, b_q5); + +} + + +void seleciona_passo (){ + + boolean b_q2, b_q3, b_q4, b_q5; + +/* + black brown orange yellow + A A/ B B/ + Q2 Q3 Q4 Q5 +1 1 0 0 1 +2 1 0 1 0 +3 0 1 1 0 +4 0 1 0 1 + +Q2 = A +Q3 = A/ +Q4 = B +Q5 = B/ + +*/ + switch (passo) { + case 0: + b_q2 = true; + b_q3 = false; + b_q4 = false; + b_q5 = true; + break; + case 1: + b_q2 = true; + b_q3 = false; + b_q4 = true; + b_q5 = false; + break; + case 2: + b_q2 = false; + b_q3 = true; + b_q4 = true; + b_q5 = false; + break; + case 3: + b_q2 = false; + b_q3 = true; + b_q4 = false; + b_q5 = true; + break; + } + escreve_motor (b_q2, b_q3, b_q4, b_q5); +} + +void avanca_passo(){ + + passo++; + passo = passo % NUM_PASSOS; + seleciona_passo(); +} + +void recua_passo(){ + passo--; + if (passo < 0) { + passo = 3; + } + //passo = passo % NUM_PASSOS; + seleciona_passo(); +} + + +void loop () { + + int leitura = digitalRead(CHAVE); + if (leitura == LOW) { + anda = !anda; + delay (300); + } + /*else { + delay (100); + if (leitura == HIGH){ + //anda = 0; + } + }*/ + + if (anda == 1) { + if (inicio == 0) { + inicio = millis(); + } + if ((millis() - inicio) > 100) { + avanca_passo(); + //delay(100); + inicio = millis(); + } + } + + + /*if (leitura == LOW && ja_ativou == 0 && contando_tempo == 0) { + digitalWrite(LED_9, HIGH); + //digitalWrite(Q4, HIGH); + avanca_passo(); + ja_ativou = 1; + contando_tempo = 1; + inicio = millis(); + //delay (1000); + } else { + if (leitura == HIGH){ + ja_ativou = 0; + } + } + + if (contando_tempo == 1) { + if ( (millis() - inicio) > TEMPO_ATIVADO ){ + contando_tempo = 0; + digitalWrite(LED_9, LOW); + //digitalWrite(Q4, LOW); + } + }*/ +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp new file mode 100644 index 0000000..a1abead --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp @@ -0,0 +1,223 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + + #define TEMPO_ATIVADO 100 + #define NUM_PASSOS 4 +#include "WProgram.h" +void setup (); +void escreve_motor (boolean b_q2, boolean b_q3, boolean b_q4, boolean b_q5); +void seleciona_passo (); +void avanca_passo(); +void recua_passo(); +void loop (); +int ja_ativou = 0; +int contando_tempo = 0; +unsigned long inicio = 0; + +int passo = 0; +int anda = 0; + +void setup () { + + pinMode(CHAVE, INPUT); // configura o pino como entrada + pinMode(Q2, OUTPUT); + pinMode(Q3, OUTPUT); + pinMode(Q4, OUTPUT); + pinMode(Q5, OUTPUT); + pinMode(LED_9, OUTPUT); +} + +void escreve_motor (boolean b_q2, boolean b_q3, boolean b_q4, boolean b_q5) { + + digitalWrite(Q2, b_q2); + digitalWrite(Q3, b_q3); + digitalWrite(Q4, b_q4); + digitalWrite(Q5, b_q5); + +} + + +void seleciona_passo (){ + + boolean b_q2, b_q3, b_q4, b_q5; + +/* + black brown orange yellow + A A/ B B/ + Q2 Q3 Q4 Q5 +1 1 0 0 1 +2 1 0 1 0 +3 0 1 1 0 +4 0 1 0 1 + +Q2 = A +Q3 = A/ +Q4 = B +Q5 = B/ + +*/ + switch (passo) { + case 0: + b_q2 = true; + b_q3 = false; + b_q4 = false; + b_q5 = true; + break; + case 1: + b_q2 = true; + b_q3 = false; + b_q4 = true; + b_q5 = false; + break; + case 2: + b_q2 = false; + b_q3 = true; + b_q4 = true; + b_q5 = false; + break; + case 3: + b_q2 = false; + b_q3 = true; + b_q4 = false; + b_q5 = true; + break; + } + escreve_motor (b_q2, b_q3, b_q4, b_q5); +} + +void avanca_passo(){ + + passo++; + passo = passo % NUM_PASSOS; + seleciona_passo(); +} + +void recua_passo(){ + passo--; + if (passo < 0) { + passo = 3; + } + //passo = passo % NUM_PASSOS; + seleciona_passo(); +} + + +void loop () { + + int leitura = digitalRead(CHAVE); + if (leitura == LOW) { + anda = !anda; + delay (300); + } + /*else { + delay (100); + if (leitura == HIGH){ + //anda = 0; + } + }*/ + + if (anda == 1) { + if (inicio == 0) { + inicio = millis(); + } + if ((millis() - inicio) > 100) { + avanca_passo(); + //delay(100); + inicio = millis(); + } + } + + + /*if (leitura == LOW && ja_ativou == 0 && contando_tempo == 0) { + digitalWrite(LED_9, HIGH); + //digitalWrite(Q4, HIGH); + avanca_passo(); + ja_ativou = 1; + contando_tempo = 1; + inicio = millis(); + //delay (1000); + } else { + if (leitura == HIGH){ + ja_ativou = 0; + } + } + + if (contando_tempo == 1) { + if ( (millis() - inicio) > TEMPO_ATIVADO ){ + contando_tempo = 0; + digitalWrite(LED_9, LOW); + //digitalWrite(Q4, LOW); + } + }*/ +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.eep b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.elf b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.elf new file mode 100644 index 0000000..2c040da Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.elf differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.hex b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.hex new file mode 100644 index 0000000..3e4d75c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.hex @@ -0,0 +1,94 @@ +:100000000C9461000C947E000C947E000C947E0095 +:100010000C947E000C947E000C947E000C947E0068 +:100020000C947E000C947E000C947E000C947E0058 +:100030000C947E000C947E000C947E000C947E0048 +:100040000C9446010C947E000C947E000C947E006F +:100050000C947E000C947E000C947E000C947E0028 +:100060000C947E000C947E00000000002400270009 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C000000011241FBECFEFD8E0DEBFCDBF11E08E +:1000D000A0E0B1E0EAECF5E002C005900D92A0309E +:1000E000B107D9F711E0A0E0B1E001C01D92A13144 +:1000F000B107E1F70E943F010C94E3020C94000069 +:10010000FF920F931F93982F162F042FF22E89E042 +:10011000692F0E94200286E0612F0E94200282E166 +:10012000602F0E94200281E16F2D0E9420021F910A +:100130000F91FF9008958091040190910501813005 +:10014000910581F0823091051CF4009741F016C0B2 +:100150008230910551F08330910581F40BC081E02C +:1001600060E00AC081E060E002C080E061E041E060 +:1001700020E004C080E061E040E021E00E948000D7 +:1001800008958091040190910501019664E070E06A +:100190000E94BC0290930501809304010E949B0081 +:1001A000089580E00E946D02892BA1F420E030E0E8 +:1001B0008091060190910701892B11F421E030E034 +:1001C00030930701209306016CE271E080E090E03B +:1001D0000E949C0180910601909107010197A9F569 +:1001E0008091000190910101A0910201B091030161 +:1001F0000097A105B10551F40E948E0160930001A2 +:100200007093010180930201909303010E948E017B +:1002100020910001309101014091020150910301B0 +:10022000621B730B840B950B653671058105910577 +:1002300060F00E94C1000E948E01609300017093E3 +:1002400001018093020190930301089580E060E032 +:100250000E94000289E061E00E94000286E061E005 +:100260000E94000282E161E00E94000281E161E0FF +:100270000E9400028DE061E00E94000208950E9449 +:10028000C6010E9426010E94D100FDCF1F920F924D +:100290000FB60F9211242F933F938F939F93AF9399 +:1002A000BF9380910C0190910D01A0910E01B0912E +:1002B0000F01309110010196A11DB11D232F2D5F5B +:1002C0002D3720F02D570196A11DB11D209310014F +:1002D00080930C0190930D01A0930E01B0930F0138 +:1002E0008091080190910901A0910A01B0910B0140 +:1002F0000196A11DB11D8093080190930901A0935F +:100300000A01B0930B01BF91AF919F918F913F91E3 +:100310002F910F900FBE0F901F9018958FB7F894E4 +:1003200020910C0130910D0140910E0150910F016F +:100330008FBFB901CA010895EF92FF920F931F93E7 +:100340007B018C018FB7F89440910C0150910D0105 +:1003500060910E0170910F018FBF2FB7F8948091BB +:100360000C0190910D01A0910E01B0910F012FBFD2 +:10037000841B950BA60BB70BE816F9060A071B079B +:1003800060F71F910F91FF90EF900895789484B5D6 +:10039000826084BD84B5816084BD85B5826085BD81 +:1003A00085B5816085BDEEE6F0E080818160808367 +:1003B000E1E8F0E0808182608083808181608083D9 +:1003C000E0E8F0E0808181608083E1EBF0E0808113 +:1003D00084608083E0EBF0E0808181608083EAE7E5 +:1003E000F0E080818460808380818260808380816E +:1003F000816080838081806880831092C10008952D +:10040000282F30E0C90186569F4FFC0194912A574E +:100410003F4FF9018491882391F0E82FF0E0EE0F2F +:10042000FF1FE859FF4FA591B491662329F48C91E1 +:10043000909589238C9308958C91892B8C930895A2 +:10044000482F50E0CA0182559F4FFC012491CA01F8 +:1004500086569F4FFC0194914A575F4FFA013491A1 +:100460003323D1F1222331F1233021F48091800014 +:100470008F7705C0243031F4809180008F7D809388 +:10048000800018C0213019F484B58F7704C0223061 +:1004900021F484B58F7D84BD0DC0263021F4809178 +:1004A000B0008F7705C0273029F48091B0008F7D90 +:1004B0008093B000E32FF0E0EE0FFF1FEE58FF4FE8 +:1004C000A591B491662329F48C91909589238C93FE +:1004D00008958C91892B8C930895682F70E0CB013F +:1004E00082559F4FFC012491CB0186569F4FFC0102 +:1004F00044916A577F4FFB019491992319F420E0AE +:1005000030E038C0222331F1233021F48091800083 +:100510008F7705C0243031F4809180008F7D8093E7 +:10052000800018C0213019F484B58F7704C02230C0 +:1005300021F484B58F7D84BD0DC0263021F48091D7 +:10054000B0008F7705C0273029F48091B0008F7DEF +:100550008093B000892F90E0880F991F84589F4F97 +:10056000FC01A591B4918C9120E030E0842311F03E +:1005700021E030E0C901089597FB092E07260AD033 +:1005800077FD04D00CD006D000201AF47095619548 +:100590007F4F0895F6F7909581959F4F0895AA1B78 +:1005A000BB1B51E107C0AA1FBB1FA617B70710F05E +:1005B000A61BB70B881F991F5A95A9F78095909590 +:0A05C000BC01CD010895F894FFCFAF +:00000001FF diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.o new file mode 100644 index 0000000..97acb30 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Print.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/WMath.cpp.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/core.a b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/core.a new file mode 100644 index 0000000..9539deb Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/core.a differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/GarraClient/GarraClient.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/GarraClient/GarraClient.pde new file mode 100644 index 0000000..7b380ce --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/GarraClient/GarraClient.pde @@ -0,0 +1,53 @@ +#include +#include +LiquidCrystal_I2C lcd(0x27,16,2); + +void setup() { + lcd.init(); + lcd.backlight(); + lcd.setCursor(0, 1); + lcd.print("Program-ME v2"); + + Serial.begin(9600); + + Wire.begin(); + delay(1000); + Wire.beginTransmission(65); + Wire.send("1+"); + Wire.endTransmission(); + Wire.beginTransmission(65); + Wire.send("2-"); + Wire.endTransmission(); + + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1."); + Wire.endTransmission(); + Wire.beginTransmission(65); + Wire.send("2."); + Wire.endTransmission(); + + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1-"); + Wire.endTransmission(); + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1."); + Wire.endTransmission(); + delay(2000); + +} + +void loop() { + /*if(Serial.available()>0) Wire.beginTransmission(65); + while(Serial.available()>0) Wire.send(Serial.read()); + Wire.endTransmission(); */ + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/GarraClientLCD/GarraClientLCD.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/GarraClientLCD/GarraClientLCD.pde new file mode 100644 index 0000000..7b380ce --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/GarraClientLCD/GarraClientLCD.pde @@ -0,0 +1,53 @@ +#include +#include +LiquidCrystal_I2C lcd(0x27,16,2); + +void setup() { + lcd.init(); + lcd.backlight(); + lcd.setCursor(0, 1); + lcd.print("Program-ME v2"); + + Serial.begin(9600); + + Wire.begin(); + delay(1000); + Wire.beginTransmission(65); + Wire.send("1+"); + Wire.endTransmission(); + Wire.beginTransmission(65); + Wire.send("2-"); + Wire.endTransmission(); + + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1."); + Wire.endTransmission(); + Wire.beginTransmission(65); + Wire.send("2."); + Wire.endTransmission(); + + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1-"); + Wire.endTransmission(); + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1."); + Wire.endTransmission(); + delay(2000); + +} + +void loop() { + /*if(Serial.available()>0) Wire.beginTransmission(65); + while(Serial.available()>0) Wire.send(Serial.read()); + Wire.endTransmission(); */ + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/GarraCompleta/GarraCompleta.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/GarraCompleta/GarraCompleta.pde new file mode 100644 index 0000000..f8bd96f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/GarraCompleta/GarraCompleta.pde @@ -0,0 +1,52 @@ +#include +#include + +MotorDC motorBase1(5, 6, 7); //branco +MotorDC motorBase2(3, 2, 4); //amarelo +MotorDC motorBase3(11, 12, 13); //azul +MotorDC motorGarra(10, 9, 8); //preto +MotorDC motor= motorBase1; //motor para trabalhar via I2C + +void setup(){ + Serial.begin(9600); + Wire.begin(65); + Wire.onReceive(receiveEvent); + motorBase1.andarParaFrente(255); + delay(2000); + motorBase1.parar(); +} + +void loop() { + Serial.println("nir"); + delay(2000); + +} + +void receiveEvent(int howMany) { + char comando[16]; + int counter=0; + while(Wire.available()>0) + { + comando[counter++]=Wire.receive(); + } + + Serial.print("Evento: "); + Serial.println(comando); + Serial.print("N Motor: "); + Serial.println(comando[0]); + Serial.print("Comando: "); + Serial.println(comando[1]=='+' ? "avançar" : comando[1]=='.' ? "parar" : "retroceder"); + if(comando[0]=='1') motor = motorBase1; + else if(comando[0]=='2') motor = motorBase2; + else if(comando[0]=='3') motor = motorBase3; + else if(comando[0]=='4') motor = motorGarra; + else return; + //Serial.println("agora vai"); + if(comando[1]=='+') motor.andarParaFrente(255); + else if(comando[1]=='-') motor.andarParaTras(255); + else if(comando[1]=='.') motor.parar(); + //delay(500); + //motor.parar(); + +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/RF_ReceptorComandos/RF_ReceptorComandos.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/RF_ReceptorComandos/RF_ReceptorComandos.pde new file mode 100644 index 0000000..4d0fb95 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/RF_ReceptorComandos/RF_ReceptorComandos.pde @@ -0,0 +1,114 @@ +#include +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 + +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 5 + +#define SPEAKER 12 + +#define TX 0 +#define RX 1 + +#define PING 15 + +#define LCD_RS 14 +#define LCD_EN 17 +#define LCD_D4 4 +#define LCD_D5 3 +#define LCD_D6 2 +#define LCD_D7 18 + +#define COMANDO_TAMANHO 16 +char comando[16]; +uint8_t buf[VW_MAX_MESSAGE_LEN]; +uint8_t buflen = VW_MAX_MESSAGE_LEN; +char string[16]; + +LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7); + +const char FRENTE[COMANDO_TAMANHO] = "FRENTE "; +const char RE[COMANDO_TAMANHO] = "RE "; +const char ESQUERDA[COMANDO_TAMANHO] = "ESQUERDA "; +const char DIREITA[COMANDO_TAMANHO] = "DIREITA "; + +void setup() { + setupEngines(); + setupLCD(); + setupReceptorRF(); + pinMode(SPEAKER, OUTPUT); +} +void setupReceptorRF() { + pinMode(RX,INPUT); + vw_set_rx_pin (RX); //Pino que recebe os dados + vw_setup(2000); // Bits per sec + vw_rx_start(); // Start the receiver PLL running +} + +void setupLCD() { + lcd.begin(16, 2); + initLCD(); +} +void initLCD() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("BRoBot:"); + lcd.setCursor(0, 1); + lcd.print("Aguardando...."); +} +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + parar(); +} + +void loop(){ + uint8_t buf[VW_MAX_MESSAGE_LEN]; + uint8_t buflen = VW_MAX_MESSAGE_LEN; + if (vw_get_message(buf, &buflen)) // Non-blocking + { + int i; + lcd.setCursor(0, 1); + lcd.clear(); + limpaComando(); + for (i = 0; i < buflen; i++) + { + comando[i]=buf[i]; + } + lcd.print(comando); + if(strcmp(comando, FRENTE)==0) { + andarFrente(2000,5); + parar(); + } + else if(strcmp(comando, RE)==0) { + andarTraz(2000,5); + parar(); + } + if(strcmp(comando, DIREITA)==0) { + virarDireita(2000,5); + parar(); + } + if(strcmp(comando, ESQUERDA)==0) { + virarEsquerda(2000,5); + parar(); + } + } +} + +void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } +} + +/* +*/ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/RF_ReceptorComandos/Walk.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/RF_ReceptorComandos/Walk.pde new file mode 100644 index 0000000..7e22f25 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/RF_ReceptorComandos/Walk.pde @@ -0,0 +1,58 @@ +int sentido; + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/RF_TransmissorComandos/RF_TransmissorComandos.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/RF_TransmissorComandos/RF_TransmissorComandos.pde new file mode 100644 index 0000000..8ba23ce --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/RF_TransmissorComandos/RF_TransmissorComandos.pde @@ -0,0 +1,22 @@ +#include + +void setup() +{ + Serial.begin(9600); + pinMode(3, OUTPUT); + vw_set_tx_pin(3); + vw_setup(2000); +} + +void loop() +{ + char c[3]; + int counter = 0; + for(int x=0;x<300;x++) { + itoa(x,c,10); + Serial.println(c); + vw_send((uint8_t *) c,strlen(c)); + delay(500); + } +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android/AtualizarDisplay.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android/AtualizarDisplay.ino new file mode 100644 index 0000000..51b700a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android/AtualizarDisplay.ino @@ -0,0 +1,46 @@ +/*void atualizaDisplay() { + lcd.clear(); + + //atualiza temperatura + //lcd.setCursor(col,row); + lcd.setCursor(8,1); + lcd.print(analogRead(SensorTemperatura)/2); + lcd.print("oC"); + + Serial.print("Temperatura= "); + Serial.println(analogRead(SensorTemperatura)/2); + + //atualiza luminosidade + //lcd.setCursor(col,row); + lcd.setCursor(0,1); + lcd.print(map((analogRead(LDR)), 0, 1023, 100,0)); + lcd.print(" %"); + + Serial.print("Luminosidade= "); + Serial.println(map((analogRead(LDR)), 0, 1023, 100,0)); + Serial.println(" "); + + + //lcd.setCursor(col,row); + lcd.setCursor(0,0); + lcd.print(DistanciaEsquerda); + lcd.print(" cms"); + + //atualiza distancia esquerda + Serial.print("Distancia Esquerda= "); + Serial.println(DistanciaEsquerda); + + //atualiza distancia direita + //lcd.setCursor(col,row); + lcd.setCursor(8,0); + lcd.print(DistanciaDireita); + lcd.print(" cms"); + + Serial.print("Distancia Direita= "); + Serial.println(DistanciaDireita); + + + +} +*/ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android/Robo_Android.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android/Robo_Android.ino new file mode 100644 index 0000000..832d25f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android/Robo_Android.ino @@ -0,0 +1,453 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +#define MOTOR1_P 7 +#define MOTOR1_N 8 +#define MOTOR1_PWM 10 +#define MOTOR2_P 12 +#define MOTOR2_N 13 +#define MOTOR2_PWM 11 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int SensorTemperatura = 1 ; +int LDR = 5; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo servoV; +Servo servoH; +int modo = 1; +int sentido; + + +void setup() { + Serial.begin(115200); + //servoH.attach(10); + //servoV.attach(11); + //meetAndroid.setSerial(&Serial); + meetAndroid.registerFunction(dedoDuro, 'A'); + meetAndroid.registerFunction(acelera, 'C'); + meetAndroid.registerFunction(encontraNorte, 'B'); + meetAndroid.registerFunction(andar, 'W'); + meetAndroid.registerFunction(leds, 'L'); + meetAndroid.registerFunction(mudarModo, 'M'); + + /* set up the LCD's number of rows and columns: + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Aguardando");*/ + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + pinMode(LED_RED, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + testeLeds(); + +} + +void loop() { + meetAndroid.receive(); + delay(50); + //meetAndroid.send(analogRead(1)); + //testeLeds(); +} +void leds(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + + if(comando[0]=='R') { + pinMode(LED_RED,INPUT); + int ligado = digitalRead(LED_RED); + pinMode(LED_RED,OUTPUT); + digitalWrite(LED_RED,!ligado); + + } + else if(comando[0]=='G') { + pinMode(LED_GREEN,INPUT); + int ligado = digitalRead(LED_GREEN); + pinMode(LED_GREEN,OUTPUT); + digitalWrite(LED_GREEN,!ligado); + } + else if(comando[0]=='B') { + pinMode(LED_BLUE,INPUT); + int ligado = digitalRead(LED_BLUE); + pinMode(LED_BLUE,OUTPUT); + digitalWrite(LED_BLUE,!ligado); + } + +} +void testeLeds() { + digitalWrite(LED_RED, HIGH); + delay(200); + digitalWrite(LED_RED, LOW); + delay(200); + digitalWrite(LED_BLUE, HIGH); + delay(200); + digitalWrite(LED_BLUE, LOW); + delay(200); + digitalWrite(LED_GREEN, HIGH); + delay(200); + digitalWrite(LED_GREEN, LOW); + delay(200); +} +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + testeLeds(); +} + +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + if(modo==4) { + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarTraz(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarFrente(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + } + else if(modo==6){ + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + delay(200); + } +} + + + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=3) return; + + if(comando[0]=='F') { + dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + dance(); + } +} + +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=1) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + testeLeds(); + } + } +} + +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=2) return; + if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + +/*void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } + }*/ + +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + + 28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ +int led_status=0; +void changeServo(int a) { + + digitalWrite(LED_RED, led_status); + led_status = led_status==0 ? 1 : 0; +} + +void dance() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + /*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android/Wask.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android/Wask.ino new file mode 100644 index 0000000..19a2ed2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android/Wask.ino @@ -0,0 +1,273 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 +long duration, inches, cm; +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServoOK(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n2/AtualizarDisplay.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n2/AtualizarDisplay.pde new file mode 100644 index 0000000..51b700a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n2/AtualizarDisplay.pde @@ -0,0 +1,46 @@ +/*void atualizaDisplay() { + lcd.clear(); + + //atualiza temperatura + //lcd.setCursor(col,row); + lcd.setCursor(8,1); + lcd.print(analogRead(SensorTemperatura)/2); + lcd.print("oC"); + + Serial.print("Temperatura= "); + Serial.println(analogRead(SensorTemperatura)/2); + + //atualiza luminosidade + //lcd.setCursor(col,row); + lcd.setCursor(0,1); + lcd.print(map((analogRead(LDR)), 0, 1023, 100,0)); + lcd.print(" %"); + + Serial.print("Luminosidade= "); + Serial.println(map((analogRead(LDR)), 0, 1023, 100,0)); + Serial.println(" "); + + + //lcd.setCursor(col,row); + lcd.setCursor(0,0); + lcd.print(DistanciaEsquerda); + lcd.print(" cms"); + + //atualiza distancia esquerda + Serial.print("Distancia Esquerda= "); + Serial.println(DistanciaEsquerda); + + //atualiza distancia direita + //lcd.setCursor(col,row); + lcd.setCursor(8,0); + lcd.print(DistanciaDireita); + lcd.print(" cms"); + + Serial.print("Distancia Direita= "); + Serial.println(DistanciaDireita); + + + +} +*/ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n2/Robo_Android_n2.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n2/Robo_Android_n2.pde new file mode 100644 index 0000000..e2ea7c8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n2/Robo_Android_n2.pde @@ -0,0 +1,460 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int SensorTemperatura = 1 ; +int LDR = 5; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo servoV; +Servo servoH; +int modo = 1; +int sentido; + + +void setup() { + Serial.begin(115200); + servoH.attach(10); + servoV.attach(11); + meetAndroid.registerFunction(dedoDuro, 'A'); + meetAndroid.registerFunction(acelera, 'C'); + meetAndroid.registerFunction(encontraNorte, 'B'); + meetAndroid.registerFunction(andar, 'W'); + meetAndroid.registerFunction(leds, 'L'); + meetAndroid.registerFunction(mudarModo, 'M'); + + /* set up the LCD's number of rows and columns: + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Aguardando");*/ + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + pinMode(LED_RED, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + testeLeds(); + andarFrente(2000,5); + parar(); + andarTraz(2000,5); + parar(); + girarNoEixo(2000,5,0); + parar(); + girarNoEixo(2000,5,1); + parar(); + +} + +void loop() { + //meetAndroid.receive(); + //delay(50); + //meetAndroid.send(analogRead(1)); + //testeLeds(); +} +void leds(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + + if(comando[0]=='R') { + pinMode(LED_RED,INPUT); + int ligado = digitalRead(LED_RED); + pinMode(LED_RED,OUTPUT); + digitalWrite(LED_RED,!ligado); + + } + else if(comando[0]=='G') { + pinMode(LED_GREEN,INPUT); + int ligado = digitalRead(LED_GREEN); + pinMode(LED_GREEN,OUTPUT); + digitalWrite(LED_GREEN,!ligado); + } + else if(comando[0]=='B') { + pinMode(LED_BLUE,INPUT); + int ligado = digitalRead(LED_BLUE); + pinMode(LED_BLUE,OUTPUT); + digitalWrite(LED_BLUE,!ligado); + } + +} +void testeLeds() { + digitalWrite(LED_RED, HIGH); + delay(200); + digitalWrite(LED_RED, LOW); + delay(200); + digitalWrite(LED_BLUE, HIGH); + delay(200); + digitalWrite(LED_BLUE, LOW); + delay(200); + digitalWrite(LED_GREEN, HIGH); + delay(200); + digitalWrite(LED_GREEN, LOW); + delay(200); +} +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + testeLeds(); +} + +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + if(modo==4) { + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarTraz(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarFrente(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + } + else if(modo==6){ + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + delay(200); + } +} + + + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=3) return; + + if(comando[0]=='F') { + dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + dance(); + } +} + +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=1) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + testeLeds(); + } + } +} + +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=2) return; + if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + +/*void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } + }*/ + +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + + 28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ +int led_status=0; +void changeServo(int a) { + + digitalWrite(LED_RED, led_status); + led_status = led_status==0 ? 1 : 0; +} + +void dance() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + /*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n2/Wask.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n2/Wask.pde new file mode 100644 index 0000000..19a2ed2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n2/Wask.pde @@ -0,0 +1,273 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 +long duration, inches, cm; +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServoOK(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n3/AtualizarDisplay.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n3/AtualizarDisplay.pde new file mode 100644 index 0000000..51b700a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n3/AtualizarDisplay.pde @@ -0,0 +1,46 @@ +/*void atualizaDisplay() { + lcd.clear(); + + //atualiza temperatura + //lcd.setCursor(col,row); + lcd.setCursor(8,1); + lcd.print(analogRead(SensorTemperatura)/2); + lcd.print("oC"); + + Serial.print("Temperatura= "); + Serial.println(analogRead(SensorTemperatura)/2); + + //atualiza luminosidade + //lcd.setCursor(col,row); + lcd.setCursor(0,1); + lcd.print(map((analogRead(LDR)), 0, 1023, 100,0)); + lcd.print(" %"); + + Serial.print("Luminosidade= "); + Serial.println(map((analogRead(LDR)), 0, 1023, 100,0)); + Serial.println(" "); + + + //lcd.setCursor(col,row); + lcd.setCursor(0,0); + lcd.print(DistanciaEsquerda); + lcd.print(" cms"); + + //atualiza distancia esquerda + Serial.print("Distancia Esquerda= "); + Serial.println(DistanciaEsquerda); + + //atualiza distancia direita + //lcd.setCursor(col,row); + lcd.setCursor(8,0); + lcd.print(DistanciaDireita); + lcd.print(" cms"); + + Serial.print("Distancia Direita= "); + Serial.println(DistanciaDireita); + + + +} +*/ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n3/Robo_Android_n3.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n3/Robo_Android_n3.pde new file mode 100644 index 0000000..eeb151e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n3/Robo_Android_n3.pde @@ -0,0 +1,453 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +#define MOTOR1_P 13 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 +#define MOTOR2_P 7 +#define MOTOR2_N 8 +#define MOTOR2_PWM 5 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int SensorTemperatura = 1 ; +int LDR = 5; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo servoV; +Servo servoH; +int modo = 1; +int sentido; + + +void setup() { + Serial.begin(115200); + servoH.attach(10); + servoV.attach(11); + /* set up the LCD's number of rows and columns: + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Aguardando");*/ + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + pinMode(LED_RED, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + //testeLeds(); + andarFrente(2000,5); + parar(); + andarTraz(2000,5); + parar(); + girarNoEixo(2000,5,0); + parar(); + girarNoEixo(2000,5,1); + parar(); + +} + +void loop() { + //meetAndroid.receive(); + //delay(50); + //meetAndroid.send(analogRead(1)); + //testeLeds(); +} +void leds(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + + if(comando[0]=='R') { + pinMode(LED_RED,INPUT); + int ligado = digitalRead(LED_RED); + pinMode(LED_RED,OUTPUT); + digitalWrite(LED_RED,!ligado); + + } + else if(comando[0]=='G') { + pinMode(LED_GREEN,INPUT); + int ligado = digitalRead(LED_GREEN); + pinMode(LED_GREEN,OUTPUT); + digitalWrite(LED_GREEN,!ligado); + } + else if(comando[0]=='B') { + pinMode(LED_BLUE,INPUT); + int ligado = digitalRead(LED_BLUE); + pinMode(LED_BLUE,OUTPUT); + digitalWrite(LED_BLUE,!ligado); + } + +} +void testeLeds() { + digitalWrite(LED_RED, HIGH); + delay(200); + digitalWrite(LED_RED, LOW); + delay(200); + digitalWrite(LED_BLUE, HIGH); + delay(200); + digitalWrite(LED_BLUE, LOW); + delay(200); + digitalWrite(LED_GREEN, HIGH); + delay(200); + digitalWrite(LED_GREEN, LOW); + delay(200); +} +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + testeLeds(); +} + +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + if(modo==4) { + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarTraz(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarFrente(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + } + else if(modo==6){ + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + delay(200); + } +} + + + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=3) return; + + if(comando[0]=='F') { + dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + dance(); + } +} + +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=1) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + testeLeds(); + } + } +} + +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=2) return; + if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + +/*void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } + }*/ + +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + + 28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ +int led_status=0; +void changeServo(int a) { + + digitalWrite(LED_RED, led_status); + led_status = led_status==0 ? 1 : 0; +} + +void dance() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + /*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n3/Wask.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n3/Wask.pde new file mode 100644 index 0000000..19a2ed2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_n3/Wask.pde @@ -0,0 +1,273 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 +long duration, inches, cm; +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServoOK(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Acelerometro.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Acelerometro.pde new file mode 100644 index 0000000..a578c2c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Acelerometro.pde @@ -0,0 +1,37 @@ +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + if(modo==4) { + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarFrente(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarTraz(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + } +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/AndarSozinho.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/AndarSozinho.pde new file mode 100644 index 0000000..32fa0ba --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/AndarSozinho.pde @@ -0,0 +1,62 @@ +int lerPingComMedia() { + int d1,d2,d3; + d1 = analogRead(1); + delay(5); + d2 = analogRead(1); + delay(5); + d3 = analogRead(1); + delay(5); + return (d1 + d2 + d3)/3; +} + +void lerPing() { + distancia = lerPingComMedia(); +} +void lerPingFull() { + servoH.write(30); + delay(200); + distanciaEsquerda = lerPingComMedia(); + servoH.write(100); + delay(200); + distancia = lerPingComMedia(); + servoH.write(150); + delay(200); + distanciaDireita = lerPingComMedia(); + servoH.write(85); +} + +void andarSozinho() { + lerPing(); + + while(distancia>25) { + andarFrente(100,3); + lerPing(); + if(modo!=6) return; + } + while(distancia>15 && distancia<25) { + if(modo!=6) return; + parar(); + delay(200); + lerPingFull(); + if(distanciaEsquerda>distancia && distanciaEsquerda>distanciaDireita) { + girarNoEixo(300,2,1); + } + if(distanciaDireita>distancia && distanciaDireita>distanciaEsquerda) { + girarNoEixo(300,2,0); + } + lerPing(); + if(modo!=6) return; + } + while(distancia>5 && distancia<15) { + parar(); + andarTraz(500,2); + girarNoEixo(500,2, random(10)%2==0); + lerPing(); + if(modo!=6) return; + } + +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Bussola.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Bussola.pde new file mode 100644 index 0000000..8d02c58 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Bussola.pde @@ -0,0 +1,27 @@ +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=2) return; + if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Dance.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Dance.pde new file mode 100644 index 0000000..4afc6d9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Dance.pde @@ -0,0 +1,171 @@ + +void dance() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + /*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/DedoDuro.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/DedoDuro.pde new file mode 100644 index 0000000..8bdb320 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/DedoDuro.pde @@ -0,0 +1,16 @@ +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=1) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + testeLeds(); + } + } +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Leds.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Leds.pde new file mode 100644 index 0000000..3b723d9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Leds.pde @@ -0,0 +1,42 @@ +void leds(byte flag, byte numOfValues) { + if(modo!=5) return; + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + + if(comando[0]=='R') { + pinMode(LED_RED,INPUT); + int ligado = digitalRead(LED_RED); + pinMode(LED_RED,OUTPUT); + digitalWrite(LED_RED,!ligado); + + } + else if(comando[0]=='G') { + pinMode(LED_GREEN,INPUT); + int ligado = digitalRead(LED_GREEN); + pinMode(LED_GREEN,OUTPUT); + digitalWrite(LED_GREEN,!ligado); + } + else if(comando[0]=='B') { + pinMode(LED_BLUE,INPUT); + int ligado = digitalRead(LED_BLUE); + pinMode(LED_BLUE,OUTPUT); + digitalWrite(LED_BLUE,!ligado); + } + +} +void testeLeds() { + digitalWrite(LED_RED, HIGH); + delay(200); + digitalWrite(LED_RED, LOW); + delay(200); + digitalWrite(LED_BLUE, HIGH); + delay(200); + digitalWrite(LED_BLUE, LOW); + delay(200); + digitalWrite(LED_GREEN, HIGH); + delay(200); + digitalWrite(LED_GREEN, LOW); + delay(200); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Robo_Android_v2.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Robo_Android_v2.pde new file mode 100644 index 0000000..775fb28 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Robo_Android_v2.pde @@ -0,0 +1,114 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int SensorTemperatura = 1 ; +int LDR = 5; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long distanciaEsquerda; +long distanciaDireita; +long distancia; +Servo servoV; +Servo servoH; +int modo = 1; +int sentido; + +void setup() { + Serial.begin(115200); + servoH.attach(10); + servoV.attach(11); + meetAndroid.setSerial(&Serial); + meetAndroid.registerFunction(dedoDuro, 'A'); + meetAndroid.registerFunction(acelera, 'C'); + meetAndroid.registerFunction(encontraNorte, 'B'); + meetAndroid.registerFunction(andar, 'W'); + meetAndroid.registerFunction(leds, 'L'); + meetAndroid.registerFunction(mudarModo, 'M'); + + /* set up the LCD's number of rows and columns: + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Aguardando");*/ + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + pinMode(LED_RED, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + testeLeds(); + +} + +void loop() { + meetAndroid.receive(); + delay(50); + if(modo==6) andarSozinho(); + //meetAndroid.send(analogRead(1)); + //testeLeds(); +} + +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + // define an array with the appropriate size which will store the string + char comando[length]; + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + testeLeds(); +} + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=3) return; + + if(comando[0]=='F') { + dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + dance(); + } +} + + +int led_status=0; +void changeServo(int a) { + + digitalWrite(LED_RED, led_status); + led_status = led_status==0 ? 1 : 0; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Walk.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Walk.pde new file mode 100644 index 0000000..7c7aa77 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Android_v2/Walk.pde @@ -0,0 +1,259 @@ +long duration, inches, cm; +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServoOK(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Globalcode/AtualizarDisplay.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Globalcode/AtualizarDisplay.pde new file mode 100644 index 0000000..2d2d3b3 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Globalcode/AtualizarDisplay.pde @@ -0,0 +1,46 @@ +void atualizaDisplay() { + lcd.clear(); + + //atualiza temperatura + //lcd.setCursor(col,row); + lcd.setCursor(8,1); + lcd.print(analogRead(SensorTemperatura)/2); + lcd.print("oC"); + + Serial.print("Temperatura= "); + Serial.println(analogRead(SensorTemperatura)/2); + + //atualiza luminosidade + //lcd.setCursor(col,row); + lcd.setCursor(0,1); + lcd.print(map((analogRead(LDR)), 0, 1023, 100,0)); + lcd.print(" %"); + + Serial.print("Luminosidade= "); + Serial.println(map((analogRead(LDR)), 0, 1023, 100,0)); + Serial.println(" "); + + + //lcd.setCursor(col,row); + lcd.setCursor(0,0); + lcd.print(DistanciaEsquerda); + lcd.print(" cms"); + + //atualiza distancia esquerda + Serial.print("Distancia Esquerda= "); + Serial.println(DistanciaEsquerda); + + //atualiza distancia direita + //lcd.setCursor(col,row); + lcd.setCursor(8,0); + lcd.print(DistanciaDireita); + lcd.print(" cms"); + + Serial.print("Distancia Direita= "); + Serial.println(DistanciaDireita); + + + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Globalcode/LerDistancias.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Globalcode/LerDistancias.pde new file mode 100644 index 0000000..c7ae0e5 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Globalcode/LerDistancias.pde @@ -0,0 +1,31 @@ +void LerDistancias ( ){ + //posiciona cursor para leitura esquerda + ServoV.write(135); + delay(150); // waits 15ms for the servo to reach the position + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + long duration = pulseIn(PING_PIN, HIGH); + DistanciaEsquerda = duration / 29 / 2; + + + //posiciona cursor para leitura direita + ServoV.write(45); + delay(150); // waits 15ms for the servo to reach the position + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + DistanciaDireita = duration / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Globalcode/Movimentos.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Globalcode/Movimentos.pde new file mode 100644 index 0000000..c3dfe4e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Globalcode/Movimentos.pde @@ -0,0 +1,62 @@ +void girarNoEixo(int intensidade) { + long sentido1 = random(0,2); + if (sentido1 < 1){ + sentido1=0; + } + else { + sentido1=1; + } + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + +void andarTraz(int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + +void virarEsquerda(int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + +void virarDireita(int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Globalcode/Robo_Globalcode.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Globalcode/Robo_Globalcode.pde new file mode 100644 index 0000000..849fd72 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Globalcode/Robo_Globalcode.pde @@ -0,0 +1,65 @@ +#include +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 5 +#define PING_PIN 16 +int SensorTemperatura = 1 ; +int LDR = 5; + +//LiquidCrystal lcd(RS, EN, D4, D5, D6, D7); +LiquidCrystal lcd(14, 17, 4, 3, 2, 18); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo ServoV; +Servo ServoH; + +int sentido; + +void setup() { + Serial.begin(9600); + + // set up the LCD's number of rows and columns: + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void loop() { + LerDistancias( ); + + if (DistanciaEsquerda > 40 && DistanciaDireita > 40) { + andarFrente(2); + } + + if (DistanciaEsquerda <= 40 && DistanciaDireita > 40) { + virarDireita(2); + } + + if (DistanciaEsquerda > 40 && DistanciaDireita <= 40) { + virarEsquerda(2); + } + + if (DistanciaEsquerda <= 40 && DistanciaDireita <= 40) { + parar(); + girarNoEixo(2); + } + + atualizaDisplay(); + delay (100); + +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Me_Tamiya/Movimentos.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Me_Tamiya/Movimentos.pde new file mode 100644 index 0000000..6833127 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Me_Tamiya/Movimentos.pde @@ -0,0 +1,56 @@ +void girarNoEixo(int intensidade, long sentido1) { + + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + +void andarTraz(int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + +void virarEsquerda(int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + +void virarDireita(int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Me_Tamiya/Robo_Me_Tamiya.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Me_Tamiya/Robo_Me_Tamiya.pde new file mode 100644 index 0000000..92ab5c7 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Robo_Me_Tamiya/Robo_Me_Tamiya.pde @@ -0,0 +1,109 @@ +#include +#include + +#define MOTOR1_P 10 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 5 +#define PING_PIN 14 +int SensorTemperatura = 1 ; +int LDR = 5; + + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo ServoV; +Servo ServoH; + +int sentido; + +void setup() { + Serial.begin(9600); + + // set up the LCD's number of rows and columns: + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void lerPing() { + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + long duration = pulseIn(PING_PIN, HIGH); + + distancia= duration / 29 / 2; + Serial.print("Distancia: "); + Serial.println(distancia); + +} + +void loop() { + lerPing(); + + while(distancia>25) { + andarFrente(5); + delay(50); + lerPing(); + } + int delaying = 350; + while(distancia>15 && distancia<25) { + long d1 = distancia; + girarNoEixo(5,0); + delay(delaying); + lerPing(); + long d2 = distancia; + girarNoEixo(5,1); + delay(delaying*2); + parar(); + lerPing(); + long d3 = distancia; + + //voltando posiço original + girarNoEixo(5,0); + delay(delaying); + parar(); + //tomando decisao.. + + if(d1>d2 && d1>d3) { + //nem para um lado nem para outro funcionou... + delaying+=100; + } + else { + if(d2>d3) { + girarNoEixo(5,0); + delay(delaying); + } + else { + girarNoEixo(5,1); + delay(delaying); + } + andarFrente(5); + delay(250); + } + } + while(distancia>5 && distancia<15) { + girarNoEixo(5, random(10)%2==0); + delay(300 + random(200,400)); + lerPing(); + } +} + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/ServoRobot/ServoRobot.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/ServoRobot/ServoRobot.pde new file mode 100644 index 0000000..8c941f9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/ServoRobot/ServoRobot.pde @@ -0,0 +1,42 @@ +// Controlling a servo position using a potentiometer (variable resistor) +// by Michal Rinott + +#include + +Servo myservo; // create servo object to control a servo +Servo myservo1; // create servo object to control a servo + +int potpin = 1; // analog pin used to connect the potentiometer +int val; // variable to read the value from the analog pin + +void setup() +{ + Serial.begin(9600); + myservo.attach(10); // attaches the servo on pin 9 to the servo object + myservo1.attach(11); // attaches the servo on pin 9 to the servo object +} + +void loop() +{ + if(Serial.available()>0) { + + while(Serial.available()>0) { + + int dado = int(Serial.read()); + Serial.println(dado,DEC); + myservo.write(dado); + int dado1 = int(Serial.read()); + Serial.println(dado1,DEC); + myservo1.write(dado1); + + } + } + + val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) + //Serial.println(val); + val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) + //myservo.write(analogRead(1)/4); // sets the servo position according to the scaled value + //myservo1.write(analogRead(2)/4); // sets the servo position according to the scaled value + delay(10); // waits for the servo to get there +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Shield_BRoBot/Demo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Shield_BRoBot/Demo.pde new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Shield_BRoBot/Demo.pde @@ -0,0 +1 @@ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Shield_BRoBot/Shield_BRoBot.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Shield_BRoBot/Shield_BRoBot.pde new file mode 100644 index 0000000..8dbe512 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Shield_BRoBot/Shield_BRoBot.pde @@ -0,0 +1,167 @@ +#include +#include +//#include +#define MOTOR1_P 11 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 + +#define MOTOR2_P 7 +#define MOTOR2_N 8 +#define MOTOR2_PWM 6 +// LCD 0, 1 ,14, 17, 18, 19 +// Trasmissor 12 +// Receptor 13 +// Motor 4, 5, 6, 7, 8 e 9 + +// Em uso 0 1 4 5 6 7 8 9 12 13 14 17 18 19 +// Livre 2 3 10 11 15 16 +int valor_anterior = -1;ds +int erro =0; +int recebidos = 0; +int i = 0; +char comando[16]; + + +uint8_t buf[VW_MAX_MESSAGE_LEN]; +uint8_t buflen = VW_MAX_MESSAGE_LEN; +char string[16]; + +LiquidCrystal lcd(14, 17, 4, 3, 2, 18); + +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=0; +//Servo myservo10; // create servo object to control a servo +#define COMANDO_TAMANHO 16 +const char FRENTE[COMANDO_TAMANHO] = "FRENTE "; +const char RE[COMANDO_TAMANHO] = "RE "; +const char ESQUERDA[COMANDO_TAMANHO] = "ESQUERDA "; +const char DIREITA[COMANDO_TAMANHO] = "DIREITA "; + +void setup() { + + setupEngines(); + //setupReceptorRF(); + setupLCD(); + + //myservo10.attach(10); // attaches the servo on pin 10 to the servo object + Serial.begin(115200); + + +} +void setupReceptorRF() { + + pinMode(3, OUTPUT); + //pinMode(11, INPUT); + digitalWrite(3, LOW); + + // Initialise the IO and ISR + + //Configura o Receptor + vw_set_rx_pin (3); //Pino que recebe os dados + vw_setup(2000); // Bits per sec + vw_rx_start(); // Start the receiver PLL running + + //Configura o Transmissor + //vw_set_tx_pin(12); //Pino de transmissao de dados + //vw_setup(2000); // Bits per sec + +} +void setupLCD() { + // set up the LCD's number of rows and columns: + lcd.begin(16, 2); + initLCD(); +} +void initLCD() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("BRoBot:"); + lcd.setCursor(0, 1); + lcd.print("Aguardando...."); +} +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + //andarFrente(2000,3); + parar(); +} + +void loop(){ + + uint8_t buf[VW_MAX_MESSAGE_LEN]; + uint8_t buflen = VW_MAX_MESSAGE_LEN; + int ii; + for(ii=0;ii0) { + while(Serial.available()>0) { + string[ii]=Serial.read(); + delay(20); + ii++; + } + lcd.clear(); + lcd.print(string); + delay(2000); + initLCD(); + + } + + + /*if (vw_get_message(buf, &buflen)) // Non-blocking + { + int i; + lcd.setCursor(0, 1); + lcd.clear(); + limpaComando(); + for (i = 0; i < buflen; i++) + { + comando[i]=buf[i]; + } + lcd.print(comando); + Serial.println(comando); + + if(strcmp(comando, FRENTE)==0) { + lcd.setCursor(0,2); + lcd.print("andando..."); + + andarFrente(2000,5); + parar(); + } + + else if(strcmp(comando, RE)==0) { + andarTraz(2000,5); + parar(); + } + if(strcmp(comando, DIREITA)==0) { + virarDireita(2000,5); + parar(); + } + if(strcmp(comando, ESQUERDA)==0) { + virarEsquerda(2000,5); + parar(); + } + + }*/ +} +void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } +} + + + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Shield_BRoBot/Walk.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Shield_BRoBot/Walk.pde new file mode 100644 index 0000000..9819fc1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Shield_BRoBot/Walk.pde @@ -0,0 +1,147 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +/*void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +}*/ + +/*void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} */ + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +/*void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} +*/ + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + + +/*void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +}*/ + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Shield_TransmissorRF/Shield_TransmissorRF.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Shield_TransmissorRF/Shield_TransmissorRF.pde new file mode 100644 index 0000000..8ba23ce --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/Shield_TransmissorRF/Shield_TransmissorRF.pde @@ -0,0 +1,22 @@ +#include + +void setup() +{ + Serial.begin(9600); + pinMode(3, OUTPUT); + vw_set_tx_pin(3); + vw_setup(2000); +} + +void loop() +{ + char c[3]; + int counter = 0; + for(int x=0;x<300;x++) { + itoa(x,c,10); + Serial.println(c); + vw_send((uint8_t *) c,strlen(c)); + delay(500); + } +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/SunSpotBot/SunSpot.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/SunSpotBot/SunSpot.pde new file mode 100644 index 0000000..9481ff8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/SunSpotBot/SunSpot.pde @@ -0,0 +1,110 @@ +#define SUN_SPOT 4 +#define SUN_SPOT_ACK 11 +#define SUN_SPOT_INTERRUPT 0 //PORTA digital 2 + +volatile int data; +volatile boolean bit_array[16]; +volatile int contador; +int x; +int y; + +void setupSunSpot() { + attachInterrupt(0, receiveSunSpot, RISING); + pinMode(SUN_SPOT,INPUT); + pinMode(SUN_SPOT_ACK,OUTPUT); +} + +void SunSpot() { + if(x==0 && y==0) { + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + return; + } + if(y>0) sentido = 0; //Para FRENTE + else if(y<0) sentido = 1;// Para Traz + //Configurando o sentido do trem.. quero dizer do robot + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + if(y!=0 && x!=0) { //Curva frente ou traz... + int coeficientePotencia = map(x<0 ? x*-1 : x,0,30,0,255); + analogWrite(MOTOR1_PWM, x< 0 ? coeficientePotencia : coeficientePotencia/2); + analogWrite(MOTOR2_PWM, x< 0 ? coeficientePotencia/2 : coeficientePotencia); + } + else { //reto + analogWrite(MOTOR1_PWM,map(y<0 ? y*-1 : y,0,30,100,200)); + analogWrite(MOTOR2_PWM,map(y<0 ? y*-1 : y,0,30,100,200)); + } + //Girando no eixo + if(y==0 && x!=0) { + sentido = x<0; + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_N,sentido); + if(x>0) { + Serial.print("Girando x>0"); + Serial.println(map(x,0,30,40,255)); + analogWrite(MOTOR1_PWM, map(x,0,30,40,255) ); + analogWrite(MOTOR2_PWM , map(x,0,30,40,255) ); + } + else { + Serial.print("Girando <0"); + Serial.println(map(x>0 ? x : x*-1,0,30,40,255)); + + analogWrite(MOTOR2_PWM, map(x*-1,0,30,40,255) ); + analogWrite(MOTOR1_PWM, map(x*-1,0,30,40,255) ); + } + } + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + delay(200); +} + +void receiveSunSpot() { + digitalWrite(SUN_SPOT_ACK,LOW); + bit_array[contador++]=digitalRead(SUN_SPOT); + digitalWrite(SUN_SPOT_ACK,HIGH); + + if(contador==16) { + Serial.println("Chegou Novos 2 bytes"); + contador=0; + x = BtoI(0,7,bit_array); + + y = BtoI(8,15,bit_array); + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + for(int clean=0;clean<16;clean++) bit_array[clean]=false; + + } +} + +int BtoI(int start,int end, volatile boolean bits[]){ + boolean negative=bits[start]; + start++; + unsigned long integer=0; + unsigned long mask=1; + int r; + for (int i = end; i >= start; i--) { + if(negative) { + if (!bits[i]) integer |= mask; + } + else { + if (bits[i]) integer |= mask; + } + mask = mask << 1; + } + r = (int) integer; + if(negative) r= ~r; + return r; +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/SunSpotBot/SunSpotBot.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/SunSpotBot/SunSpotBot.pde new file mode 100644 index 0000000..a7941bd --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/SunSpotBot/SunSpotBot.pde @@ -0,0 +1,52 @@ +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int sentido = 0; + +void setup() { + Serial.begin(9600); + Serial.println("Setup feito"); + + setupSunSpot(); + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + +} + +void loop() { + //Serial.println("aaa"); + SunSpot(); + //Serial.println("BBB"); + //meetAndroid.receive(); + //meetAndroid.send(analogRead(1)); + //testeLeds(); + /*andarFrente(1500,3); + parar(); + delay(1500); + andarTraz(1500,3); + parar(); + delay(1500); + girarNoEixo(1500,3,0); + parar(); + delay(1500); + girarNoEixo(1500,3,1); + parar(); + delay(1500); + */ + +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/SunSpotBot/Walk.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/SunSpotBot/Walk.pde new file mode 100644 index 0000000..75a8331 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/SunSpotBot/Walk.pde @@ -0,0 +1,88 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca/Demo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca/Demo.pde new file mode 100644 index 0000000..541d53a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca/Demo.pde @@ -0,0 +1,194 @@ +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca/SunSpot.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca/SunSpot.pde new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca/SunSpot.pde @@ -0,0 +1 @@ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca/Walk.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca/Walk.pde new file mode 100644 index 0000000..6d49a4a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca/Walk.pde @@ -0,0 +1,63 @@ +int sentido=0; + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca/br1_danca.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca/br1_danca.pde new file mode 100644 index 0000000..43ab1e6 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca/br1_danca.pde @@ -0,0 +1,33 @@ +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 + +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 5 +#define SERVO_1 11 + +Servo myservo10; // create servo object to control a servo + + +void setup() { + setupEngines(); + myservo10.attach(SERVO_1); // attaches the servo on pin 10 to the servo object + Serial.begin(9600); +} + +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void loop(){ + Demo(); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca_ok/Demo.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca_ok/Demo.pde new file mode 100644 index 0000000..541d53a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca_ok/Demo.pde @@ -0,0 +1,194 @@ +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca_ok/SunSpot.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca_ok/SunSpot.pde new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca_ok/SunSpot.pde @@ -0,0 +1 @@ + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca_ok/Walk.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca_ok/Walk.pde new file mode 100644 index 0000000..6d49a4a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca_ok/Walk.pde @@ -0,0 +1,63 @@ +int sentido=0; + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca_ok/br1_danca_ok.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca_ok/br1_danca_ok.pde new file mode 100644 index 0000000..8254f4d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br1_danca_ok/br1_danca_ok.pde @@ -0,0 +1,36 @@ +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 +#define SERVO_1 11 + +Servo myservo10; // create servo object to control a servo + + +void setup() { + setupEngines(); + myservo10.attach(SERVO_1); // attaches the servo on pin 10 to the servo object + Serial.begin(9600); +} + +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void loop(){ + Demo(); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_android/Android.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_android/Android.pde new file mode 100644 index 0000000..38464f1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_android/Android.pde @@ -0,0 +1,105 @@ +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + if(modo!=ACELEROMETRO) return; + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarTraz(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarFrente(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + +} + + + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=ANDAR) return; + + if(comando[0]=='F') { + //dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + //dance(); + } +} + +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=DEDO_DURO) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + //testeLeds(); + } + } +} + +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=ENCONTRAR_NORTE) return; + //if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + //else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_android/Motores.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_android/Motores.pde new file mode 100644 index 0000000..30330d3 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_android/Motores.pde @@ -0,0 +1,95 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + + +int sentido=0; +void setupMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_android/SeguidorLinha.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_android/SeguidorLinha.pde new file mode 100644 index 0000000..1677f85 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_android/SeguidorLinha.pde @@ -0,0 +1,135 @@ +#include + +#define NUM_SENSORS 3 // number of sensors used +#define TIMEOUT 2500 // waits for 2500 us for sensor outputs to go low +#define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2 +unsigned int last_proportional = 0; +long integral = 0; + +// sensores 1 a 5 estao conectados nas portas digitais 5, 9, 2, 3 e 4, respectivamente +//PololuQTRSensorsRC qtrrc((unsigned char[]) {5, 9, 2, 3, 4}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); +PololuQTRSensorsRC qtrrc((unsigned char[]) {5, 9, 2}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); +unsigned int sensorValues[NUM_SENSORS]; + + +void calibrarSensorDeLinha() { + int i; + // Auto-calibration: turn right and left while calibrating the sensors. + for (i = 0; i < 155; i++) { // make the calibration take about 10 seconds + if (i < 40 || i > 110) + setSpeeds(50, -50); + else + setSpeeds(-50, 50); + qtrrc.calibrate(); // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call) + } + setSpeeds(0, 0); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMinimumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMaximumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + //Serial.println(); + calibrado=true; +} + +void seguirLinha() { + if(!calibrado) calibrarSensorDeLinha(); + if(modo!=SEGUIR_LINHA) return; + unsigned int position = qtrrc.readLine(sensorValues); // Get the position of the line. + int proportional = (int)position - 2000;// The "proportional" term should be 0 when we are on the line. + int derivative = proportional - last_proportional; // Compute the derivative (change) of the position. + integral += proportional; // Compute the integral (sum) of the position. + last_proportional = proportional; // Remember the last position. + + // Compute the difference between the two motor power settings, + // m1 - m2. If this is a positive number the robot will turn + // to the right. If it is a negative number, the robot will + // turn to the left, and the magnitude of the number determines + // the sharpness of the turn. You can adjust the constants by which + // the proportional, integral, and derivative terms are multiplied to + // improve performance. + int power_difference = proportional/20 + integral/10000 + derivative*3/2; + + // Compute the actual motor settings. We never set either motor + // to a negative value. + const int maximum = 60; + if (power_difference > maximum) + power_difference = maximum; + if (power_difference < -maximum) + power_difference = -maximum; + // Serial.print("power diference: "); + // Serial.println(power_difference); + //setSpeeds(70,70); + if (power_difference < 0){ + setSpeeds(maximum + power_difference, maximum); + // Serial.print("motores: "); + // Serial.println(maximum + power_difference); + // Serial.print(" : "); + // Serial.println(maximum); + } + else{ + setSpeeds(maximum, maximum - power_difference); + // Serial.print("motores: "); + // Serial.print(maximum); + // Serial.print(" : "); + // Serial.println(maximum - power_difference); + // Serial.println(" "); + } + if(DEBUG_LIGADO) { + Serial.print("position: "); + Serial.println(position); + delay(10); + Serial.println("sensor values: "); + for(int x=0;x 0){ + digitalWrite(MOTOR1_control_A,HIGH); + digitalWrite(MOTOR1_control_B,LOW); + } + else { + digitalWrite(MOTOR1_control_A,LOW); + digitalWrite(MOTOR1_control_B,HIGH); + } + if (M2 > 0){ + digitalWrite(MOTOR2_control_A,HIGH); + digitalWrite(MOTOR2_control_B,LOW); + } + else { + digitalWrite(MOTOR2_control_A,LOW); + digitalWrite(MOTOR2_control_B,HIGH); + } + analogWrite(MOTOR1_PWM,abs(M1) ); + analogWrite(MOTOR2_PWM,abs(M2) ); +} + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_android/br2_android.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_android/br2_android.pde new file mode 100644 index 0000000..49642b2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_android/br2_android.pde @@ -0,0 +1,125 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +boolean DEBUG_LIGADO = false; + +int modo=1; +boolean calibrado = false; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; + +Servo servoV; +Servo servoH; + +#define IDLE 0 +#define DEDO_DURO 1 +#define ENCONTRAR_NORTE 2 +#define ANDAR 3 +#define ACELEROMETRO 4 +#define SEGUIR_LINHA 5 + +void setup(){ + setupMotor(); + delay(500); + Serial.begin(115200); + meetAndroid.setSerial(&Serial); + meetAndroid.registerFunction(dedoDuro, 'A'); + meetAndroid.registerFunction(encontraNorte, 'B'); + meetAndroid.registerFunction(acelera, 'C'); + meetAndroid.registerFunction(mudarModo, 'M'); + meetAndroid.registerFunction(andar, 'W'); + modo=IDLE; +} + +void loop(){ + meetAndroid.receive(); + delay(50); + if(modo==SEGUIR_LINHA) seguirLinha2(); + if(modo==IDLE) modoZero(); + +} +int direita; +int centro; +int esquerda; + +void ler() { + direita = RCtime(5); + centro = RCtime(9); + esquerda = RCtime(2); +} +void seguirLinha2() { + andarFrente(0,2); + ler(); + while(esquerda<400 && direita<400 && centro>400) { + setSpeeds(60,60); + ler(); + } + while(esquerda>400 && direita<400 && centro<400) { //esquerda na faixa + parar(); + girarNoEixo(200, 1, 0); + parar(); + ler(); + } + while(direita>400 && esquerda<400 && centro<400) { + parar(); + girarNoEixo(200, 1, 1); + parar(); + ler(); + } + while(direita<400 && esquerda<400 && centro<400) { + parar(); + girarNoEixo(200, 1, 1); + parar(); + ler(); + } + while(direita>400 && esquerda>400 && centro>400) { + parar(); + girarNoEixo(200, 1, 1); + parar(); + ler(); + } + + +} + +long RCtime(int sensPin){ + long result = 0; + pinMode(sensPin, OUTPUT); // make pin OUTPUT + digitalWrite(sensPin, HIGH); // make pin HIGH to discharge capacitor - study the schematic + delay(1); // wait a ms to make sure cap is discharged + + pinMode(sensPin, INPUT); // turn pin into an input and time till pin goes low + digitalWrite(sensPin, LOW); // turn pullups off - or it won't work + while(digitalRead(sensPin)){ // wait for pin to go low + result++; + } + + return result; // report results +} +void modoZero() { + digitalWrite(13, HIGH); + delay(1000); + digitalWrite(13, LOW); + delay(1000); +} + +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + calibrado = false; //para recalibrar quando ligar seguidor de linha novamente +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_seguir_bluetooth/Motores.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_seguir_bluetooth/Motores.pde new file mode 100644 index 0000000..611aec0 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_seguir_bluetooth/Motores.pde @@ -0,0 +1,78 @@ +int sentido=0; + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_seguir_bluetooth/SeguidorLinha.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_seguir_bluetooth/SeguidorLinha.pde new file mode 100644 index 0000000..f7bc750 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_seguir_bluetooth/SeguidorLinha.pde @@ -0,0 +1,117 @@ +void calibrarSensorDeLinha() { + int i; + // Auto-calibration: turn right and left while calibrating the sensors. + for (i = 0; i < 155; i++) { // make the calibration take about 10 seconds + if (i < 40 || i > 110) + setSpeeds(60, -60); + else + setSpeeds(-60, 60); + qtrrc.calibrate(); // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call) + } + setSpeeds(0, 0); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMinimumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMaximumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + //Serial.println(); + calibrado=true; +} + +void seguirLinha() { + if(!calibrado) calibrarSensorDeLinha(); + if(modo!=9) return; + unsigned int position = qtrrc.readLine(sensorValues); // Get the position of the line. + int proportional = (int)position - 2000;// The "proportional" term should be 0 when we are on the line. + //Serial.print("proportional: "); + //Serial.println(proportional); + int derivative = proportional - last_proportional; // Compute the derivative (change) of the position. + //Serial.print("derivative: "); + //Serial.println(derivative); + integral += proportional; // Compute the integral (sum) of the position. + //Serial.print("integral: "); + //Serial.println(integral); + last_proportional = proportional; // Remember the last position. + + // Compute the difference between the two motor power settings, + // m1 - m2. If this is a positive number the robot will turn + // to the right. If it is a negative number, the robot will + // turn to the left, and the magnitude of the number determines + // the sharpness of the turn. You can adjust the constants by which + // the proportional, integral, and derivative terms are multiplied to + // improve performance. + int power_difference = proportional/20 + integral/10000 + derivative*3/2; + + // Compute the actual motor settings. We never set either motor + // to a negative value. + const int maximum = 120; + if (power_difference > maximum) + power_difference = maximum; + if (power_difference < -maximum) + power_difference = -maximum; + // Serial.print("power diference: "); + // Serial.println(power_difference); + //setSpeeds(70,70); + if (power_difference < 0){ + setSpeeds(maximum + power_difference, maximum); + // Serial.print("motores: "); + // Serial.println(maximum + power_difference); + // Serial.print(" : "); + // Serial.println(maximum); + } + else{ + setSpeeds(maximum, maximum - power_difference); + // Serial.print("motores: "); + // Serial.print(maximum); + // Serial.print(" : "); + // Serial.println(maximum - power_difference); + // Serial.println(" "); + } + //Ler sensor distancia + //Se tiver objeto na frente, parar + //Andar um pouco pra traz + //Programacao do desvio de pista + + //delay(1000); + Serial.print("position: "); + + Serial.println(position); + Serial.println("sensor values: "); + for(int x=0;x 0){ + digitalWrite(MOTOR1_control_A,HIGH); + digitalWrite(MOTOR1_control_B,LOW); + } + else { + digitalWrite(MOTOR1_control_A,LOW); + digitalWrite(MOTOR1_control_B,HIGH); + } + if (M2 > 0){ + digitalWrite(MOTOR2_control_A,HIGH); + digitalWrite(MOTOR2_control_B,LOW); + } + else { + digitalWrite(MOTOR2_control_A,LOW); + digitalWrite(MOTOR2_control_B,HIGH); + } + analogWrite(MOTOR1_PWM,abs(M1) ); + analogWrite(MOTOR2_PWM,abs(M2) ); +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_seguir_bluetooth/br2_seguir_bluetooth.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_seguir_bluetooth/br2_seguir_bluetooth.pde new file mode 100644 index 0000000..7b485f7 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/br2_seguir_bluetooth/br2_seguir_bluetooth.pde @@ -0,0 +1,72 @@ +#include +#include +#include + +#define NUM_SENSORS 5 // number of sensors used +#define TIMEOUT 2500 // waits for 2500 us for sensor outputs to go low +#define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2 + + +unsigned int last_proportional = 0; +long integral = 0; + +// sensores 1 a 5 estao conectados nas portas digitais 5, 9, 2, 3 e 4, respectivamente +PololuQTRSensorsRC qtrrc((unsigned char[]) {5, 9, 2, 3, 4}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); +unsigned int sensorValues[NUM_SENSORS]; + +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + +int modo=1; +boolean calibrado = false; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo servoV; +Servo servoH; + +void setup(){ + delay(500); + Serial.begin(115200); + Serial.println("Heelooo"); + delay(20); + //meetAndroid.setSerial(&Serial); + //meetAndroid.registerFunction(dedoDuro, 'A'); + //meetAndroid.registerFunction(encontraNorte, 'B'); + //meetAndroid.registerFunction(acelera, 'C'); + //meetAndroid.registerFunction(mudarModo, 'M'); + + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + modo=9; +} + int x=0; +void loop(){ + //meetAndroid.receive(); + //delay(50); + //if(modo==9) seguirLinha(); + //seguirLinha(); + + Serial.println("Heelooo" + x++); + delay(2000); + + +} + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/jHome_Robo1/Motores.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/jHome_Robo1/Motores.pde new file mode 100644 index 0000000..e1ab492 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/jHome_Robo1/Motores.pde @@ -0,0 +1,95 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + + +int sentido=0; +void setupMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTras(int tempo,int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/jHome_Robo1/jHome_Robo1.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/jHome_Robo1/jHome_Robo1.pde new file mode 100644 index 0000000..9aa2375 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/jHome_Robo1/jHome_Robo1.pde @@ -0,0 +1,70 @@ +#define LED 6 +boolean connected; + +void setup(){ + setupMotor(); + Serial.begin(115200); +} + +void loop(){ + if(Serial.available()) receiveCommand(); + +} +void handShake() { + Serial.print("ID 2|robot|4|f|frente|t|tras|d|direita|e|esquerda"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); + connected=false; +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + if(comando[0]=='f') frente(); + if(comando[0]=='t') tras(); + if(comando[0]=='d') direita(); + if(comando[0]=='e') esquerda(); + if(comando[0]=='X') shutdown(); +} + +void frente() { + andarFrente(2000, 3); + parar(); +} +void tras() { + andarTras(2000, 3); + parar(); +} +void esquerda() { + virarEsquerda(2000, 3); + parar(); +} +void direita() { + virarDireita(2000, 3); + parar(); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/minicurso/Motores.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/minicurso/Motores.ino new file mode 100644 index 0000000..768f361 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/minicurso/Motores.ino @@ -0,0 +1,97 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + + +int sentido=0; +void configurarMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + parar(); +} +void andarTras(int tempo,int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + parar(); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/minicurso/Utilitario.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/minicurso/Utilitario.ino new file mode 100644 index 0000000..a99ee8a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/minicurso/Utilitario.ino @@ -0,0 +1,21 @@ +void configurarComunicacao() { + Serial.begin(115200); +} + + +void imprimirLuz() { + Serial.print("Luz: "); + Serial.println(analogRead(3)); +} + +void imprimirTemperatura() { + float tempC = analogRead(2); //read the value from the sensor + tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature + Serial.print("Temperatura: "); + Serial.println((byte)tempC); +} + +void esperar(long mssegundos) { + delay(mssegundos); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/minicurso/minicurso.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/minicurso/minicurso.ino new file mode 100644 index 0000000..df31163 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/Robotica/minicurso/minicurso.ino @@ -0,0 +1,17 @@ + +//setup = configurar +void setup(){ + configurarMotor(); + configurarComunicacao(); +} + +//executar para sempre no robo +void loop(){ + imprimirTemperatura(); + delay(1000); + imprimirLuz(); + delay(1000); + + +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/.DS_Store b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/.DS_Store new file mode 100644 index 0000000..076cdba Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/.DS_Store differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/LCD_driver.c b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/LCD_driver.c new file mode 100644 index 0000000..684b169 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/LCD_driver.c @@ -0,0 +1,416 @@ +//************************************************************************ +// +// LCD_driver.c: Interface for Nokia LCD +// +//************************************************************************ +//************************************************************************ +//* Edit History +//* = Mark Sproul msproul -at- jove.rutgers.edu +//************************************************************************ +//* Apr 2, 2010 I received my Color LCD Shield sku: LCD-09363 from sparkfun +//* Apr 2, 2010 The code was written for WinAVR, I modified it to compile under Arduino +//* Apr 3, 2010 Changed LCDSetPixel to make it "RIGHT" side up +//* Apr 3, 2010 Made LCDSetPixel public +//* Apr 3, 2010 Working on MEGA, pin defs in nokia_tester.h +//* Apr 4, 2010 Removed delays from LCDCommand & LCDCommand, increased speed by 75% +//************************************************************************ +#include "nokia_tester.h" +#include "LCD_driver.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef _USE_ARDUINO_FOR_NOKIEA_ + #include "WProgram.h" +#endif + +//************************************************************************ +// +// "Private" Function Definitions +// +//************************************************************************ + + +//************************************************************************ +// +// Global Variables for LCD driver +// +//************************************************************************ +//static char x_offset = 0; +//static char y_offset = 0; + +//The spark logo array defines the SparkFun logo that is displayed during startup on the splash screen. The array may +//be changed to display a different image at startup or removed altogether. The array is local to the LCD driver and +//can not be used outside of this file. +static char logo_spark[1120] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfb,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x3f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x3f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x7f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x20,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x00,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0f,0xe0,0x9f,0x01,0xfc,0x09,0x9e,0x1e,0x7f,0x70,0x73,0x9f,0x00,0x00,0x00,0x00, +0x3f,0xf1,0xff,0x87,0xfe,0x3f,0xde,0x3d,0xff,0x78,0xf3,0xff,0x80,0x00,0x00,0x00, +0x3c,0xf9,0xff,0xc7,0xdf,0x3f,0xde,0x79,0xff,0x78,0xf3,0xff,0xc0,0x00,0x00,0x00, +0x78,0x79,0xc3,0xcf,0x0f,0x3f,0x1c,0xf0,0x3c,0x78,0xf3,0xe3,0xc0,0x00,0x00,0x00, +0x7c,0x01,0xc1,0xe0,0x0f,0x3e,0x1f,0xe0,0x3c,0x78,0xf3,0xc3,0xc0,0x00,0x00,0x00, +0x3f,0xc1,0x81,0xe0,0x3f,0x3c,0x1f,0xe0,0x3c,0x78,0xf3,0xc1,0xc0,0x00,0x00,0x00, +0x1f,0xf1,0x81,0xe3,0xff,0x3c,0x1f,0xe0,0x3c,0x78,0xf3,0xc1,0xc0,0x00,0x00,0x00, +0x07,0xf9,0x81,0xe7,0xef,0x3c,0x1f,0xf0,0x3c,0x78,0xf3,0xc1,0xc0,0x00,0x00,0x00, +0x00,0xf9,0x81,0xef,0x07,0x3c,0x1e,0xf8,0x3c,0x78,0xf3,0xc1,0xc0,0x00,0x00,0x00, +0x78,0x79,0xc1,0xef,0x0f,0x3c,0x1e,0x78,0x3c,0x78,0xf3,0xc1,0xc0,0x00,0x00,0x00, +0x78,0x79,0xe3,0xcf,0x0f,0x3c,0x1e,0x3c,0x3c,0x7c,0xf3,0xc1,0xc0,0x00,0x00,0x00, +0x3f,0xf9,0xff,0xcf,0xff,0x3c,0x1e,0x3e,0x3c,0x7f,0xf3,0xc1,0xcf,0x00,0x00,0x00, +0x1f,0xf1,0xff,0x87,0xff,0x3c,0x1e,0x1e,0x3c,0x3f,0xf3,0xc1,0xc7,0x00,0x00,0x00, +0x07,0xc1,0x9e,0x03,0xe0,0x00,0x00,0x02,0x00,0x0e,0x20,0x00,0x00,0x00,0x00,0x00, +0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x03,0x80,0x00,0x00,0x00,0xc0,0x00,0x00,0x18,0x00,0x00,0x08,0x08,0x00,0x00, +0x00,0x01,0x87,0xc3,0x03,0xe0,0xe1,0xf0,0xf8,0x3e,0x33,0x08,0x3e,0x1e,0x00,0x00, +0x00,0x01,0x86,0x03,0x03,0x01,0xb0,0xe0,0xdc,0x66,0x3b,0x08,0x66,0x32,0x00,0x00, +0x00,0x00,0x87,0xc3,0x03,0xe1,0x80,0x40,0xd8,0x63,0x3b,0x08,0x60,0x3c,0x00,0x00, +0x00,0x00,0x87,0x83,0x03,0xc1,0x80,0x40,0xf8,0x63,0x3f,0x08,0x60,0x0e,0x00,0x00, +0x00,0x00,0x06,0x03,0x03,0x01,0xb0,0x40,0xd8,0x66,0x37,0x08,0x66,0x32,0x00,0x00, +0x00,0x00,0x07,0xc3,0xe3,0xe0,0xe0,0x40,0xc8,0x3e,0x33,0x08,0x3e,0x3e,0x00,0x00, +0x00,0x00,0x07,0xc3,0xe3,0xe0,0xe0,0x40,0x88,0x3c,0x33,0x08,0x3c,0x1e,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,}; + + +//************************************************************************ +//Usage: LCDClear(black); +//Inputs: char color: 8-bit color to be sent to the screen. +//Outputs: None +//Description: This function will clear the screen with "color" by writing the +// color to each location in the RAM of the LCD. +//************************************************************************ +void LCDClear(int color) +{ +unsigned int i; + + #ifdef EPSON + LCDCommand(PASET); + LCDData(0); + LCDData(131); + + LCDCommand(CASET); + LCDData(0); + LCDData(131); + + LCDCommand(RAMWR); + #endif + #ifdef PHILLIPS + LCDCommand(PASETP); + LCDData(0); + LCDData(131); + + LCDCommand(CASETP); + LCDData(0); + LCDData(131); + + LCDCommand(RAMWRP); + #endif + + for (i=0; i < (131*131)/2; i++) + { + LCDData((color >> 4) & 0x00FF); + LCDData(((color & 0x0F) << 4) | (color >> 8)); + LCDData(color & 0x0FF); // nop(EPSON) + } + +// x_offset = 0; +// y_offset = 0; +} + + +//************************************************************************ +void delay_us(int microSecs) +{ + delayMicroseconds(microSecs); +} + +//************************************************************************ +void delay_ms(int millisecs) +{ +// delay(millisecs); +// delayMicroseconds(millisecs * 1000); +} + + +//************************************************************************ +//Usage: LCDCommand(RAMWR); +//Inputs: char data - character command to be sent to the LCD +//Outputs: None +//************************************************************************ +void LCDCommand(unsigned char data) +{ +char jj; + cbi(LCD_PORT_CS, CS); // enable chip, p0.20 goes low + //delay_us(1); + cbi(LCD_PORT_DIO, DIO); // output low on data out (9th bit low = command), p0.19 + //delay_us(1); + + cbi(LCD_PORT_SCK, SCK); // send clock pulse + delay_us(1); + sbi(LCD_PORT_SCK, SCK); + //delay_us(1); + + for (jj = 0; jj < 8; jj++) + { + if ((data & 0x80) == 0x80) + { + sbi(LCD_PORT_DIO, DIO); + } + else + { + cbi(LCD_PORT_DIO, DIO); + } + //delay_us(1); + + cbi(LCD_PORT_SCK, SCK); // send clock pulse + //+ delay_us(1); + sbi(LCD_PORT_SCK, SCK); + + data <<= 1; + } + + sbi(LCD_PORT_CS, CS); // disable +} + +//************************************************************************ +//Usage: LCDData(RAMWR); +//Inputs: char data - character data to be sent to the LCD +//Outputs: None +//************************************************************************ +void LCDData(unsigned char data) +{ +char j; + + cbi(LCD_PORT_CS, CS); // enable chip, p0.20 goes low + //delay_us(1); + sbi(LCD_PORT_DIO, DIO); // output high on data out (9th bit high = data), p0.19 + //delay_us(1); + + cbi(LCD_PORT_SCK, SCK); // send clock pulse +//+ delay_us(1); + sbi(LCD_PORT_SCK, SCK); // send clock pulse + //delay_us(1); + + for (j = 0; j < 8; j++) + { + if ((data & 0x80) == 0x80) + { + sbi(LCD_PORT_DIO, DIO); + } + else + { + cbi(LCD_PORT_DIO, DIO); + } + //delay_us(1); + + cbi(LCD_PORT_SCK, SCK); // send clock pulse +//+ delay_us(1); + sbi(LCD_PORT_SCK, SCK); + + data <<= 1; + } + + LCD_PORT_CS |= (1< Made LCDSetPixel public +//************************************************************************ +void LCDSetPixel(int color, unsigned char x, unsigned char y) +{ +int myYYvalue; + +//* Apr 3, 2010 This is to make it "RIGHT" side up + + myYYvalue = (COL_HEIGHT - 1) - y; + + #ifdef EPSON + LCDCommand(PASET); // page start/end ram + LCDData(x); + LCDData(ENDPAGE); + + LCDCommand(CASET); // column start/end ram + LCDData(myYYvalue); + LCDData(ENDCOL); + + LCDCommand(RAMWR); // write + LCDData((color>>4)&0x00FF); + LCDData(((color&0x0F)<<4)|(color>>8)); + LCDData(color&0x0FF); // nop(EPSON) + //LCDData(color); + //LCDData(NOP); + //LCDData(NOP); + #endif + #ifdef PHILLIPS + LCDCommand(PASETP); // page start/end ram + LCDData(x); + LCDData(ENDPAGE); + + LCDCommand(CASETP); // column start/end ram + LCDData(myYYvalue); + LCDData(ENDCOL); + + LCDCommand(RAMWRP); // write + + LCDData((unsigned char)((color>>4)&0x00FF)); + LCDData((unsigned char)(((color&0x0F)<<4)|0x00)); + #endif + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/LCD_driver.h b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/LCD_driver.h new file mode 100644 index 0000000..85ca4bc --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/LCD_driver.h @@ -0,0 +1,184 @@ +//#define PHILLIPS +#define EPSON + +#ifdef __cplusplus +extern "C" { +#endif + +//******************************************************************** +// +// General Function Definitions +// +//******************************************************************** +void LCDCommand(unsigned char data); +void LCDData(unsigned char data); +void LCDInit(void); +void LCDClear(int color); +void LCDPrintLogo(void); +void LCDContrast(char setting); +void LCDSetPixel(int color, unsigned char x, unsigned char y); + +//******************************************************************** +// +// LCD Dimension Definitions +// +//******************************************************************** +#define ROW_LENGTH 132 +#define COL_HEIGHT 132 +#define ENDPAGE 132 +#define ENDCOL 130 + +//******************************************************************** +// +// EPSON Controller Definitions +// +//******************************************************************** +#define DISON 0xAF +#define DISOFF 0xAE +#define DISNOR 0xA6 +#define DISINV 0xA7 +#define SLPIN 0x95 +#define SLPOUT 0x94 +#define COMSCN 0xBB +#define DISCTL 0xCA +#define PASET 0x75 +#define CASET 0x15 +#define DATCTL 0xBC +#define RGBSET8 0xCE +#define RAMWR 0x5C +#define RAMRD 0x5D +#define PTLIN 0xA8 +#define PTLOUT 0xA9 +#define RMWIN 0xE0 +#define RMWOUT 0xEE +#define ASCSET 0xAA +#define SCSTART 0xAB +#define OSCON 0xD1 +#define OSCOFF 0xD2 +#define PWRCTR 0x20 +#define VOLCTR 0x81 +#define VOLUP 0xD6 +#define VOLDOWN 0xD7 +#define TMPGRD 0x82 +#define EPCTIN 0xCD +#define EPCOUT 0xCC +#define EPMWR 0xFC +#define EPMRD 0xFD +#define EPSRRD1 0x7C +#define EPSRRD2 0x7D +#define NOP 0x25 + +//******************************************************************** +// +// PHILLIPS Controller Definitions +// +//******************************************************************** +//LCD Commands +//* Apr 4, 2010 see definitions below, +#if 0 + #define NOPP 0x00 // nop + #define BSTRON 0x03 + #define SLEEPIN 0x10 + #define SLEEPOUT 0x11 + #define NORON 0x13 + #define INVOFF 0x20 + #define INVON 0x21 + #define SETCON 0x25 + #define DISPOFF 0x28 + #define DISPON 0x29 + #define CASETP 0x2A + #define PASETP 0x2B + #define RAMWRP 0x2C + #define RGBSET 0x2D + #define MADCTL 0x36 + #define COLMOD 0x3A + #define DISCTR 0xB9 + #define EC 0xC0 +#endif + +//************************************************************************************* +// LCD Include File for Philips PCF8833 STN RGB- 132x132x3 Driver +// +// Taken from Philips data sheet Feb 14, 2003 +//************************************************************************************* +//* I changed them to P_ for Philips +//* many of these commands are not used but I wanted them all listed in case +//* anyone wants to write more features +// Philips PCF8833 LCD controller command codes +#define P_NOP 0x00 // nop +#define P_SWRESET 0x01 // software reset +#define P_BSTROFF 0x02 // booster voltage OFF +#define P_BSTRON 0x03 // booster voltage ON +#define P_RDDIDIF 0x04 // read display identification +#define P_RDDST 0x09 // read display status +#define P_SLEEPIN 0x10 // sleep in +#define P_SLEEPOUT 0x11 // sleep out +#define P_PTLON 0x12 // partial display mode +#define P_NORON 0x13 // display normal mode +#define P_INVOFF 0x20 // inversion OFF +#define P_INVON 0x21 // inversion ON +#define P_DALO 0x22 // all pixel OFF +#define P_DAL 0x23 // all pixel ON +#define P_SETCON 0x25 // write contrast +#define P_DISPOFF 0x28 // display OFF +#define P_DISPON 0x29 // display ON +#define P_CASET 0x2A // column address set +#define P_PASET 0x2B // page address set +#define P_RAMWR 0x2C // memory write +#define P_RGBSET 0x2D // colour set +#define P_PTLAR 0x30 // partial area +#define P_VSCRDEF 0x33 // vertical scrolling definition +#define P_TEOFF 0x34 // test mode +#define P_TEON 0x35 // test mode +#define P_MADCTL 0x36 // memory access control +#define P_SEP 0x37 // vertical scrolling start address +#define P_IDMOFF 0x38 // idle mode OFF +#define P_IDMON 0x39 // idle mode ON +#define P_COLMOD 0x3A // interface pixel format +#define P_SETVOP 0xB0 // set Vop +#define P_BRS 0xB4 // bottom row swap +#define P_TRS 0xB6 // top row swap +#define P_DISCTR 0xB9 // display control +#define P_DOR 0xBA // data order +#define P_TCDFE 0xBD // enable/disable DF temperature compensation +#define P_TCVOPE 0xBF // enable/disable Vop temp comp +#define P_EC 0xC0 // internal or external oscillator +#define P_SETMUL 0xC2 // set multiplication factor +#define P_TCVOPAB 0xC3 // set TCVOP slopes A and B +#define P_TCVOPCD 0xC4 // set TCVOP slopes c and d +#define P_TCDF 0xC5 // set divider frequency +#define P_DF8COLOR 0xC6 // set divider frequency 8-color mode +#define P_SETBS 0xC7 // set bias system +#define P_RDTEMP 0xC8 // temperature read back +#define P_NLI 0xC9 // n-line inversion +#define P_RDID1 0xDA // read ID1 +#define P_RDID2 0xDB // read ID2 +#define P_RDID3 0xDC // read ID3 + + +//******************************************************* +// 12-Bit Color Definitions +//******************************************************* +#define WHITE 0xFFF +#define BLACK 0x000 +#define RED 0xF00 +#define GREEN 0x0F0 +#define BLUE 0x00F +#define CYAN 0x0FF +#define MAGENTA 0xF0F +#define YELLOW 0xFF0 +#define BROWN 0xB22 +#define ORANGE 0xFA0 +#define PINK 0xF6A + +typedef struct +{ + unsigned char red; + unsigned char green; + unsigned char blue; +} RGBColor; + + +#ifdef __cplusplus +} +#endif diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/SparkLCD.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/SparkLCD.pde new file mode 100644 index 0000000..00f706e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/SparkLCD.pde @@ -0,0 +1,882 @@ +//************************************************************************ +// Nokia Shield +//************************************************************************ +//* Edit History +//* = Mark Sproul msproul -at- jove.rutgers.edu +//************************************************************************ +//* Apr 2, 2010 I received my Color LCD Shield sku: LCD-09363 from sparkfun +//* Apr 2, 2010 The code was written for WinAVR, I modified it to compile under Arduino +//* Apr 3, 2010 Changed LCDSetPixel to make it "RIGHT" side up +//************************************************************************ + +#include +#include +#include +#include +#include +#include +#include + + +#include "WProgram.h" +#include "HardwareSerial.h" + + +//************************************************************************ +// External Component Libs +//************************************************************************ +#include "LCD_driver.h" +#include "nokia_tester.h" + +//static int uart_putchar(char c, FILE *stream); +//uint8_t uart_getchar(void); +//static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE); + +#define _SHOW_RGB_IMAGE_ +void DisplayRGBimage(); + + +#define kSwitch1_PIN 3 +#define kSwitch2_PIN 4 +#define kSwitch3_PIN 5 + +void DoMandleBrot(void); + +//#define _ENABLE_DEBUG_ + +//************************************************************************ +// Main Code +//************************************************************************ +void setup() +{ +int frameCounter; +unsigned long startTime; + + Serial.begin(9600); + Serial.println("Initializing"); + + //Initialize ARM I/O + ioinit(); + + Serial.println("ioinit. Done"); + + LCDInit(); //Initialize the LCD + + Serial.println("LCDInit. Done"); + + LCDClear(BLACK); + Serial.print("Logo..."); + //Show the splash-screen (Sparkfun Logo) + LCDPrintLogo(); + +#ifdef _ENABLE_DEBUG_ + //* test speed + Serial.println(); + Serial.print("Speed test..."); + frameCounter = 0; + startTime = millis(); + + while ((millis() - startTime) < 5000) + { + LCDClear((frameCounter << 8) + frameCounter); + LCDPrintLogo(); + + frameCounter++; + } + Serial.println(); + Serial.print("Frames="); + Serial.println(frameCounter); +#endif +} + +//************************************************************************ +// Loop +//************************************************************************ +void loop() +{ +int s1, s2, s3; + + s1 = !digitalRead(kSwitch1_PIN); + s2 = !digitalRead(kSwitch2_PIN); + s3 = !digitalRead(kSwitch3_PIN); +#ifdef _ENABLE_DEBUG_foo + Serial.print("switches..."); + Serial.print(s1); + Serial.print("..."); + Serial.print(s2); + Serial.print("..."); + Serial.print(s3); + Serial.println(); +#endif + + + if (s1) + { + Serial.println("GRREN"); + LCDClear(GREEN); + LCDPrintLogo(); + } + else if (s2) + { + Serial.println("WHITE"); + // LCDClear(PINK); + LCDClear(WHITE); + LCDPrintLogo(); + } + else if (s3) + { + DisplayRGBimage(); + delay(5000); + + // Serial.println("BLACK"); + // LCDClear(BLACK); + // LCDPrintLogo(); + DoMandleBrot(); + } + delay(200); +} + +//************************************************************************ +void ioinit(void) +{ +#ifdef _USE_ARDUINO_FOR_NOKIEA_ + + //* setup the switches for input + pinMode(kSwitch1_PIN, INPUT); + pinMode(kSwitch2_PIN, INPUT); + pinMode(kSwitch3_PIN, INPUT); + + //* set the pull up resisters + digitalWrite(kSwitch1_PIN, HIGH); + digitalWrite(kSwitch2_PIN, HIGH); + digitalWrite(kSwitch3_PIN, HIGH); + + + //* do the LCD control lines + pinMode(CS_PIN, OUTPUT); + pinMode(DIO_PIN, OUTPUT); + pinMode(SCK_PIN, OUTPUT); + pinMode(LCD_RES_PIN, OUTPUT); + +#else + DDRB = ((1<> 8) & 0x7F; //Make sure highest bit(URSEL) is 0 indicating we are writing to UBRRH + UBRR0L = MYUBRR; + UCSR0A = (1< 0 ; x--) + delay_us(1000); +} + +//************************************************************************ +//General short delays +void delay_us(int x) +{ + TIFR2 = (1<0) + { + while( (TIFR2 & (1<red << 4) & 0x0f00; + color12bit += (rgbColor->green) & 0x0f0; + color12bit += (rgbColor->blue >> 4) & 0x0f; + + LCDSetPixel(color12bit, col, row); +// LCDSetPixel(color12bit, row, col); +} + +//******************************************************************************* +boolean gettouch() +{ +int s1, s2, s3; + + s1 = !digitalRead(kSwitch1_PIN); + s2 = !digitalRead(kSwitch2_PIN); + s3 = !digitalRead(kSwitch3_PIN); + + return(s1 || s2 || s3); +} + + +//******************************************************************************* +void DoMandleBrot(void) +{ +float XMax, YMax, XMin, YMin; +float X, Y, Xsquare, Ysquare; +float QQtemp; +float QQ[kQmax]; +float PP, deltaP, deltaQ; +long color; +short row, col; +short maxcol; +short maxrow; +RGBColor rgbColor; +short itteration; +boolean keepGoing; +short deltaColumn; +short ii; +short startOffset[10] = {0, 16, 8, 4, 2, 1, 3, 0}; +short columnSteps[10] = {32, 32, 16, 8, 4, 4, 4, 0}; + + XMin = kMandel_FarLeft; + XMax = kMandel_FarRight; + YMin = kMandel_FarTop; + YMax = kMandel_FarBottom; + + itteration = 0; + keepGoing = true; + while (keepGoing) + { + switch(itteration % 3) + { + case 0: + XMin = kMandel_FarLeft; + XMax = kMandel_FarRight; + YMin = kMandel_FarTop; + YMax = kMandel_FarBottom; + break; + + case 1: + XMin = -1.7018; + XMax = -1.7016; + YMin = -0.000075; + YMax = 0.000075; + break; + + case 2: + XMin = -0.197272275682447305; + XMax = -0.196537412401197305; + YMin = -0.67495234375; + YMax = -0.67436640625; + break; + + } + maxcol = gWidth; + maxrow = gHeight; + deltaP = (XMax - XMin) / (maxcol); + deltaQ = (YMax - YMin) / (maxrow); + + QQ[0] = YMin; + for (row=1; row<=maxrow; row++) + { + QQ[row] = QQ[row-1] + deltaQ; + } + + ii = 0; + while (columnSteps[ii] > 0) + { + deltaColumn = columnSteps[ii]; + for (col=startOffset[ii]; col < maxcol; col += deltaColumn) + { + PP = XMin + (deltaP * col); + + for (row=0; row < maxrow; row++) + { + X = Y = Xsquare = Ysquare = 0.0; + color = kStartColor; + QQtemp = QQ[row]; + while ((color < kMaxItterations) && ((Xsquare + Ysquare) < 4)) + { + Xsquare = X * X; + Ysquare = Y * Y; + Y *= X; + Y += Y + QQtemp; + X = Xsquare - Ysquare + PP; + color++; + } + rgbColor.red = (255 - color) & 0xe0; + rgbColor.green = ((255 - color) << 3) & 0xe0;; + rgbColor.blue = ((255 - color) << 6) & 0xe0;; + setPixel(col, row, &rgbColor); + } + if (gettouch()) + { + keepGoing = false; + break; + } + } + ii++; + if (gettouch()) + { + keepGoing = false; + break; + } + } + if (keepGoing) + { + delay(2500); + } + itteration++; + } +} + + +#ifdef _SHOW_RGB_IMAGE_ +static uint8_t gRGBimage[] PROGMEM = { +0,64,0,59,0 , //xSize_hi, xSize_lo ,ySize_hi, ySize_lo + +//* Line # 0 +19,33,33, 20,33,34, 21,36,36, 25,39,39, 27,40,40, 28,40,40, 31,43,42, 32,44,42, 35,46,44, 38,48,45, 40,49,46, +41,50,46, 42,50,46, 44,52,47, 46,53,48, 49,56,51, 53,58,52, 59,63,57, 68,72,66, 72,74,68, 76,77,72, 82,82,77, +68,66,62, 62,64,54, 73,69,58, 97,79,70, 111,82,75, 131,101,94, 133,114,104, 105,99,85, 99,92,82, 92,82,76, 88,77,71, +83,74,68, 75,69,65, 70,71,69, 63,71,69, 57,66,63, 54,64,59, 52,61,57, 49,58,55, 47,57,55, 46,57,55, 48,59,58, +48,60,59, 46,58,56, 46,57,55, 43,56,53, 45,58,53, 46,60,55, 46,60,54, 51,63,58, 61,69,66, 63,73,69, 63,74,69, +63,73,67, 69,76,70, 78,82,77, 86,87,82, 95,91,88, 99,97,93, 102,100,96, 101,100,96, 98,98,94, +//* Line # 1 +22,35,36, 23,36,37, 23,37,38, 27,40,41, 29,42,42, 32,45,44, 32,44,43, 37,48,47, 38,49,47, 39,49,46, 41,51,48, +43,52,48, 43,51,47, 44,52,48, 47,54,49, 48,55,50, 57,60,53, 63,64,57, 70,70,64, 71,71,64, 72,70,65, 80,78,73, +74,71,66, 120,111,115, 170,161,165, 213,208,209, 206,203,203, 216,213,212, 235,227,228, 222,209,217, 213,193,188, 191,164,149, 169,143,129, +126,101,89, 106,87,77, 90,80,72, 80,77,72, 69,69,66, 63,66,62, 52,60,55, 47,60,54, 43,59,53, 43,59,55, 48,60,58, +51,62,59, 49,61,53, 49,61,53, 49,62,52, 51,63,54, 53,65,55, 54,67,56, 55,67,57, 63,72,63, 66,75,66, 64,75,64, +65,76,64, 70,77,66, 76,80,70, 87,87,78, 100,94,86, 104,98,90, 106,101,92, 106,102,93, 105,101,92, +//* Line # 2 +22,36,36, 25,38,39, 27,41,42, 31,45,46, 33,46,46, 35,48,47, 36,47,46, 39,51,49, 39,51,49, 40,50,47, 43,53,50, +44,54,51, 43,52,49, 47,56,51, 49,56,51, 49,57,52, 57,61,55, 62,65,59, 69,71,66, 72,72,68, 72,71,68, 80,77,75, +156,153,151, 221,212,209, 194,178,173, 172,150,145, 178,152,149, 181,156,153, 179,160,158, 204,191,190, 216,196,187, 213,182,168, 178,144,129, +160,123,108, 153,117,103, 140,111,97, 118,95,84, 93,75,68, 79,69,66, 64,66,59, 49,63,53, 42,61,52, 46,63,55, 51,63,58, +53,63,57, 54,65,56, 54,64,55, 57,67,58, 60,70,59, 61,71,60, 65,74,63, 64,73,62, 69,76,66, 71,79,69, 68,77,66, +68,76,65, 72,77,66, 78,81,70, 90,90,78, 100,96,85, 107,102,91, 110,106,95, 111,108,97, 110,109,97, +//* Line # 3 +23,36,37, 25,39,39, 30,44,45, 31,45,46, 34,48,48, 36,49,48, 37,49,48, 39,51,50, 43,54,52, 43,55,51, 44,56,52, +46,57,53, 47,57,52, 47,57,52, 48,56,51, 49,57,51, 53,61,57, 58,65,62, 67,71,68, 72,72,70, 76,74,73, 147,142,140, +196,188,188, 148,134,127, 154,136,125, 160,140,130, 171,150,142, 190,171,164, 230,214,210, 247,236,233, 248,237,234, 233,216,211, 203,176,166, +180,142,127, 165,123,104, 162,120,100, 150,110,90, 145,111,97, 114,91,83, 87,76,65, 62,65,53, 56,68,55, 53,66,56, 59,67,61, +59,67,63, 61,70,66, 63,72,67, 65,72,68, 69,75,71, 69,74,69, 71,76,71, 71,76,71, 73,78,73, 71,78,72, 70,77,71, +72,78,71, 78,81,74, 85,85,78, 94,92,86, 102,102,93, 112,113,103, 114,116,106, 117,119,110, 117,121,111, +//* Line # 4 +22,35,36, 23,36,37, 26,40,41, 30,44,45, 33,46,47, 35,47,47, 37,49,48, 39,50,49, 41,52,51, 41,53,50, 45,57,53, +46,58,53, 45,56,52, 46,56,51, 49,58,52, 50,59,53, 53,60,56, 60,66,63, 69,70,66, 75,71,66, 123,112,106, 225,210,203, +188,169,162, 197,176,163, 229,214,198, 240,224,209, 247,232,219, 251,236,226, 250,237,228, 237,223,218, 227,218,216, 222,212,208, 218,194,184, +201,163,145, 192,146,124, 191,143,120, 161,115,92, 150,109,89, 126,90,73, 132,105,88, 109,94,79, 77,71,59, 67,68,60, 67,72,66, +67,73,70, 67,75,73, 69,76,73, 71,77,74, 74,78,75, 74,77,74, 77,79,75, 77,79,76, 76,80,76, 72,76,73, 71,76,71, +75,79,74, 82,84,79, 92,91,86, 106,104,98, 117,117,109, 129,129,120, 132,133,124, 131,133,124, 129,132,122, +//* Line # 5 +25,38,39, 25,39,39, 24,38,39, 28,41,42, 32,45,45, 34,47,46, 36,48,47, 37,48,47, 39,50,48, 40,52,49, 41,54,50, +43,55,51, 45,57,52, 47,57,52, 46,57,51, 50,61,54, 61,65,58, 78,77,69, 86,80,70, 125,111,100, 195,173,159, 217,188,172, +215,180,163, 225,193,167, 198,165,136, 203,164,139, 210,169,147, 196,158,139, 204,175,158, 235,214,197, 226,216,203, 217,200,186, 207,177,158, +214,171,147, 196,148,123, 187,141,117, 164,122,102, 157,115,92, 129,82,58, 117,75,55, 128,95,80, 140,118,108, 98,89,82, 74,74,70, +72,78,74, 71,80,73, 72,79,73, 76,82,75, 79,82,76, 78,80,73, 80,80,73, 80,80,73, 78,81,74, 75,79,70, 72,77,68, +77,81,72, 90,91,82, 105,103,95, 123,119,110, 135,130,118, 147,142,130, 150,145,134, 146,143,131, 140,138,125, +//* Line # 6 +28,42,41, 28,41,40, 24,38,37, 26,39,38, 28,41,40, 32,45,43, 35,47,46, 36,48,46, 38,49,47, 40,50,49, 41,52,50, +44,55,51, 46,56,51, 46,56,50, 47,56,49, 50,59,53, 61,63,55, 85,76,66, 124,103,89, 158,127,109, 185,150,129, 181,144,123, +146,106,87, 105,71,52, 102,73,52, 135,107,86, 164,136,116, 146,118,100, 177,147,134, 207,175,168, 206,182,168, 225,204,185, 199,170,151, +198,158,133, 190,142,109, 184,137,104, 179,137,113, 183,141,116, 188,141,111, 140,92,67, 114,68,49, 132,95,82, 154,130,121, 115,104,98, +90,88,81, 76,77,69, 80,81,73, 81,82,75, 83,83,76, 83,82,74, 82,81,73, 80,80,71, 78,82,73, 77,82,72, 76,80,70, +84,86,76, 100,99,89, 117,115,105, 132,129,118, 142,137,125, 154,147,133, 158,150,137, 155,147,133, 150,143,129, +//* Line # 7 +34,48,46, 33,46,44, 29,42,40, 24,38,36, 26,39,38, 31,43,42, 33,44,43, 36,46,45, 38,48,48, 42,50,50, 44,54,53, +46,56,53, 45,56,52, 47,57,51, 50,59,53, 54,61,57, 57,60,54, 109,98,90, 150,121,107, 167,129,110, 172,135,112, 160,124,102, +113,75,59, 89,55,42, 111,81,69, 111,79,64, 93,62,49, 135,108,93, 193,174,161, 210,196,185, 205,183,171, 184,154,143, 174,139,131, +164,120,104, 159,106,77, 174,118,86, 158,104,82, 138,92,72, 175,133,107, 190,144,120, 162,114,93, 131,87,69, 142,106,90, 167,138,125, +137,119,108, 104,96,89, 98,91,84, 86,82,76, 87,84,78, 86,83,78, 83,81,74, 81,81,73, 79,83,76, 79,82,75, 83,83,76, +92,90,82, 106,104,95, 123,119,111, 135,131,122, 144,141,130, 154,148,136, 161,152,139, 160,150,136, 157,148,136, +//* Line # 8 +40,53,51, 38,50,49, 32,44,44, 30,43,43, 31,43,43, 32,44,44, 33,43,44, 37,47,48, 41,50,51, 46,53,52, 50,59,57, +48,58,55, 47,59,55, 51,61,58, 52,61,58, 54,60,58, 71,74,69, 129,118,112, 158,131,119, 167,132,115, 199,164,143, 161,126,106, +185,146,130, 219,199,189, 236,225,216, 223,208,197, 210,193,182, 206,186,179, 235,217,212, 245,226,224, 198,176,171, 185,157,150, 165,131,125, +172,129,118, 154,104,83, 132,79,56, 153,100,84, 151,104,92, 133,93,78, 125,84,67, 162,120,99, 166,122,100, 161,116,94, 156,109,88, +141,106,89, 124,110,100, 94,83,73, 98,90,83, 95,90,84, 92,89,82, 90,87,79, 88,86,77, 87,86,79, 87,86,78, 91,89,81, +100,96,88, 111,106,98, 124,118,109, 135,128,120, 147,142,131, 154,148,135, 160,152,138, 160,151,136, 159,151,137, +//* Line # 9 +42,54,52, 41,53,51, 37,49,50, 37,48,49, 36,47,48, 36,46,48, 36,46,48, 41,50,52, 46,54,56, 51,57,54, 55,63,59, +51,61,58, 51,62,60, 52,63,60, 55,62,59, 55,58,55, 84,82,78, 201,189,183, 195,169,159, 180,145,132, 189,155,138, 161,127,110, +141,103,88, 153,123,115, 187,165,160, 219,202,196, 251,237,230, 255,245,238, 252,243,236, 246,240,234, 243,235,223, 227,214,199, 216,193,180, +204,174,156, 197,166,143, 168,133,110, 135,96,75, 138,93,78, 163,116,102, 145,101,82, 131,89,66, 168,125,100, 146,98,75, 151,96,75, +155,110,91, 128,104,89, 115,96,83, 112,99,90, 99,92,85, 98,93,86, 98,94,85, 97,92,83, 98,94,86, 100,95,87, 102,97,88, +107,100,92, 114,106,97, 124,115,106, 134,126,116, 143,136,125, 150,143,130, 157,149,134, 160,152,136, 160,152,137, +//* Line # 10 +45,57,54, 43,54,51, 38,50,50, 39,50,51, 38,48,49, 40,50,51, 42,51,52, 45,53,55, 50,58,59, 56,62,58, 59,66,62, +53,64,61, 53,63,60, 56,63,59, 62,63,57, 75,70,62, 175,167,160, 242,224,217, 204,172,163, 186,151,138, 192,159,143, 169,137,121, +107,70,57, 101,68,58, 127,97,88, 161,134,124, 145,122,114, 187,166,156, 221,204,194, 224,206,196, 225,207,193, 230,205,187, 223,186,167, +214,175,155, 193,159,137, 175,139,117, 141,97,75, 148,96,76, 166,113,96, 144,96,75, 129,86,62, 128,86,62, 142,96,75, 149,99,83, +134,88,70, 150,114,93, 146,118,102, 118,100,89, 107,96,89, 106,100,92, 104,98,88, 104,98,87, 108,101,92, 108,101,93, 110,103,94, +114,106,96, 118,110,100, 124,116,105, 131,123,111, 139,129,118, 145,137,124, 151,144,128, 156,149,133, 155,147,132, +//* Line # 11 +49,59,56, 44,54,51, 41,52,50, 44,54,53, 41,51,50, 42,52,50, 46,55,54, 49,56,56, 54,61,60, 58,64,60, 58,66,62, +58,67,64, 58,66,63, 60,63,56, 76,69,58, 146,132,118, 232,212,199, 195,166,154, 195,156,145, 167,128,116, 145,112,98, 147,117,103, +111,78,67, 144,113,100, 170,142,128, 137,110,98, 97,68,58, 76,45,35, 110,75,65, 125,88,78, 107,69,58, 125,78,66, 131,72,57, +117,60,44, 115,69,56, 132,87,74, 131,72,56, 81,26,8, 100,58,42, 155,111,92, 161,115,95, 118,72,51, 132,86,66, 142,95,77, +141,94,73, 131,85,60, 139,104,85, 124,101,89, 114,102,93, 111,103,94, 113,105,95, 111,103,92, 112,104,94, 113,106,96, 116,108,98, +119,111,100, 120,113,101, 123,117,104, 129,122,110, 138,126,115, 141,132,118, 146,139,122, 154,148,130, 156,149,133, +//* Line # 12 +51,61,57, 47,57,54, 47,58,53, 47,58,53, 45,55,51, 45,54,50, 48,56,52, 51,57,54, 56,63,59, 60,67,62, 60,68,64, +58,68,64, 61,67,62, 72,69,60, 88,73,59, 156,134,115, 193,163,143, 141,103,85, 146,101,87, 151,108,95, 140,107,94, 147,119,107, +108,78,69, 99,61,53, 101,62,54, 85,50,44, 68,37,31, 66,36,29, 75,45,35, 84,51,39, 69,36,27, 83,40,32, 123,68,54, +110,61,48, 74,41,33, 63,33,25, 116,71,56, 98,61,48, 35,12,6, 104,69,58, 128,83,68, 114,62,42, 127,75,50, 137,89,61, +154,103,74, 140,88,60, 135,96,75, 145,120,107, 131,118,109, 122,114,106, 116,108,97, 117,108,97, 116,110,100, 118,111,100, 119,113,101, +123,117,104, 120,115,102, 122,117,103, 128,122,108, 136,122,111, 136,126,112, 139,133,115, 150,145,126, 156,148,131, +//* Line # 13 +49,60,55, 49,60,55, 49,60,56, 47,58,54, 45,54,51, 47,55,52, 49,57,54, 52,60,57, 56,64,61, 59,68,66, 64,67,61, +61,64,61, 56,64,62, 90,86,75, 160,134,111, 196,160,137, 158,122,105, 100,69,55, 96,66,53, 108,74,62, 108,70,56, 107,68,54, +95,59,47, 99,66,49, 99,66,48, 93,58,44, 84,47,35, 97,57,46, 103,59,46, 111,63,49, 91,52,40, 73,37,26, 92,50,37, +103,66,54, 82,54,45, 47,24,15, 51,24,12, 97,63,56, 52,31,26, 80,51,40, 126,72,62, 99,60,36, 126,72,46, 144,77,51, +144,93,58, 163,105,74, 150,99,73, 145,105,84, 168,139,125, 156,139,128, 132,122,113, 124,115,105, 126,111,98, 121,109,97, 123,115,103, +124,118,106, 123,118,106, 123,117,104, 127,120,107, 133,123,112, 135,127,115, 137,131,116, 145,139,124, 151,145,129, +//* Line # 14 +49,60,55, 49,61,55, 47,58,56, 46,56,54, 43,53,51, 45,54,52, 48,56,55, 51,59,58, 54,61,60, 55,66,66, 64,63,56, +62,63,57, 52,63,65, 77,73,61, 164,130,103, 190,146,123, 117,84,71, 54,34,25, 47,33,24, 58,33,23, 102,60,45, 125,76,58, +125,82,64, 131,90,67, 129,85,61, 121,76,56, 109,64,45, 108,62,44, 120,74,54, 114,68,45, 106,62,44, 88,47,33, 77,37,24, +85,46,35, 96,60,51, 74,43,35, 43,20,11, 64,29,25, 84,59,52, 80,54,44, 114,60,51, 97,68,44, 116,65,41, 147,72,53, +126,75,45, 147,91,64, 164,109,82, 160,109,85, 168,124,104, 161,130,113, 169,148,135, 160,141,129, 157,133,118, 138,119,106, 127,115,104, +123,115,106, 125,119,109, 126,119,108, 127,119,108, 130,124,112, 134,128,116, 136,130,117, 141,135,122, 146,140,126, +//* Line # 15 +47,58,53, 47,58,53, 46,57,55, 45,55,53, 44,54,52, 45,54,52, 47,56,54, 50,58,56, 52,59,58, 53,63,64, 60,61,54, +58,62,55, 53,64,64, 73,66,55, 146,112,87, 169,128,106, 106,79,69, 43,28,21, 24,12,7, 62,39,29, 122,80,64, 142,92,71, +137,91,70, 138,91,68, 139,91,67, 132,84,62, 124,77,56, 113,65,45, 129,83,61, 124,78,53, 111,67,47, 98,55,40, 78,36,22, +83,44,33, 76,42,33, 80,52,44, 47,24,17, 38,13,9, 50,28,24, 60,36,29, 83,47,38, 88,53,37, 92,45,27, 149,90,72, +137,85,64, 134,85,64, 126,75,54, 154,103,81, 164,114,92, 182,139,117, 179,143,121, 178,147,127, 194,168,154, 143,122,108, 126,112,101, +124,116,105, 127,121,111, 128,121,111, 127,119,108, 129,122,112, 132,125,114, 135,128,116, 140,133,121, 145,138,125, +//* Line # 16 +47,58,54, 47,59,54, 47,58,55, 45,55,53, 46,56,54, 45,54,53, 48,56,54, 50,57,56, 52,59,58, 53,63,65, 60,63,56, +57,64,56, 53,64,63, 83,73,63, 149,112,89, 123,86,65, 44,25,18, 17,8,6, 15,9,5, 65,45,36, 126,84,67, 149,97,74, +148,99,73, 149,98,73, 147,95,70, 136,85,61, 137,86,64, 119,69,47, 137,89,65, 133,85,58, 121,74,51, 105,60,42, 87,42,27, +80,40,28, 68,35,26, 66,40,34, 55,34,30, 34,22,18, 37,19,17, 42,20,16, 46,27,17, 83,44,36, 62,21,12, 114,74,58, +140,86,71, 152,100,79, 158,104,83, 137,81,59, 164,110,88, 167,118,97, 185,141,121, 204,167,148, 185,155,141, 140,115,101, 126,110,98, +124,114,103, 125,118,108, 125,118,108, 126,118,107, 128,120,110, 130,122,112, 136,128,117, 140,132,121, 144,137,125, +//* Line # 17 +47,58,55, 49,60,57, 47,58,56, 45,55,53, 44,54,52, 46,54,53, 47,55,54, 49,57,55, 51,59,57, 54,62,66, 58,63,56, +56,67,57, 51,63,61, 91,76,67, 143,104,84, 90,57,39, 23,9,5, 9,6,6, 12,10,8, 58,40,32, 133,92,75, 153,100,76, +149,99,71, 153,102,74, 153,100,74, 142,91,66, 146,94,71, 128,77,54, 146,95,70, 143,93,65, 127,77,52, 114,65,45, 101,54,38, +76,35,23, 64,31,23, 65,41,36, 52,35,33, 20,14,11, 40,24,25, 46,27,25, 30,21,13, 82,44,41, 63,28,20, 53,26,15, +126,74,62, 127,71,47, 144,87,64, 168,112,90, 190,138,119, 204,159,142, 216,184,170, 229,197,184, 167,132,117, 140,111,97, 122,102,90, +123,111,100, 122,113,103, 122,115,105, 124,116,106, 129,119,111, 132,123,114, 135,126,116, 140,130,121, 141,132,121, +//* Line # 18 +47,58,56, 49,60,57, 49,60,57, 48,59,56, 48,57,55, 48,56,55, 47,55,54, 49,57,55, 51,59,57, 53,60,65, 56,63,55, +52,68,56, 54,66,63, 92,74,67, 129,88,70, 73,43,27, 28,18,15, 14,14,15, 11,12,10, 44,28,20, 123,85,67, 154,103,78, +152,103,75, 152,104,75, 153,104,77, 148,98,73, 147,96,73, 130,78,55, 144,91,67, 154,101,74, 138,85,60, 120,68,46, 108,60,41, +81,39,27, 57,24,17, 33,11,8, 25,11,11, 13,8,7, 28,15,16, 36,18,18, 28,17,12, 65,33,32, 64,36,31, 55,34,26, +70,29,20, 111,62,42, 97,46,28, 110,60,42, 131,83,68, 144,102,89, 146,113,102, 159,125,114, 124,84,69, 135,102,88, 145,122,110, +123,109,98, 122,113,103, 122,114,104, 122,114,105, 126,116,109, 132,122,114, 134,124,116, 134,124,115, 136,127,116, +//* Line # 19 +48,58,56, 49,60,57, 49,60,58, 50,61,58, 50,60,58, 50,59,57, 50,59,57, 53,60,58, 55,62,60, 56,62,68, 57,65,57, +49,69,55, 55,68,64, 102,81,75, 127,85,70, 80,53,37, 27,18,14, 7,9,8, 6,8,6, 26,12,5, 104,67,48, 149,101,75, +153,107,79, 149,106,77, 144,101,73, 145,98,73, 145,95,72, 129,76,55, 151,96,74, 160,103,80, 138,82,56, 138,84,61, 119,70,51, +96,55,42, 58,27,20, 40,19,18, 21,8,9, 15,8,9, 24,11,11, 40,24,24, 34,18,17, 46,21,19, 63,40,36, 51,33,25, +54,28,23, 85,53,48, 99,63,53, 133,93,81, 119,75,62, 99,56,43, 118,78,64, 152,113,97, 155,111,95, 144,108,93, 136,112,100, +122,106,96, 120,111,102, 121,113,104, 122,114,104, 123,113,106, 128,118,110, 132,121,114, 131,121,112, 132,121,112, +//* Line # 20 +50,59,57, 51,59,58, 51,62,58, 52,63,60, 51,62,58, 52,60,58, 53,61,60, 54,63,61, 56,66,64, 57,68,69, 59,67,59, +58,70,62, 68,72,71, 125,97,85, 138,94,73, 52,32,24, 7,4,2, 18,15,13, 6,5,3, 16,8,1, 100,68,54, 153,103,82, +156,110,81, 133,94,65, 126,87,60, 116,74,49, 107,63,38, 105,57,33, 144,93,68, 157,104,77, 138,82,54, 157,99,72, 139,85,62, +114,67,49, 63,29,19, 39,20,17, 15,9,12, 10,7,8, 22,9,6, 38,19,13, 55,30,22, 39,16,11, 48,28,24, 48,31,26, +53,33,29, 95,67,61, 117,83,74, 137,97,85, 120,76,62, 120,77,63, 140,98,86, 92,53,40, 178,140,125, 158,126,113, 130,105,93, +123,106,93, 121,110,98, 120,112,104, 119,111,107, 121,111,104, 122,112,105, 126,116,108, 129,119,110, 130,119,111, +//* Line # 21 +53,60,58, 55,62,59, 53,64,60, 54,65,61, 54,64,60, 54,63,60, 56,65,62, 57,67,64, 57,67,65, 56,71,66, 62,71,65, +66,68,67, 91,80,77, 156,121,102, 114,74,53, 22,10,9, 3,5,4, 28,21,19, 12,5,4, 11,8,0, 89,62,52, 161,108,93, +154,107,78, 153,107,80, 164,115,94, 151,103,82, 130,81,61, 125,74,53, 135,80,56, 159,99,73, 166,107,78, 170,112,82, 160,102,74, +138,85,62, 99,59,43, 44,22,15, 21,15,14, 6,5,8, 13,7,7, 33,16,10, 51,28,20, 52,32,28, 36,19,17, 34,18,13, +44,22,16, 75,44,36, 124,88,77, 142,101,87, 139,96,81, 115,74,62, 84,47,39, 118,84,74, 169,135,120, 149,118,109, 173,150,141, +140,126,112, 120,111,96, 119,113,106, 117,111,109, 119,112,104, 119,112,103, 120,111,103, 122,113,104, 125,115,107, +//* Line # 22 +54,61,58, 56,63,60, 54,65,61, 54,65,61, 55,65,61, 56,65,62, 59,68,65, 63,71,68, 63,70,67, 61,71,66, 60,72,72, +69,67,65, 123,95,80, 148,110,89, 67,40,29, 19,10,10, 1,0,0, 26,18,17, 13,6,5, 5,3,0, 69,43,35, 155,103,89, +161,114,86, 169,117,91, 164,108,89, 139,89,74, 124,77,65, 136,87,74, 163,106,88, 180,114,91, 175,115,86, 172,117,86, 164,109,79, +156,102,77, 119,74,53, 86,52,38, 38,14,6, 17,8,9, 3,2,9, 17,7,9, 31,18,20, 33,21,24, 43,30,31, 48,30,24, +51,28,21, 63,36,35, 101,71,65, 81,45,35, 68,33,22, 95,60,50, 156,121,111, 193,157,145, 149,108,93, 158,126,118, 225,208,203, +189,180,171, 124,119,105, 124,118,107, 121,114,107, 117,110,101, 116,109,100, 117,108,100, 116,108,99, 118,109,101, +//* Line # 23 +52,59,57, 54,61,59, 54,63,61, 54,63,60, 55,64,61, 56,66,62, 60,67,64, 64,69,66, 65,69,66, 68,69,63, 64,72,75, +95,84,79, 169,125,99, 117,74,52, 64,48,46, 16,10,12, 0,0,0, 20,14,14, 12,7,6, 1,0,0, 56,32,24, 153,102,88, +160,112,86, 150,106,76, 105,64,43, 83,52,38, 63,36,25, 84,55,44, 122,84,63, 162,112,84, 171,118,87, 169,116,85, 164,110,80, +156,102,74, 133,81,56, 117,70,50, 90,47,33, 47,18,12, 27,10,8, 29,9,7, 33,16,17, 16,7,11, 13,6,9, 32,18,14, +50,31,25, 81,56,56, 144,115,110, 192,160,150, 202,177,163, 211,181,165, 200,162,145, 182,142,125, 130,87,71, 139,105,99, 195,175,174, +213,205,198, 134,131,117, 134,130,115, 124,118,105, 113,107,97, 108,102,92, 110,103,94, 110,102,93, 110,101,93, +//* Line # 24 +52,59,57, 52,58,56, 53,60,59, 55,64,61, 55,65,61, 55,65,60, 60,67,62, 65,68,64, 71,69,66, 71,65,56, 85,80,78, +155,131,119, 158,106,77, 108,66,45, 65,51,50, 11,5,6, 4,2,1, 14,8,9, 13,9,9, 0,0,0, 47,25,18, 149,98,86, +165,116,91, 156,112,82, 116,76,50, 118,85,66, 99,71,57, 114,85,69, 125,88,66, 154,107,79, 167,116,86, 168,116,86, 161,109,79, +153,100,72, 161,108,81, 166,112,88, 169,114,92, 156,106,84, 131,86,64, 103,59,41, 68,35,24, 27,10,9, 8,1,3, 6,2,1, +13,1,1, 32,9,8, 75,49,43, 109,77,66, 138,101,85, 154,113,95, 163,121,100, 159,116,95, 122,80,65, 142,107,101, 215,191,189, +183,169,160, 168,160,143, 134,128,109, 128,121,106, 123,118,107, 109,104,93, 105,99,89, 104,97,88, 106,98,91, +//* Line # 25 +52,59,57, 52,59,57, 54,59,59, 54,61,60, 55,64,60, 56,65,60, 61,67,61, 65,65,60, 83,78,74, 101,85,74, 139,114,101, +164,125,106, 123,74,51, 117,77,60, 64,44,37, 24,14,12, 5,2,2, 7,3,3, 13,9,10, 0,1,0, 39,19,13, 143,92,81, +167,118,95, 173,121,96, 172,116,94, 160,107,88, 163,112,95, 164,112,95, 171,115,96, 180,120,99, 171,115,90, 171,118,91, 166,115,88, +154,103,76, 160,108,82, 175,121,95, 180,122,98, 186,127,101, 183,123,92, 161,100,69, 124,74,50, 76,45,34, 15,4,3, 3,2,3, +7,4,4, 16,1,0, 25,7,3, 40,15,8, 73,43,31, 98,61,47, 126,85,67, 114,72,55, 122,85,73, 151,116,108, 201,169,161, +156,131,115, 160,143,120, 152,143,122, 137,131,115, 124,120,106, 109,104,92, 101,95,85, 101,95,86, 103,95,88, +//* Line # 26 +51,58,56, 54,60,58, 57,61,61, 57,63,63, 55,65,61, 53,64,58, 61,67,60, 72,71,65, 93,87,84, 137,116,104, 188,144,119, +153,100,73, 123,81,66, 108,73,61, 84,54,39, 41,25,19, 4,1,2, 5,1,3, 10,8,10, 5,10,5, 34,16,8, 133,82,72, +166,115,94, 171,125,100, 176,127,102, 184,132,105, 190,135,106, 189,133,106, 188,134,109, 179,129,106, 173,120,97, 172,117,93, 170,120,95, +158,110,85, 155,107,82, 171,119,94, 182,126,102, 187,132,109, 181,125,101, 172,109,80, 148,91,62, 100,59,40, 25,7,3, 5,2,2, +3,5,6, 4,3,5, 14,8,10, 26,15,14, 37,18,15, 58,32,26, 74,40,32, 93,59,48, 90,59,49, 108,71,61, 142,102,87, +150,113,89, 181,157,129, 160,148,126, 137,132,117, 123,121,106, 108,104,92, 100,95,84, 99,93,84, 98,91,85, +//* Line # 27 +50,58,54, 54,61,58, 57,63,64, 56,62,59, 57,66,61, 59,68,64, 72,76,74, 78,71,66, 106,89,78, 171,130,111, 157,108,82, +113,72,49, 112,78,64, 112,72,59, 108,69,56, 50,31,26, 3,1,2, 7,3,5, 10,8,9, 11,10,8, 34,19,14, 95,56,45, +161,113,90, 167,122,95, 177,131,102, 183,134,105, 189,141,110, 191,145,113, 189,143,114, 178,131,106, 171,119,94, 169,116,90, 177,125,100, +172,122,98, 158,108,84, 162,111,87, 176,125,99, 185,133,110, 175,125,101, 168,112,81, 157,93,66, 109,63,44, 22,10,4, 2,1,0, +7,5,8, 8,8,10, 11,7,9, 32,22,23, 60,46,45, 71,52,51, 60,39,37, 38,19,16, 35,21,14, 47,22,15, 85,47,35, +154,110,91, 200,164,142, 199,180,163, 181,173,161, 134,126,111, 117,109,95, 121,113,100, 104,96,86, 96,90,82, +//* Line # 28 +49,56,53, 52,58,57, 53,61,64, 57,64,61, 61,67,61, 73,79,77, 76,74,76, 98,82,74, 148,118,97, 176,116,90, 118,75,54, +103,81,65, 107,77,61, 129,83,67, 114,73,63, 58,37,34, 7,4,4, 5,4,3, 10,4,5, 17,10,13, 25,13,14, 57,32,23, +142,99,77, 169,116,87, 179,122,95, 187,131,104, 191,140,114, 189,144,116, 188,141,114, 183,126,101, 168,111,83, 171,118,88, 185,130,104, +188,133,109, 170,115,92, 161,108,84, 169,119,92, 180,126,100, 173,121,90, 165,111,75, 159,92,66, 112,66,51, 14,11,5, 0,3,2, +8,1,4, 14,6,5, 22,10,8, 38,21,19, 37,18,16, 32,15,14, 28,15,14, 28,19,18, 32,25,21, 52,37,34, 78,47,41, +120,76,63, 182,138,123, 216,185,171, 191,173,161, 138,123,107, 129,114,99, 131,117,103, 118,107,95, 94,85,76, +//* Line # 29 +46,52,53, 49,55,56, 54,62,65, 57,63,62, 75,79,75, 73,75,71, 80,73,69, 123,101,87, 158,120,96, 139,85,61, 112,73,55, +101,78,65, 112,82,67, 136,90,74, 119,77,65, 62,35,30, 13,8,8, 11,7,8, 8,3,4, 15,10,13, 19,11,14, 21,3,2, +105,67,51, 162,111,82, 175,116,86, 182,122,94, 183,127,99, 183,134,105, 185,137,108, 176,121,95, 170,112,85, 173,117,88, 180,124,97, +181,125,101, 161,107,82, 161,108,82, 170,117,90, 175,120,93, 173,118,89, 166,109,76, 156,93,69, 108,67,53, 13,7,3, 1,1,1, +14,4,7, 19,8,9, 29,14,13, 31,12,11, 34,12,10, 39,19,17, 49,32,32, 43,26,24, 56,34,28, 56,33,27, 90,60,50, +102,63,45, 141,98,76, 176,139,120, 196,166,151, 160,140,124, 142,123,108, 137,120,106, 141,125,114, 105,91,82, +//* Line # 30 +47,52,54, 51,56,58, 55,62,63, 62,66,66, 73,72,71, 70,66,61, 97,83,71, 151,120,99, 161,112,84, 124,74,52, 109,73,58, +100,76,65, 124,93,79, 132,88,70, 124,82,65, 69,36,28, 23,12,13, 15,9,10, 10,4,4, 8,3,7, 25,19,22, 19,7,8, +58,30,20, 150,102,75, 172,112,81, 179,116,87, 182,122,92, 181,129,97, 180,129,100, 174,119,93, 171,112,85, 167,108,79, 171,113,87, +171,115,90, 164,108,84, 161,106,81, 169,112,86, 169,113,86, 171,114,85, 167,106,78, 152,95,73, 94,62,50, 9,2,0, 11,5,6, +24,12,15, 23,11,12, 34,16,17, 39,17,17, 46,21,20, 57,33,31, 53,31,31, 45,22,21, 48,18,16, 53,30,27, 54,32,23, +89,60,42, 124,87,64, 161,119,100, 172,133,117, 200,173,155, 192,167,151, 151,128,115, 139,118,107, 116,97,87, +//* Line # 31 +56,58,59, 63,64,65, 64,68,64, 73,71,71, 79,72,73, 81,71,64, 140,120,100, 180,141,113, 161,103,73, 131,83,59, 119,83,68, +110,80,70, 131,96,82, 134,92,69, 138,94,74, 77,37,27, 37,19,19, 22,10,11, 19,9,8, 8,3,5, 14,11,13, 43,30,30, +38,16,14, 112,68,47, 168,111,82, 177,113,84, 181,117,87, 180,123,91, 178,124,94, 175,118,91, 177,116,90, 173,113,86, 166,109,84, +162,107,83, 160,107,83, 157,101,78, 165,107,83, 166,111,84, 170,112,85, 167,105,81, 146,100,79, 64,43,35, 5,0,0, 24,14,15, +24,13,14, 28,15,18, 31,13,14, 45,21,20, 42,15,13, 45,19,17, 53,29,27, 42,17,16, 47,21,23, 45,29,31, 28,16,13, +57,38,26, 133,100,83, 180,137,119, 204,161,145, 227,196,175, 191,162,144, 161,135,119, 133,109,96, 127,102,90, +//* Line # 32 +69,66,64, 73,70,67, 78,77,68, 89,81,79, 99,86,87, 97,81,70, 174,148,122, 180,136,103, 161,97,67, 131,82,56, 128,87,70, +130,91,80, 139,100,83, 137,95,69, 141,96,73, 89,44,32, 49,24,22, 31,13,11, 26,11,8, 17,10,10, 7,4,7, 32,23,24, +63,42,39, 81,44,29, 150,99,75, 174,112,87, 180,115,86, 181,121,89, 177,121,89, 176,118,90, 173,113,88, 160,99,76, 157,101,78, +160,108,86, 160,109,88, 142,89,67, 128,71,49, 158,105,79, 166,110,83, 166,103,81, 131,95,75, 22,14,10, 11,3,3, 29,16,16, +20,11,10, 25,14,16, 27,10,11, 39,15,14, 48,21,18, 54,27,24, 56,31,27, 44,21,18, 41,22,24, 33,23,26, 26,16,17, +61,40,33, 89,53,38, 147,100,82, 200,153,135, 206,171,148, 188,156,136, 159,132,115, 147,121,107, 169,142,128, +//* Line # 33 +82,76,69, 85,79,72, 95,89,74, 103,90,87, 106,87,89, 117,96,85, 172,143,112, 174,127,90, 167,99,69, 144,93,64, 138,92,72, +132,87,75, 152,109,90, 148,106,77, 151,107,81, 104,56,43, 61,31,28, 44,21,17, 38,20,13, 26,17,15, 12,9,11, 13,4,6, +40,18,17, 77,45,31, 118,73,54, 173,113,92, 181,115,88, 183,120,89, 178,121,89, 178,118,88, 146,85,61, 141,82,62, 175,122,101, +186,138,118, 175,127,108, 140,88,70, 133,76,58, 160,110,85, 167,112,84, 166,104,82, 91,63,46, 2,0,0, 15,7,6, 29,16,15, +19,13,10, 17,7,9, 26,11,11, 39,17,16, 48,22,18, 63,37,33, 49,24,19, 43,22,16, 41,26,20, 34,21,22, 38,21,21, +89,57,50, 181,134,118, 201,146,124, 195,141,117, 195,159,133, 183,150,129, 186,158,141, 217,192,177, 209,181,165, +//* Line # 34 +96,86,77, 96,85,76, 105,93,80, 111,94,87, 109,88,83, 131,107,92, 171,138,111, 162,117,85, 173,114,86, 161,105,74, 162,109,83, +151,101,79, 147,101,76, 152,107,79, 162,116,91, 112,63,47, 69,32,24, 54,27,21, 43,24,20, 32,22,20, 18,11,11, 13,3,4, +22,7,8, 37,16,9, 74,41,28, 142,93,73, 173,114,85, 179,117,84, 179,119,87, 176,118,90, 151,91,67, 139,79,56, 141,85,64, +143,89,70, 148,95,77, 150,95,76, 156,98,78, 167,114,88, 163,112,84, 147,99,81, 36,18,13, 0,0,1, 18,12,12, 28,14,13, +23,13,9, 17,6,7, 24,8,8, 40,18,16, 55,31,27, 53,29,25, 47,24,20, 38,21,17, 24,15,12, 24,13,13, 38,19,20, +90,57,53, 137,91,79, 109,55,37, 152,100,80, 201,167,145, 219,186,165, 241,210,188, 233,203,180, 211,181,160, +//* Line # 35 +107,93,84, 109,95,86, 114,97,89, 117,100,88, 116,96,81, 127,101,84, 167,133,113, 131,90,68, 170,126,102, 189,133,104, 193,137,106, +198,147,116, 182,135,105, 174,126,101, 142,93,71, 118,67,48, 76,33,19, 57,27,21, 34,18,18, 28,18,19, 20,10,8, 16,6,4, +16,9,10, 15,6,7, 35,17,11, 79,45,28, 153,103,74, 171,112,79, 174,114,83, 173,116,90, 176,118,91, 165,103,76, 161,100,76, +170,109,89, 171,111,91, 164,105,83, 167,110,84, 174,116,89, 164,114,89, 98,71,58, 3,0,0, 0,0,1, 14,10,12, 33,19,16, +31,14,11, 20,7,7, 34,16,15, 50,28,26, 50,27,25, 46,25,23, 39,22,20, 24,12,11, 18,15,14, 26,19,18, 32,18,18, +41,19,18, 56,26,23, 59,23,18, 93,52,45, 146,103,91, 179,134,116, 177,130,107, 165,120,93, 156,115,92, +//* Line # 36 +109,95,86, 109,95,85, 110,95,84, 116,100,88, 117,100,85, 115,94,77, 153,126,107, 110,79,59, 116,79,59, 155,108,82, 182,136,108, +212,168,141, 215,175,149, 198,153,129, 187,136,115, 124,69,50, 72,30,17, 53,24,19, 30,15,15, 23,14,15, 19,10,8, 19,9,7, +19,11,11, 6,1,1, 25,11,8, 50,19,10, 101,53,36, 152,94,71, 169,109,82, 171,115,85, 174,116,86, 175,116,87, 171,112,86, +167,108,85, 169,111,88, 177,119,95, 178,122,96, 173,115,87, 160,108,83, 73,43,31, 6,0,0, 0,0,2, 12,8,11, 30,17,15, +28,12,10, 27,12,15, 37,19,20, 41,19,19, 37,15,14, 26,8,6, 20,6,6, 26,16,13, 23,19,10, 22,16,10, 24,16,11, +32,20,16, 36,18,15, 64,41,37, 100,69,62, 148,94,80, 167,113,94, 163,108,86, 148,96,74, 144,98,80, +//* Line # 37 +109,95,84, 108,94,83, 110,95,81, 111,96,83, 115,101,85, 108,92,76, 128,108,91, 119,95,79, 105,77,61, 136,99,78, 123,86,63, +150,115,92, 197,161,139, 205,164,143, 190,140,121, 129,71,52, 75,33,22, 46,19,15, 28,14,16, 19,11,12, 16,7,5, 20,10,8, +21,12,12, 3,1,1, 18,9,8, 46,17,16, 77,30,23, 115,56,42, 150,90,66, 168,112,79, 173,116,83, 178,118,88, 180,121,92, +182,124,96, 181,124,96, 184,128,100, 177,121,92, 169,110,81, 143,88,63, 72,40,29, 7,0,0, 1,1,3, 7,4,7, 24,13,11, +23,8,7, 30,14,18, 30,12,14, 32,11,12, 30,9,9, 31,14,13, 30,18,17, 22,14,12, 10,7,2, 5,3,0, 9,4,1, +36,26,22, 52,35,31, 46,23,18, 82,52,42, 146,103,80, 187,145,120, 187,145,119, 188,152,127, 185,156,136, +//* Line # 38 +115,101,89, 110,96,84, 111,96,81, 113,99,83, 114,100,84, 111,97,81, 102,85,69, 137,116,101, 121,98,84, 126,94,75, 131,100,81, +107,80,62, 132,103,86, 181,146,129, 189,144,128, 139,84,67, 73,33,23, 40,15,12, 22,9,12, 15,7,10, 15,6,5, 24,14,12, +20,11,11, 4,1,2, 22,11,12, 47,17,17, 83,34,28, 126,67,52, 143,83,57, 152,95,61, 166,108,74, 178,118,86, 182,123,91, +184,125,93, 180,122,90, 175,118,87, 169,112,82, 159,99,69, 138,81,56, 77,42,31, 9,0,0, 1,1,3, 7,6,8, 19,11,10, +22,8,8, 23,9,12, 37,18,20, 39,19,18, 41,20,19, 47,30,28, 27,13,11, 15,7,6, 9,7,12, 9,7,10, 11,5,6, +41,28,24, 48,23,17, 82,46,36, 129,87,73, 166,126,103, 206,164,141, 205,164,141, 198,162,139, 207,178,159, +//* Line # 39 +117,104,90, 115,102,88, 128,111,96, 124,108,92, 119,104,88, 115,99,82, 111,92,76, 118,96,80, 135,109,95, 147,115,98, 161,132,116, +171,148,133, 211,192,179, 204,177,164, 202,165,152, 146,99,84, 68,32,23, 37,14,12, 17,5,8, 14,7,10, 17,8,8, 30,19,16, +16,7,6, 12,3,5, 32,14,14, 58,23,17, 103,51,36, 138,76,53, 158,95,65, 158,98,64, 155,94,60, 167,104,71, 174,112,77, +175,114,78, 169,109,74, 161,101,68, 163,104,73, 161,97,68, 138,79,53, 82,45,33, 9,0,0, 0,0,3, 3,4,6, 12,5,5, +27,16,14, 22,9,9, 32,14,13, 43,21,19, 55,31,29, 50,28,26, 40,21,19, 24,10,11, 14,6,14, 13,7,12, 16,8,10, +29,14,12, 39,13,7, 65,26,18, 102,56,46, 135,82,68, 163,109,94, 165,110,95, 151,98,84, 132,83,70, +//* Line # 40 +123,110,95, 124,110,95, 139,121,106, 134,116,100, 127,109,93, 123,104,86, 122,99,82, 124,96,80, 127,96,80, 152,117,101, 168,138,123, +186,165,154, 218,202,192, 233,215,206, 208,179,169, 139,101,88, 68,34,27, 41,18,18, 13,2,6, 8,2,5, 20,11,10, 27,16,13, +10,2,2, 23,9,12, 43,18,16, 85,44,29, 127,71,44, 147,83,48, 164,99,63, 167,104,72, 165,102,69, 166,99,66, 171,107,70, +174,110,72, 170,107,70, 167,104,69, 168,105,74, 162,96,66, 134,74,49, 89,53,37, 10,1,0, 0,0,3, 1,1,3, 6,2,2, +18,9,6, 29,18,14, 35,18,14, 50,27,23, 62,36,32, 64,37,33, 51,26,24, 43,20,18, 30,12,9, 20,7,5, 18,10,8, +21,12,10, 25,10,10, 36,12,12, 48,16,14, 83,38,28, 107,59,48, 118,68,56, 112,61,48, 155,105,90, +//* Line # 41 +137,124,106, 137,125,106, 145,126,111, 160,139,125, 178,157,144, 169,148,136, 186,165,152, 203,182,168, 221,201,186, 228,197,182, 208,176,161, +212,184,170, 221,201,189, 239,223,213, 216,188,180, 123,86,80, 67,36,29, 35,14,16, 14,4,11, 12,9,9, 19,15,11, 11,3,3, +18,9,8, 41,16,12, 73,35,25, 111,62,42, 136,78,46, 154,89,52, 164,100,62, 166,103,69, 170,106,73, 172,106,73, 173,108,73, +175,111,74, 172,107,72, 172,108,73, 170,106,74, 157,92,60, 132,71,43, 109,66,49, 31,9,7, 4,0,2, 1,1,4, 2,1,4, +6,1,3, 17,7,7, 33,17,15, 45,22,17, 55,27,22, 50,22,17, 46,23,22, 37,18,16, 40,21,14, 35,20,14, 30,21,16, +27,21,18, 30,20,19, 38,22,25, 52,31,32, 73,46,36, 80,46,34, 96,53,38, 129,81,63, 165,118,98, +//* Line # 42 +151,138,116, 154,140,117, 162,142,123, 189,166,150, 226,200,190, 221,193,186, 218,192,185, 225,206,196, 215,199,188, 228,196,174, 204,165,138, +187,146,116, 179,137,108, 199,158,133, 206,164,146, 127,84,72, 69,40,29, 44,22,28, 25,13,24, 18,16,10, 7,6,1, 17,5,9, +39,21,18, 77,37,23, 108,56,38, 126,70,48, 142,83,54, 153,92,59, 160,98,63, 167,107,71, 171,109,75, 174,109,77, 174,110,77, +177,113,80, 173,109,76, 174,110,76, 172,107,74, 153,89,55, 131,70,39, 124,72,54, 73,35,31, 32,12,16, 4,1,4, 1,1,5, +0,1,5, 2,2,5, 13,8,7, 24,12,7, 40,17,12, 48,23,20, 32,17,17, 24,14,15, 29,14,12, 27,15,12, 26,14,12, +28,17,14, 28,13,11, 33,14,14, 40,20,19, 48,26,20, 67,35,24, 125,79,62, 156,101,80, 149,95,77, +//* Line # 43 +166,148,124, 172,152,127, 179,159,131, 189,164,139, 200,172,153, 188,152,137, 147,103,91, 163,121,110, 136,90,77, 175,126,94, 221,172,134, +217,167,128, 210,159,120, 205,157,120, 209,161,130, 127,80,53, 76,45,29, 45,21,24, 27,10,15, 18,7,2, 18,3,0, 41,14,19, +72,39,33, 102,58,43, 115,63,45, 134,79,57, 147,90,63, 153,93,62, 159,97,65, 167,106,73, 172,110,77, 175,112,79, 176,113,79, +177,114,80, 174,112,78, 174,110,77, 170,107,73, 147,84,52, 130,70,42, 128,76,58, 91,51,44, 46,19,19, 12,0,1, 6,0,0, +2,0,0, 0,2,1, 0,3,0, 5,4,2, 17,7,6, 43,24,25, 32,14,16, 24,10,10, 32,16,15, 27,14,12, 21,9,8, +18,7,5, 17,6,4, 25,11,10, 28,13,12, 43,22,16, 64,34,25, 124,83,69, 163,115,98, 140,92,75, +//* Line # 44 +182,156,130, 186,159,132, 177,147,117, 193,164,138, 216,183,161, 174,129,112, 170,119,105, 163,108,95, 153,98,83, 146,89,69, 144,86,64, +145,87,65, 147,90,68, 131,78,57, 125,74,57, 76,26,13, 49,16,3, 36,8,7, 38,12,11, 48,23,12, 78,47,43, 85,42,49, +105,57,48, 109,59,40, 111,60,41, 124,71,49, 136,80,56, 143,85,58, 153,94,65, 161,102,70, 171,110,78, 176,114,81, 177,115,82, +177,115,82, 173,111,78, 172,110,78, 163,101,68, 145,83,52, 129,71,46, 122,69,50, 109,65,53, 63,26,20, 59,29,25, 44,18,15, +26,9,7, 10,3,1, 2,3,0, 0,1,0, 5,0,1, 28,13,16, 36,19,19, 27,11,9, 52,35,34, 40,24,23, 31,18,15, +28,16,13, 29,18,15, 35,25,22, 45,33,30, 58,39,34, 59,34,27, 82,49,38, 110,71,58, 115,75,61, +//* Line # 45 +198,167,139, 187,151,123, 182,136,113, 219,173,152, 182,135,118, 177,131,116, 181,137,122, 179,135,119, 177,133,116, 178,125,112, 171,116,103, +162,106,93, 153,98,86, 144,92,81, 130,83,73, 111,65,57, 89,53,39, 83,50,42, 97,61,54, 120,83,68, 142,97,96, 111,56,66, +144,87,77, 145,92,71, 136,85,66, 131,79,58, 128,75,53, 128,73,49, 134,77,51, 144,86,59, 158,98,68, 167,106,75, 174,114,83, +172,112,81, 166,105,75, 166,105,75, 155,94,63, 142,82,54, 122,64,42, 113,60,40, 108,60,43, 75,32,20, 80,38,29, 97,55,49, +83,41,35, 63,25,19, 40,13,8, 29,10,8, 22,4,5, 24,6,6, 37,21,17, 25,11,6, 44,25,23, 53,33,31, 34,16,13, +33,17,13, 33,18,14, 30,17,14, 37,24,20, 40,22,19, 39,19,14, 43,19,13, 79,51,44, 109,77,67, +//* Line # 46 +207,172,144, 178,137,109, 191,134,114, 177,121,103, 173,123,106, 173,128,113, 172,131,115, 171,133,115, 173,135,116, 177,133,110, 175,127,104, +173,124,102, 169,121,99, 165,119,97, 159,115,94, 150,109,87, 142,103,84, 138,99,86, 142,99,86, 147,101,84, 144,91,94, 115,55,70, +156,98,88, 160,106,84, 153,102,82, 150,99,80, 147,96,76, 146,93,73, 152,97,74, 150,92,67, 150,90,64, 154,94,68, 159,99,73, +158,98,71, 152,92,66, 155,96,69, 141,81,54, 130,71,48, 114,57,37, 105,51,30, 103,52,32, 92,43,28, 91,41,31, 89,38,33, +108,51,47, 109,48,38, 101,52,41, 86,45,34, 64,25,17, 50,17,11, 41,19,12, 29,12,5, 33,10,6, 38,15,10, 44,19,15, +47,21,17, 41,19,14, 45,24,19, 35,15,10, 32,16,14, 35,20,17, 28,13,11, 41,23,19, 62,37,30, +//* Line # 47 +196,158,130, 190,146,119, 168,110,86, 173,116,94, 172,120,99, 172,125,104, 173,127,107, 178,131,111, 180,133,112, 179,134,112, 177,131,109, +175,127,108, 172,122,104, 170,120,103, 166,119,100, 160,114,94, 157,113,93, 158,113,97, 160,111,93, 157,107,88, 145,88,96, 116,58,78, +157,104,95, 157,106,82, 157,105,85, 158,108,89, 156,106,89, 155,104,86, 158,105,84, 166,110,87, 159,100,77, 154,94,72, 148,89,66, +148,88,65, 151,91,69, 154,94,72, 147,88,65, 145,85,66, 141,83,66, 139,84,63, 139,86,65, 140,87,70, 143,89,79, 111,55,53, +137,78,72, 148,88,68, 139,83,61, 124,70,46, 114,60,39, 104,56,44, 69,36,28, 36,13,5, 48,24,15, 54,26,20, 70,40,34, +56,24,20, 67,36,31, 67,38,32, 51,25,19, 25,12,11, 27,16,16, 20,12,11, 21,10,8, 39,20,15, +//* Line # 48 +180,141,112, 183,135,108, 162,105,78, 173,118,92, 173,121,96, 174,124,101, 176,126,105, 180,128,107, 181,129,108, 178,130,114, 176,128,114, +175,125,114, 174,122,112, 174,122,112, 174,123,112, 171,120,110, 169,123,103, 168,119,107, 163,118,101, 166,111,94, 146,89,99, 123,62,86, +157,110,98, 156,106,86, 156,104,84, 156,107,88, 160,110,92, 161,110,92, 157,105,85, 163,108,87, 164,107,86, 159,101,80, 151,93,73, +154,97,76, 159,102,81, 158,101,80, 158,100,79, 156,99,80, 154,99,80, 155,101,79, 156,104,80, 158,106,84, 161,107,93, 130,74,68, +118,61,57, 130,76,60, 128,75,45, 130,74,46, 138,81,59, 134,80,58, 107,61,46, 47,14,9, 53,29,26, 70,39,32, 87,48,39, +90,47,36, 87,45,34, 90,52,42, 91,58,50, 53,28,21, 27,10,8, 23,11,11, 15,6,7, 38,22,20, +//* Line # 49 +179,138,109, 177,125,96, 159,103,78, 173,118,94, 175,121,98, 175,123,101, 176,126,105, 176,127,108, 176,129,110, 176,128,110, 173,125,107, +173,125,108, 176,127,111, 174,126,112, 177,128,115, 176,127,114, 174,132,108, 175,126,121, 166,127,115, 177,120,104, 145,88,99, 133,66,92, +161,118,99, 157,108,95, 157,108,89, 155,105,86, 157,107,88, 160,108,88, 160,108,88, 158,106,85, 160,106,86, 162,107,87, 158,103,83, +160,105,84, 161,106,85, 158,104,83, 156,101,80, 157,104,84, 157,106,85, 156,106,81, 156,106,78, 156,105,79, 153,101,81, 135,82,67, +106,50,50, 119,63,64, 121,69,41, 129,75,53, 138,83,68, 142,90,59, 135,81,54, 74,28,22, 42,19,19, 84,49,43, 101,55,41, +111,58,40, 131,80,61, 95,50,35, 97,55,40, 104,60,43, 53,21,11, 31,13,11, 27,15,17, 27,12,11, +//* Line # 50 +190,148,119, 169,116,89, 158,101,76, 171,116,91, 175,121,98, 176,123,101, 177,126,105, 178,128,107, 177,127,107, 174,126,108, 173,125,108, +172,124,107, 173,126,110, 175,128,114, 180,133,120, 182,135,123, 180,137,115, 179,131,124, 170,130,116, 178,123,110, 142,84,98, 144,80,100, +164,120,102, 161,113,98, 161,112,93, 157,108,89, 154,104,85, 155,104,85, 159,108,88, 158,106,85, 155,102,81, 158,104,84, 161,107,87, +158,105,84, 155,101,81, 153,99,78, 153,99,78, 156,103,83, 156,105,85, 156,105,83, 154,103,77, 152,100,76, 150,98,78, 142,90,75, +111,56,54, 123,66,68, 130,76,57, 131,78,59, 137,83,65, 139,88,57, 140,88,60, 118,70,56, 58,23,15, 66,26,17, 98,53,41, +108,59,46, 133,86,70, 126,81,65, 87,42,25, 104,59,43, 85,51,41, 42,20,17, 30,14,15, 34,14,13, +//* Line # 51 +182,139,112, 164,109,83, 162,105,80, 169,113,89, 174,119,94, 176,122,98, 175,122,100, 175,122,100, 175,123,102, 173,124,104, 171,121,103, +172,124,106, 175,128,112, 174,128,114, 181,136,123, 182,138,126, 181,138,119, 178,132,123, 172,129,114, 176,122,114, 138,76,96, 158,97,108, +171,125,109, 167,119,104, 163,115,97, 161,113,95, 159,109,91, 159,108,90, 159,108,88, 158,107,87, 156,105,84, 155,102,82, 158,105,85, +156,103,83, 154,102,82, 153,101,81, 152,100,80, 154,102,83, 155,104,85, 154,103,82, 151,101,78, 152,102,79, 151,100,81, 147,96,80, +123,69,63, 111,54,58, 139,85,77, 136,84,72, 135,84,64, 138,87,57, 141,90,61, 142,89,69, 120,72,53, 74,28,13, 65,20,9, +91,48,36, 114,69,56, 126,79,62, 110,62,42, 85,38,22, 96,58,48, 47,21,18, 28,7,7, 44,19,18, +//* Line # 52 +163,119,93, 163,108,83, 168,111,86, 171,115,90, 177,121,96, 176,121,96, 175,121,97, 175,121,97, 174,120,96, 172,119,97, 167,114,94, +171,120,101, 173,124,107, 173,127,111, 180,136,122, 184,141,128, 184,140,123, 178,135,124, 178,133,115, 177,124,122, 136,71,96, 165,109,109, +170,123,109, 166,121,104, 166,118,102, 165,117,99, 166,117,99, 162,112,94, 160,110,91, 158,107,88, 157,106,86, 155,104,84, 155,104,84, +158,106,86, 159,108,88, 160,109,89, 158,106,87, 156,105,86, 155,105,86, 154,103,84, 153,103,82, 152,102,82, 151,101,83, 150,99,82, +142,88,77, 110,53,54, 136,81,85, 142,91,85, 139,91,68, 138,89,60, 143,91,64, 150,95,69, 151,95,69, 136,85,65, 100,54,40, +76,32,20, 83,37,23, 113,63,44, 126,75,53, 95,46,31, 75,34,24, 65,35,30, 46,20,19, 49,21,19, +//* Line # 53 +172,128,103, 162,105,82, 171,114,89, 173,117,91, 177,120,95, 177,121,95, 178,121,96, 176,120,95, 174,117,92, 170,112,87, 164,107,83, +170,115,93, 174,123,102, 175,128,109, 183,138,120, 184,141,125, 184,138,123, 176,135,123, 181,135,113, 172,122,125, 135,67,98, 174,121,112, +175,127,114, 167,123,105, 166,119,103, 164,117,100, 165,117,100, 163,114,96, 162,112,93, 160,110,91, 159,109,89, 156,106,87, 154,104,85, +154,104,85, 158,108,89, 160,111,91, 162,112,91, 160,111,92, 160,110,92, 158,108,90, 156,107,88, 155,105,87, 154,105,86, 154,103,85, +155,103,85, 129,72,69, 119,64,77, 146,96,94, 142,97,72, 140,93,66, 143,91,67, 148,93,67, 154,98,71, 153,98,76, 150,98,80, +145,94,78, 121,70,53, 102,50,29, 106,55,33, 108,60,45, 68,27,16, 53,21,14, 97,70,65, 53,25,20, +//* Line # 54 +158,113,89, 165,106,85, 171,113,88, 174,117,91, 175,118,92, 177,120,93, 176,118,91, 175,118,91, 172,114,87, 169,106,80, 162,101,75, +169,111,86, 175,121,97, 176,126,105, 180,134,115, 182,138,119, 183,136,122, 176,137,124, 186,138,114, 165,117,121, 138,67,102, 182,131,115, +177,126,115, 168,124,107, 165,119,102, 161,114,98, 162,115,97, 161,113,95, 161,112,94, 162,113,94, 162,114,94, 162,114,94, 162,113,94, +160,111,92, 159,110,91, 160,111,91, 160,112,92, 161,112,92, 161,111,94, 160,111,94, 158,109,92, 157,108,91, 155,106,88, 154,105,86, +156,105,82, 150,92,84, 110,54,74, 143,95,94, 144,102,73, 143,96,72, 144,91,72, 148,93,68, 152,98,74, 157,101,78, 160,103,80, +161,102,80, 160,104,82, 147,94,72, 123,72,52, 93,47,32, 76,36,24, 49,17,9, 52,25,19, 57,29,23, +//* Line # 55 +157,111,87, 170,110,87, 171,113,85, 175,118,90, 176,119,91, 177,119,92, 175,117,89, 177,118,90, 174,115,86, 165,102,72, 160,97,70, +168,106,83, 173,116,92, 178,125,102, 179,131,110, 182,136,118, 183,140,126, 180,141,123, 188,134,121, 156,95,122, 147,74,110, 185,134,112, +172,127,112, 167,125,109, 166,119,104, 162,114,99, 163,112,98, 162,111,96, 162,113,95, 160,114,95, 163,115,95, 167,118,100, 167,120,102, +165,118,100, 164,116,99, 162,114,95, 160,112,93, 160,111,92, 161,111,92, 162,112,95, 160,110,94, 159,109,93, 157,107,90, 154,104,87, +154,105,82, 156,105,93, 113,56,78, 119,63,78, 151,102,89, 148,100,80, 147,96,76, 148,95,72, 151,98,76, 156,100,77, 162,101,77, +164,102,77, 163,103,77, 161,106,82, 158,106,82, 143,92,71, 105,60,44, 64,27,15, 54,22,13, 63,32,23, +//* Line # 56 +158,112,87, 174,111,85, 170,111,79, 175,117,86, 177,118,90, 176,117,90, 177,117,90, 179,119,90, 176,116,86, 163,101,70, 149,85,60, +168,104,84, 175,114,92, 180,125,99, 179,129,106, 182,135,119, 180,143,129, 186,144,121, 178,112,126, 135,50,115, 140,63,102, 181,127,110, +169,132,112, 164,124,111, 165,119,104, 161,110,98, 160,106,95, 160,106,95, 159,110,94, 159,114,95, 162,114,95, 168,117,102, 169,121,106, +167,121,108, 166,121,107, 163,117,101, 159,113,94, 162,113,94, 164,113,95, 161,110,93, 158,107,92, 157,106,92, 156,105,91, 156,104,89, +151,105,87, 149,109,93, 122,62,79, 109,37,83, 144,79,110, 155,103,90, 148,102,74, 146,96,77, 149,95,72, 155,99,76, 162,103,78, +165,106,79, 165,106,78, 166,109,80, 165,107,78, 164,103,74, 146,91,67, 111,64,45, 70,30,16, 65,29,18, +//* Line # 57 +166,121,93, 171,111,81, 169,110,77, 173,115,84, 175,116,88, 176,116,91, 178,119,92, 179,120,92, 178,119,90, 168,106,75, 138,75,49, +166,103,80, 176,115,89, 180,125,94, 183,133,105, 184,136,115, 183,141,120, 193,141,134, 149,76,107, 133,45,109, 137,54,105, 171,107,122, +178,129,129, 164,124,110, 161,121,100, 159,114,96, 157,109,92, 157,105,89, 155,104,87, 158,109,91, 163,113,95, 168,118,102, 172,124,109, +174,128,113, 172,127,112, 170,125,108, 167,119,102, 164,116,99, 161,113,97, 159,112,96, 159,111,95, 157,108,92, 154,106,90, 154,105,89, +150,107,89, 150,110,91, 131,69,80, 122,40,105, 124,46,108, 156,97,96, 152,105,79, 148,99,86, 148,94,69, 151,96,69, 157,100,71, +166,106,78, 169,110,82, 169,112,84, 167,109,82, 166,105,77, 153,98,73, 124,76,57, 75,35,20, 57,22,12, +//* Line # 58 +184,143,111, 171,112,79, 173,113,80, 173,114,83, 174,115,87, 176,116,90, 176,117,91, 178,120,93, 180,122,94, 173,111,81, 144,81,54, +161,99,73, 177,117,87, 181,125,90, 185,134,102, 182,134,110, 187,136,115, 182,118,131, 133,50,103, 142,50,115, 144,54,117, 137,59,110, +182,120,146, 173,127,122, 163,124,107, 160,117,99, 155,110,90, 153,106,85, 153,102,82, 157,104,86, 162,109,92, 167,117,98, 172,124,108, +176,130,115, 174,130,115, 174,129,113, 172,124,107, 168,122,107, 164,118,106, 161,114,101, 157,112,96, 157,112,95, 155,110,92, 155,108,92, +151,110,91, 149,107,91, 133,65,88, 127,37,115, 126,39,120, 133,65,92, 159,107,98, 150,100,88, 148,95,68, 147,93,64, 152,95,65, +163,104,74, 171,112,83, 171,113,88, 170,112,87, 172,111,83, 160,104,78, 134,83,62, 79,37,21, 63,28,18, +}; + + + +//******************************************************************************* +void DisplayRawRGB(uint8_t *rgbData, int xLoc, int yLoc) +{ +int imageWidth, imageHeight; +int byte1, byte2; +long dataIndex; +int ii, jj; +RGBColor myColor; +int myXX, myYY; + + + dataIndex = 0; + byte1 = pgm_read_byte(rgbData + dataIndex++); + byte2 = pgm_read_byte(rgbData + dataIndex++); + imageWidth = (byte1 << 8) + byte2; + byte1 = pgm_read_byte(rgbData + dataIndex++); + byte2 = pgm_read_byte(rgbData + dataIndex++); + imageHeight = (byte1 << 8) + byte2; + + //* if x,y are negitive, then center + myXX = xLoc; + myYY = yLoc; + if (myXX < 0) + { + myXX = (gWidth - imageWidth) / 2; + } + if (myYY < 0) + { + myYY = (gHeight - imageHeight) / 2; + } + if (imageWidth < 100) + { + myXX = 0; + myYY = 0; + } + for (jj=0; jj +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + +#---------------- Programming Options (STK500) ---------------- +# Programming hardware: stk500 + +STK500 = stk500 + +# Location of STK500.exe - no trailing '\' +STK500_PATH = C:\Program Files\Atmel\AVR Tools\STK500 + +# The STK500 AVR ISP MKII is USB. The USB drivers must already be installed. +# Do this normally by installing AVR Studio. +STK500_PORT = USB + +#-erase chip -Program Flash -Verify Flash -File name -Serial programing(ISP) +STK500_WRITE_FLASH = -e -pf -vf -if$(TARGET).hex -ms +STK500_WRITE_FLASH += -s + +#Program the Fuse Bytes +#STK500_FLAGS = -d$(MCU) -c$(STK500_PORT) -fFF79 -FFF79 +#Skip the Fuse Bytes +STK500_FLAGS = -d$(MCU) -c$(STK500_PORT) + +#-Set ISP frequency to 250kHz. Limit is 1/4 of internal osc which is default 1MHz +STK500_FLAGS += -I250kHz + +#---------------- Programming Options (avrdude serial bootloader) ---------------- + +#"C:\arduino\hardware\tools\avr\bin\avrdude" -PCOM28 -c stk500v1 -patmega168 -b19200 -Uflash:w:Simon-PTH-v1.hex -V -F -C"C:\arduino\hardware\tools\avr\etc\avrdude.conf" +SERIAL_AVRDUDE = "C:\Documents and Settings\Administrator\Desktop\Arduino 16\arduino-0016\hardware\tools\avr\bin\avrdude" +SERIAL_AVRDUDE_CONFIG = "C:\Documents and Settings\Administrator\Desktop\Arduino 16\arduino-0016\hardware\tools\avr\etc\avrdude.conf" +SERIAL_AVRDUDE_PORT = COM2 +SERIAL_AVRDUDE_SPEED = 57600 +SERIAL_AVRDUDE_PROGRAMMER = stk500v1 + +SERIAL_AVRDUDE_FLAGS = -p $(MCU) -P $(SERIAL_AVRDUDE_PORT) -c $(SERIAL_AVRDUDE_PROGRAMMER) -b $(SERIAL_AVRDUDE_SPEED) +SERIAL_AVRDUDE_FLAGS += -C$(SERIAL_AVRDUDE_CONFIG) +SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + +#---------------- Debugging Options ---------------- + +# For simulavr only - target MCU frequency. +DEBUG_MFREQ = $(F_CPU) + +# Set the DEBUG_UI to either gdb or insight. +# DEBUG_UI = gdb +DEBUG_UI = insight + +# Set the debugging back-end to either avarice, simulavr. +DEBUG_BACKEND = avarice +#DEBUG_BACKEND = simulavr + +# GDB Init Filename. +GDBINIT_FILE = __avr_gdbinit + +# When using avarice settings for the JTAG +JTAG_DEV = /dev/com1 + +# Debugging port used to communicate between GDB / avarice / simulavr. +DEBUG_PORT = 4242 + +# Debugging host used to communicate between GDB / avarice / simulavr, normally +# just set to localhost unless doing some sort of crazy debugging when +# avarice is running on a different computer. +DEBUG_HOST = localhost + + + +#============================================================================ + + +# Define programs and commands. +SHELL = sh +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +AR = avr-ar rcs +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +REMOVEDIR = rm -rf +COPY = cp +WINSHELL = cmd + + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling C: +MSG_COMPILING_CPP = Compiling C++: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: +MSG_CREATING_LIBRARY = Creating library: + + + + +# Define all object files. +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) + +# Define all listing files. +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) + + +# Compiler flags to generate dependency files. +GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + + + +# Default target. +all: begin gccversion sizebefore build sizeafter end + +# Change the build target to build a HEX file or a library. +build: elf hex eep lss sym +#build: lib + + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym +LIBNAME=lib$(TARGET).a +lib: $(LIBNAME) + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf + +sizebefore: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +sizeafter: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ + 2>/dev/null; echo; fi + + + +# Display compiler version information. +gccversion : + @$(CC) --version + + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + +program_stk500: $(TARGET).hex $(TARGET).eep + $(STK500_PATH)\$(STK500) $(STK500_FLAGS) $(STK500_WRITE_FLASH) + +program_serial: $(TARGET).hex $(TARGET).eep + $(SERIAL_AVRDUDE) $(SERIAL_AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) + +# Generate avr-gdb config/init file which does the following: +# define the reset signal, load the target file, connect to target, and set +# a breakpoint at main(). +gdb-config: + @$(REMOVE) $(GDBINIT_FILE) + @echo define reset >> $(GDBINIT_FILE) + @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) + @echo end >> $(GDBINIT_FILE) + @echo file $(TARGET).elf >> $(GDBINIT_FILE) + @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) +ifeq ($(DEBUG_BACKEND),simulavr) + @echo load >> $(GDBINIT_FILE) +endif + @echo break main >> $(GDBINIT_FILE) + +debug: gdb-config $(TARGET).elf +ifeq ($(DEBUG_BACKEND), avarice) + @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. + @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ + $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) + @$(WINSHELL) /c pause + +else + @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ + $(DEBUG_MFREQ) --port $(DEBUG_PORT) +endif + @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT = $(OBJCOPY) --debugging +COFFCONVERT += --change-section-address .data-0x800000 +COFFCONVERT += --change-section-address .bss-0x800000 +COFFCONVERT += --change-section-address .noinit-0x800000 +COFFCONVERT += --change-section-address .eeprom-0x810000 + + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Create library from object files. +.SECONDARY : $(TARGET).a +.PRECIOUS : $(OBJ) +%.a: $(OBJ) + @echo + @echo $(MSG_CREATING_LIBRARY) $@ + $(AR) $@ $(OBJ) + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +$(OBJDIR)/%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create object files from C++ source files. +$(OBJDIR)/%.o : %.cpp + @echo + @echo $(MSG_COMPILING_CPP) $< + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C++ source files. +%.s : %.cpp + $(CC) -S $(ALL_CPPFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +$(OBJDIR)/%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + + +# Target: clean project. +clean: begin clean_list end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lss + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) $(SRC:.c=.i) + $(REMOVEDIR) .dep + + +# Create object files directory +$(shell mkdir $(OBJDIR) 2>/dev/null) + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff \ +clean clean_list program debug gdb-config + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/fromOriginal/main.c b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/fromOriginal/main.c new file mode 100644 index 0000000..5261f9f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/SparkLCD/fromOriginal/main.c @@ -0,0 +1,121 @@ +//******************************************************* +// Nokia Shield +//******************************************************* +#include +#include +#include +#include +#include +#include +#include + +//******************************************************* +// External Component Libs +//******************************************************* +#include "LCD_driver.h" +#include "nokia_tester.h" + +static int uart_putchar(char c, FILE *stream); +uint8_t uart_getchar(void); +static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE); + +int main (void) +{ +//******************************************************* +// Main Code +//******************************************************* + //Initialize ARM I/O + ioinit(); + + printf("Initializing\n"); + + //Show the splash-screen (Sparkfun Logo) + LCDInit(); //Initialize the LCD + + printf("Init. Done\n"); + + LCDClear(BLACK); + printf("Logo..."); + LCDPrintLogo(); + + while(1){ + if((PIND & (1<<3)) == 0) + { + LCDClear(GREEN); + LCDPrintLogo(); + } + if((PIND & (1<<4)) == 0) + { + LCDClear(PINK); + LCDPrintLogo(); + } + if((PIND & (1<<5)) == 0) + { + LCDClear(BLACK); + LCDPrintLogo(); + } + } + return 0; +} + +void ioinit(void) +{ + DDRB = ((1<> 8) & 0x7F; //Make sure highest bit(URSEL) is 0 indicating we are writing to UBRRH + UBRR0L = MYUBRR; + UCSR0A = (1< 0 ; x--) + delay_us(1000); +} + +//General short delays +void delay_us(int x) +{ + TIFR2 = (1<0){ + while( (TIFR2 & (1<0) { + byte l = Serial.read(); + if(l=='L') { + digitalWrite(7, HIGH); + } + else if(l=='D') { + digitalWrite(7, LOW); + } + else if(l=='l') { + digitalWrite(6, HIGH); + } + else if(l=='d') { + digitalWrite(6, LOW); + } + } + +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/br2_android.zip b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/br2_android.zip new file mode 100644 index 0000000..58b7d3a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/br2_android.zip differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/exemplo1/exemplo1.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/exemplo1/exemplo1.ino new file mode 100644 index 0000000..ab05c60 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/exemplo1/exemplo1.ino @@ -0,0 +1,21 @@ + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +void setup() { + pinMode(MOTOR1_A, OUTPUT); + pinMode(MOTOR1_B, OUTPUT); +} + +void loop() { + digitalWrite(MOTOR1_A, 1); + digitalWrite(MOTOR1_B, 0); + analogWrite(MOTOR1_PWM,1023); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/heart/Motores.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/heart/Motores.pde new file mode 100644 index 0000000..728909b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/heart/Motores.pde @@ -0,0 +1,102 @@ +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +int sentido = 0; + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} +void andar(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade); + analogWrite(MOTOR2_PWM,intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + + +void readPing() +{ + /* + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm);*/ +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/heart/heart.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/heart/heart.pde new file mode 100644 index 0000000..e5319a8 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/heart/heart.pde @@ -0,0 +1,95 @@ +#include "Wire.h" +#include "hrmi_funcs.h" +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 +#define MAX_IN_BUFFSIZE 16 + +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use +int leds[] = { + 13, 12, 8, 7, 4}; + +void setup() +{ + hrmi_open(); + Serial.begin(HRMI_HOST_BAUDRATE); + for(int x=0;x<5;x++) { + pinMode(leds[x], OUTPUT); + } +} + + +void loop() +{ + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + + int val = map(i2cRspArray[2], 80,130,0, 150); + + Serial.print(i2cRspArray[2]); + int numeroLedsALigar = map(i2cRspArray[2], 80, 100, 0, 4); + //Serial.println(numeroLedsALigar); + for(int x=0;x<=numeroLedsALigar;x++) { + digitalWrite(leds[x], HIGH); + delay(100); + } + for(int x=numeroLedsALigar;x>-1;x--) { + digitalWrite(leds[x], LOW); + delay(100); + } + + //analogWrite(9, val); + + /*if(i2cRspArray[2]>100) + andar(0, map(i2cRspArray[2], 100, 130, 100,255)); + else parar();*/ + } + if (++numEntries > 30) numEntries = 0; + delay(300); +} + + + + + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/heart/hrmi_funcs.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/heart/hrmi_funcs.cpp new file mode 100644 index 0000000..3fae9aa --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/heart/hrmi_funcs.cpp @@ -0,0 +1,60 @@ +/* + * hrmi_funcs.cpp + * + * Arduino library to communicate with a HRMI using I2C + * + * Written by Dan Julio, www.danjuliodesigns.com + * Version 1.1, 12/28/2008 + * + */ + + #include + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.send(cmd); + Wire.send(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.send(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home1/home1.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home1/home1.ino new file mode 100644 index 0000000..b76084e --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home1/home1.ino @@ -0,0 +1,27 @@ +#include "Device.h" + +Device homeDevice=Device("central-device"); + +void setup() { + homeDevice.add("pwm-aux1", PWM, 3); + homeDevice.add("pwm-aux2", PWM, 5); + homeDevice.add("buzz", PWM, 6); + homeDevice.add("fan", PWM, 9); + + homeDevice.add("speaker", DIGITAL, 4); + homeDevice.add("relay1", DIGITAL, 14); + homeDevice.add("relay2", DIGITAL, 15); + homeDevice.add("relay3", DIGITAL, 7); + homeDevice.add("relay4", DIGITAL, 8); + homeDevice.add("light", ANALOG, 3); + homeDevice.add("temp", ANALOG, 2); + //Starting booth communication! + Serial.begin(115200); + +} + +void loop() { + homeDevice.loop(); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home1_comir/home1_comir.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home1_comir/home1_comir.ino new file mode 100644 index 0000000..5e6f10f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home1_comir/home1_comir.ino @@ -0,0 +1,42 @@ +#include "Device.h" +#include //biblioteca do controle +int RECV_PIN = 6; // colocar o Shield IR receiver module na porta 11 +IRrecv irrecv(RECV_PIN); +decode_results results; +unsigned long codigo;//variável que recebe o código + +Device homeDevice=Device(); + +void setup() { + homeDevice.add("relay1", "RELAY", 14); + homeDevice.add("relay2", "RELAY", 15); + homeDevice.add("relay3", "RELAY", 16); + homeDevice.add("relay4", "RELAY", 17); + homeDevice.add("light", "LIGHT", 3); + homeDevice.add("temperature", "TEMP", 2); + Serial.begin(115200); + irrecv.enableIRIn(); // inicia o recebimento de dados + + +} + +void print() { + Serial.println(homeDevice.read("light")); +} +int state; +void loop() { + //homeDevice.loop(); + if (irrecv.decode(&results)) { + codigo=results.value; // variável "código" recebe dados da "results.value " + Serial.println(codigo, DEC); // mostra o dados na Serial Monitor em decimal + irrecv.resume(); + } + if(codigo==2640478335) { + digitalWrite(14,state); + state=!state; + delay(200); + } + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home2/home2.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home2/home2.ino new file mode 100644 index 0000000..8a4df08 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home2/home2.ino @@ -0,0 +1,29 @@ +#include "Device.h" +#include "etherShield.h" +#include "ETHER_28J60.h" + +Device homeDevice=Device("old-central"); + +void setup() { + homeDevice.add("red", PWM, 5); + homeDevice.add("green", PWM, 6); + homeDevice.add("blue", PWM, 9); + + homeDevice.add("relay1", DIGITAL, 4); + homeDevice.add("relay2", DIGITAL, 2); + homeDevice.add("portao1", DIGITAL, 7); + homeDevice.add("portao2", DIGITAL, 8); + + homeDevice.add("light", ANALOG, 3); + homeDevice.add("temp", ANALOG, 2); + //Starting booth communication! + Serial.begin(115200); + //int ip[]={192,168,1,15}; + //homeDevice.startNetwork(ip); +} + +void loop() { + homeDevice.loop(); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3/HeartMonitor.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3/HeartMonitor.ino new file mode 100644 index 0000000..6cdd89d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3/HeartMonitor.ino @@ -0,0 +1,71 @@ +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 +#define MAX_IN_BUFFSIZE 16 + +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use +boolean heartInit = false; +void heartMonitor_setup() { +} + +char* readHeartBeat() { + if(!heartInit) { + hrmi_open(); + heartInit=true; + } + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + //int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + if (++numEntries > 30) numEntries = 0; + char r[1];// = { i2cRspArray[2] ]}; + return r; + } + else { + char r[1]; return r; + } +} +void writeHeartBeat(char *c) { + +} + +void oldReadHeartBeat() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + Serial.flush(); + } + if (++numEntries > 30) numEntries = 0; +} + +void heartMonitor() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + //} + Serial.println(" "); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Heart Monitor"); + lcd.setCursor(0, 1); + //char c*[]; + //toa(i2cRspArray[2],&c); + String n = String(i2cRspArray[2]); + + lcd.print(i2cRspArray[2],DEC); + + } + if (++numEntries > 30) numEntries = 0; + //Kernel.wait(300); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3/RGB.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3/RGB.ino new file mode 100644 index 0000000..4e091c0 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3/RGB.ino @@ -0,0 +1,85 @@ +char rgb='R'; +long cm; +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = 1; + if(comando[1]=='G') port = 1; + if(comando[1]=='B') port = 1; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + +void rgb_red_setup() { + lcd.setCursor(0, 1); + lcd.print("RED"); + rgb='R'; +} +void rgb_green_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("GREEN"); + rgb='G'; +} +void rgb_blue_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("BLUE"); + rgb='B'; +} +void mode_rgb() { + lcd.clear(); + lcd.setCursor(0, 0); + //readPing(); + //homeDevice.execute("distance"); + int port = 0; + if(rgb=='R') { + port = 3; + lcd.print("RGB Red"); + } + else if(rgb=='G') { + port = 6; + lcd.print("RGB Green"); + } + else if(rgb=='B') { + port = 9; + lcd.print("RGB Blue"); + } + if(cm<10) { + delay(200); + //cm = long(homeDevice.execute("distance")); + //readPing(); + if(cm<10){ + blink(port, 3, 100); + while(cm<50) { + int cmok=cm; + cmok = cmok>25 ? 25 : cmok; + cmok = cmok<5 ? 5 : cmok; + + int amount = map(cmok,5,25,255,0); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(amount); + analogWrite(port, amount); + delay(50); + //cm = atoi(homeDevice.execute("distance")); + } + } + } + delay(150); +} + +void blink(int port, int n, int d) { + pinMode(port, OUTPUT); + for(int x=0;x1000) { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print(homeDevice.execute("distance")); + lcd.setCursor(4, 1); + float temperatura = (analogRead(2) * 0.00488); // 5V / 1023 = 0.00488 (precisão do A/D) + temperatura = temperatura * 100; //Converte milivolts para graus celcius, lembrando que a cada 10mV equivalem a 1 grau celcius + lcd.print(temperatura); + handTimer=millis(); + }*/ + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3/hrmi_funcs.cpp b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3/hrmi_funcs.cpp new file mode 100644 index 0000000..a0c8c46 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3/hrmi_funcs.cpp @@ -0,0 +1,60 @@ +/* + * hrmi_funcs.cpp + * + * Arduino library to communicate with a HRMI using I2C + * + * Written by Dan Julio, www.danjuliodesigns.com + * Version 1.1, 12/28/2008 + * + */ + + #include + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.write(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3_AGAIN/home3_AGAIN.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3_AGAIN/home3_AGAIN.ino new file mode 100644 index 0000000..e7022f3 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3_AGAIN/home3_AGAIN.ino @@ -0,0 +1,34 @@ +#include "Device.h" +#include "etherShield.h" +#include "ETHER_28J60.h" +#include "EEPROM.h" +#include "Ethernet.h" + +Device homeDevice=Device("central-device"); +Ethernet ethernet=Ethernet(&homeDevice); + +void setup() { + homeDevice.add("red", PWM, 3); + homeDevice.add("distance", PING, 5); + homeDevice.add("blue", PWM, 6); + homeDevice.add("fan", PWM, 9); + + homeDevice.add("speaker", DIGITAL, 4); + homeDevice.add("relay1", DIGITAL, 7); + homeDevice.add("relay2", DIGITAL, 8); + homeDevice.add("relay3", DIGITAL, 14); + homeDevice.add("relay4", DIGITAL, 15); + homeDevice.add("light", ANALOG, 3); + homeDevice.add("temp", ANALOG, 2); + //Starting booth communication! + Serial.begin(115200); + int ip[]={192,168,1,15}; + ethernet.startNetwork(ip); +} + +void loop() { + homeDevice.loop(); + ethernet.loop(); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3_basicop/home3_basicop.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3_basicop/home3_basicop.ino new file mode 100644 index 0000000..81f7215 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/home3_basicop/home3_basicop.ino @@ -0,0 +1,78 @@ +//jHome and Electron Kernel includes +//#include "ElectronKernel.h" +#include "Device.h" +#include "etherShield.h" +#include "ETHER_28J60.h" + +//Specific includes to LCD and HR + +Device homeDevice=Device("sensor-device"); + + +long handTimer=0; + +void setup() +{ + homeDevice.add("red", PWM, 3); + homeDevice.add("green", PWM, 6); + homeDevice.add("blue", PWM, 9); + + + homeDevice.add("distance", PING, 5); + + homeDevice.add("light", LIGHT, 3); + homeDevice.add("temp", TEMP, 2); + //Cool jHome Feature: you can add your custom component passing a read / write function pointer + //homeDevice.add("heart", "LIB", I2C, readHeartBeat, writeHeartBeat); + + /*Kernel.setup(INTERRUPTION); + Kernel.registerMode("M1", jhome_setup); + Kernel.registerTask(jhome); + Kernel.registerMode("MH", heartMonitor_setup); + Kernel.registerTask(heartMonitor); + + Kernel.registerMode("M2", rgb_red_setup); + Kernel.registerTask(mode_rgb); + Kernel.registerMode("M3", rgb_green_setup); + Kernel.registerTask(mode_rgb); + Kernel.registerMode("M4", rgb_blue_setup); + Kernel.registerTask(mode_rgb);*/ + + Serial.begin(115200); + int ip[]={192,168,1,15}; + homeDevice.startNetwork(ip); + Serial.println(homeDevice.serial); + /*lcd.init(); + lcd.setBacklight(0); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print("by Globalcode"); + delay(1500);*/ +} + +void loop() +{ + //Kernel.loop(); + jhome(); +} + +void jhome() { + + homeDevice.loop(); + /*if(millis()-handTimer>1000) { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print(homeDevice.execute("distance")); + lcd.setCursor(4, 1); + float temperatura = (analogRead(2) * 0.00488); // 5V / 1023 = 0.00488 (precisão do A/D) + temperatura = temperatura * 100; //Converte milivolts para graus celcius, lembrando que a cada 10mV equivalem a 1 grau celcius + lcd.print(temperatura); + handTimer=millis(); + }*/ + +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/jHomeEthernet/jHomeEthernet.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/jHomeEthernet/jHomeEthernet.pde new file mode 100644 index 0000000..b94dad6 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/jHomeEthernet/jHomeEthernet.pde @@ -0,0 +1,294 @@ +#include "etherShield.h" +// Default jHome pin +#define RX 0 +#define TX 1 +#define AUX_INT 2 + +#define RELAY1 3 +#define RELAY2 4 + +#define RED 5 +#define GREEN 6 + +#define AUX1 7 +#define AUX2 8 + +#define BLUE 9 +//10, 11, 12, 13 SPI port reserved for ethernet + +//ANALOG +#define RELAY3 14 //0 +#define RELAY4 15 //1 + +#define TEMPERATURE 2 +#define LIGHT 3 +//4, 5 reserved for I2C component, ex. LCD display + + +// please modify the following two lines. mac and ip have to be unique +// in your local area network. You can not have the same numbers in +// two devices: +static uint8_t mymac[6] = { + 0x54,0x55,0x58,0x10,0x00,0x24}; +static uint8_t myip[4] = { + 192,168,1,15}; +static char baseurl[]="http://192.168.1.15/"; +static uint16_t mywwwport =80; // listen port for tcp/www (max range 1-254) + + + +#define BUFFER_SIZE 500 +static uint8_t buf[BUFFER_SIZE+1]; +#define STR_BUFFER_SIZE 22 +static char strbuf[STR_BUFFER_SIZE+1]; + +EtherShield es=EtherShield(); + +// prepare the webpage by writing the data to the tcp send buffer +uint16_t print_webpage(uint8_t *buf, byte on_off); +int8_t analyse_cmd(char *str); + +// LED cathode connects the Pin4, anode to 5V through 1K resistor +#define LED_PIN 14 + + +void setup(){ + + /*initialize enc28j60*/ + es.ES_enc28j60Init(mymac); + es.ES_enc28j60clkout(2); // change clkout from 6.25MHz to 12.5MHz + delay(10); + + /* Magjack leds configuration, see enc28j60 datasheet, page 11 */ + // LEDA=greed LEDB=yellow + // + // 0x880 is PHLCON LEDB=on, LEDA=on + // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00); + es.ES_enc28j60PhyWrite(PHLCON,0x880); + delay(500); + // + // 0x990 is PHLCON LEDB=off, LEDA=off + // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00); + es.ES_enc28j60PhyWrite(PHLCON,0x990); + delay(500); + // + // 0x880 is PHLCON LEDB=on, LEDA=on + // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00); + es.ES_enc28j60PhyWrite(PHLCON,0x880); + delay(500); + // + // 0x990 is PHLCON LEDB=off, LEDA=off + // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00); + es.ES_enc28j60PhyWrite(PHLCON,0x990); + delay(500); + // + // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit + // enc28j60PhyWrite(PHLCON,0b0000 0100 0111 01 10); + es.ES_enc28j60PhyWrite(PHLCON,0x476); + delay(100); + + //init the ethernet/ip layer: + es.ES_init_ip_arp_udp_tcp(mymac,myip,80); + + pinMode(LED_PIN, OUTPUT); + pinMode(15, OUTPUT); + digitalWrite(LED_PIN, LOW); // switch on LED +} + +void loop(){ + uint16_t plen, dat_p; + int8_t cmd; + byte on_off = 1; + + plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf); + + /*plen will ne unequal to zero if there is a valid packet (without crc error) */ + if(plen!=0){ + + // arp is broadcast if unknown but a host may also verify the mac address by sending it to a unicast address. + if(es.ES_eth_type_is_arp_and_my_ip(buf,plen)){ + es.ES_make_arp_answer_from_request(buf); + return; + } + + // check if ip packets are for us: + if(es.ES_eth_type_is_ip_and_my_ip(buf,plen)==0){ + return; + } + + if(buf[IP_PROTO_P]==IP_PROTO_ICMP_V && buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V){ + es.ES_make_echo_reply_from_request(buf,plen); + return; + } + + // tcp port www start, compare only the lower byte + if (buf[IP_PROTO_P]==IP_PROTO_TCP_V&&buf[TCP_DST_PORT_H_P]==0&&buf[TCP_DST_PORT_L_P]==mywwwport){ + if (buf[TCP_FLAGS_P] & TCP_FLAGS_SYN_V){ + es.ES_make_tcp_synack_from_syn(buf); // make_tcp_synack_from_syn does already send the syn,ack + return; + } + if (buf[TCP_FLAGS_P] & TCP_FLAGS_ACK_V){ + es.ES_init_len_info(buf); // init some data structures + dat_p=es.ES_get_tcp_data_pointer(); + if (dat_p==0){ // we can possibly have no data, just ack: + if (buf[TCP_FLAGS_P] & TCP_FLAGS_FIN_V){ + es.ES_make_tcp_ack_from_any(buf); + } + return; + } + //Here jHome starts to rocks... + if (strncmp("PUT ",(char *)&(buf[dat_p]),4)==0){ + if(strncmp("RELAY ON",(char *)&(buf[dat_p+4]),8)==0){ + digitalWrite(15, 1); + //char relayNumber = + } + else if(strncmp("RELAY OFF",(char *)&(buf[dat_p+4]),9)==0){ + digitalWrite(15, 0); + //char relayNumber = + } + } + + if (strncmp("GET ",(char *)&(buf[dat_p]),4)!=0){ + // head, post and other methods for possible status codes see: + // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html + plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n

200 OK

")); + goto SENDTCP; + } + if (strncmp("/ ",(char *)&(buf[dat_p+4]),2)==0){ + plen=print_webpage(buf, on_off); + goto SENDTCP; + } + if (strncmp("/setup",(char *)&(buf[dat_p+4]),6)==0){ + plen=print_setuppage(buf, on_off); + goto SENDTCP; + } + cmd=analyse_cmd((char *)&(buf[dat_p+5])); + + if (cmd==2){ + on_off=1; + digitalWrite(LED_PIN, LOW); // switch on LED + } + else if (cmd==3){ + on_off=0; + digitalWrite(LED_PIN, HIGH); // switch off LED + } + plen=print_webpage(buf, on_off); + + plen=print_webpage(buf, on_off); +SENDTCP: + es.ES_make_tcp_ack_from_any(buf); // send ack for http get + es.ES_make_tcp_ack_with_data(buf,plen); // send data + } + } + } + +} +// The returned value is stored in the global var strbuf +uint8_t find_key_val(char *str,char *key) +{ + uint8_t found=0; + uint8_t i=0; + char *kp; + kp=key; + while(*str && *str!=' ' && found==0){ + if (*str == *kp){ + kp++; + if (*kp == '\0'){ + str++; + kp=key; + if (*str == '='){ + found=1; + } + } + } + else{ + kp=key; + } + str++; + } + if (found==1){ + // copy the value to a buffer and terminate it with '\0' + while(*str && *str!=' ' && *str!='&' && i 0x2f){ + // is a ASCII number, return it + r=(*strbuf-0x30); + } + } + return r; +} + + +uint16_t print_webpage(uint8_t *buf, byte on_off) +{ + + int i=0; + + + uint16_t plen; + + + + plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

Welcome to Arduino Ethernet Shield V1.0

")); + + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

REMOTE LED is

")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

")); + + if(on_off) + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("ON")); + else + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("OFF")); + + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("


") ); + + if(on_off){ + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
")); + } + else { + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("")); + } + + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

V1.0 www.nuelectronics.com")); + + return(plen); +} + + +uint16_t print_setuppage(uint8_t *buf, byte on_off) +{ + int i=0; + uint16_t plen; + + + plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

Welcome to jHome Hardware Setup Interface

")); + + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

SETUP PAGE

")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
")); + + return(plen); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/jHomeSample1/jHomeSample1.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/jHomeSample1/jHomeSample1.ino new file mode 100644 index 0000000..292cca2 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/jHomeSample1/jHomeSample1.ino @@ -0,0 +1,18 @@ +#include "jHomeEthernet.h" + +jHomeEthernet ethernet=jHomeEthernet(); +//jHome home=jHome(); + +void setup() { + //setup IP and Mac Address + ethernet.setup(); + home.add("relay1", "RELAY", 5); + home.add("relay2", "RELAY", 6); + home.add("light", "LIGHT", 3); + home.add("temperature","TEMP", 2); + +} + +void loop() { + home.loop(); +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/jhome_ubatuba/jhome_ubatuba.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/jhome_ubatuba/jhome_ubatuba.ino new file mode 100644 index 0000000..b118891 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jHome/jhome_ubatuba/jhome_ubatuba.ino @@ -0,0 +1,37 @@ +#include "Device.h" + +#include "etherShield.h" +#include "ETHER_28J60.h" +#include "Ethernet.h" + +Device homeDevice=Device("central-device"); +Ethernet ethernet=Ethernet(&homeDevice); + +void setup() { + homeDevice.add("buzz", PWM, 6); + homeDevice.add("red", PWM, 9); + homeDevice.add("green", PWM, 5); + homeDevice.add("blue", PWM, 3); + + homeDevice.add("p-esq", DIGITAL, 10); + homeDevice.add("p-dir", DIGITAL, 11); + + homeDevice.add("speaker", DIGITAL, 4); + homeDevice.add("relay2", DIGITAL, 15); + homeDevice.add("luz1", DIGITAL, 19); + homeDevice.add("luz2", DIGITAL, 18); + homeDevice.add("relay1", DIGITAL, 14); + homeDevice.add("light", ANALOG, 3); + homeDevice.add("temp", ANALOG, 2); + //Starting booth communication! + Serial.begin(115200); + int ip[]={192,168,1,3}; + ethernet.startNetwork(ip); +} + +void loop() { + homeDevice.loop(); + ethernet.loop(); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/javafx/javafx.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/javafx/javafx.ino new file mode 100644 index 0000000..0811af5 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/javafx/javafx.ino @@ -0,0 +1,35 @@ +#include "Device.h" + +#include "etherShield.h" +#include "ETHER_28J60.h" +#include "Ethernet.h" +#include "Servo.h" + +Device homeDevice=Device("central-device"); +Ethernet ethernet=Ethernet(&homeDevice); +Servo servo; +void setup(){ + servo.attach(6); + //homeDevice.add("buzz", PWM, 6); + //homeDevice.add("red", PWM, 9); + // homeDevice.add("green", PWM, 5); + //homeDevice.add("blue", PWM, 3); + + + //homeDevice.add("speaker", DIGITAL, 4); + //homeDevice.add("light", ANALOG, 3); + homeDevice.add("pot1", ANALOG, 0); + //homeDevice.add("temp", ANALOG, 2); + //Starting booth communication! + Serial.begin(115200); + int ip[]={192,168,1,5}; + ethernet.startNetwork(ip); +} + +void loop() { + homeDevice.loop(); + ethernet.loop(); + servo.write(map(analogRead(0), 0, 1023, 0, 179)); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jone-2010.zip b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jone-2010.zip new file mode 100644 index 0000000..2a8cc8d Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/jone-2010.zip differ diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/kernel_sample1/kernel_sample1.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/kernel_sample1/kernel_sample1.pde new file mode 100644 index 0000000..400684c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/kernel_sample1/kernel_sample1.pde @@ -0,0 +1,26 @@ +#include +#include +/* + Arduinos -> Arduino -> Modes -> Mode -> Tasks -> Task + -> Components -> Component + -> Events -> Event + + */ +void setup() { + Kernel.setup(); + Kernel.registerMode(1, "Blinking Leds", piscarLedSetup); + Kernel.registerTask(1, piscarLed); + Kernel.registerMode(2, "Blinking Leds"); + Kernel.registerTask(2, nada); + +} + +void loop() { + Kernel.loop(); +} + +void nada() {} +void piscarLed() { +} +void piscarLedSetup() { +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/lm35/lm35.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/lm35/lm35.pde new file mode 100644 index 0000000..41f4460 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/lm35/lm35.pde @@ -0,0 +1,17 @@ +//declare variables +float tempC; +int tempPin = 2; + +void setup() +{ +Serial.begin(9600); //opens serial port, sets data rate to 9600 bps +} + +void loop() +{ + +tempC = analogRead(tempPin); //read the value from the sensor +tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature +Serial.print((byte)tempC); //send the data to the computer +delay(1000); //wait one second before sending new data +} diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/sharp_sensor/sharp_sensor.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/sharp_sensor/sharp_sensor.pde new file mode 100644 index 0000000..9b9f1d9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/sharp_sensor/sharp_sensor.pde @@ -0,0 +1,27 @@ +#define MUITO_PERTO_VAL 350 +#define PERTO_VAL 300 +#define APROXIMANDO_VAL 200 +#define MUITO_LONGE_VAL 100 + +void setup() { + Serial.begin(9600); +} + +void loop() { + int val = analogRead(0); + Serial.print("Valor analogico: "); + Serial.println(val); + + float volts = (5.0/1024.0) * val; + //Serial.print("Valor Volts na mo: "); + Serial.println(volts); + if(volts>0 && volts<0.6) Serial.println("25cm"); + if(volts>0.6 && volts<1.0) Serial.println("20cm"); + if(volts>1.0 && volts<1.5) Serial.println("15cm"); + if(volts>1.5 && volts<2.0) Serial.println("10cm"); + if(volts>2.0) Serial.println("5cm"); + + delay(500); +} + + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/starterkit1/starterkit1.ino b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/starterkit1/starterkit1.ino new file mode 100644 index 0000000..6d5458c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/starterkit1/starterkit1.ino @@ -0,0 +1,28 @@ +#include "Device.h" +#include "etherShield.h" +#include "ETHER_28J60.h" +#include "Ethernet.h" +Device homeDevice=Device("central-device"); +Ethernet ethernet=Ethernet(&homeDevice); + +void setup() { + homeDevice.add("red", PWM, 9); + homeDevice.add("green", PWM, 5); + homeDevice.add("blue", PWM, 3); + homeDevice.add("speaker", DIGITAL, 4); + homeDevice.add("relay2", DIGITAL, 8); + homeDevice.add("relay1", DIGITAL, 7); + + homeDevice.add("light", ANALOG, 3); + homeDevice.add("temp", ANALOG, 2); + //Starting booth communication! + Serial.begin(115200); + int ip[]={192,168,1,15}; + ethernet.startNetwork(ip); +} + +void loop() { + homeDevice.loop(); + ethernet.loop(); +} + diff --git a/arduino/all the sketchs of my life/0sony/arduino-old-sketches/tiziu_motor/tiziu_motor.pde b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/tiziu_motor/tiziu_motor.pde new file mode 100644 index 0000000..003e8cf --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/arduino-old-sketches/tiziu_motor/tiziu_motor.pde @@ -0,0 +1,24 @@ +void setup() { + pinMode(11,OUTPUT); + pinMode(12,OUTPUT); + pinMode(13,OUTPUT); +} + +void loop() { + digitalWrite(12, 0); + digitalWrite(13, 1); + analogWrite(11,200); + delay(1000); + analogWrite(11,0); + delay(3000); + digitalWrite(12, 1); + digitalWrite(13, 0); + analogWrite(11,200); + delay(1000); + analogWrite(11,0); + delay(3000); +} + + + + diff --git a/arduino/all the sketchs of my life/0sony/ethernet_jhome.zip b/arduino/all the sketchs of my life/0sony/ethernet_jhome.zip new file mode 100644 index 0000000..b17e77a Binary files /dev/null and b/arduino/all the sketchs of my life/0sony/ethernet_jhome.zip differ diff --git a/arduino/all the sketchs of my life/0sony/ethernet_jhome/Ethernet.ino b/arduino/all the sketchs of my life/0sony/ethernet_jhome/Ethernet.ino new file mode 100644 index 0000000..c82cd20 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/ethernet_jhome/Ethernet.ino @@ -0,0 +1,58 @@ +char comando[30]; +char comandoOK[30]; +int contador = 0; + +void ethernet() { + EthernetClient client = server.available(); + if (client) { + contador =0; + // an http request ends with a blank line + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + //Serial.println("aaa"); + comando[contador++]=c; + if(c=='\n') { + //Serial.print("COMANDO: "); + //Serial.println(comando); + + + contador=0; + for(int x=5;x<30;x++) { + if(comando[x]==' ') break; + comandoOK[contador++]=comando[x]; + //Serial.println(x); + } + limpa(); + + //Serial.print("COMANDO OK: "); + //Serial.println(comandoOK); + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println("Connection: close"); + client.println(); + client.println(homeDevice.execute(comandoOK)); + client.flush(); + break; + + } + + } + + } + // give the web browser time to receive the data + delay(5); + // close the connection: + client.stop(); + //Serial.println("client disonnected"); + + } +} + +void limpa() { + for(int x=0;x<30;x++) { + comando[x]=='\0'; + comandoOK[x]=='\0'; + } +} diff --git a/arduino/all the sketchs of my life/0sony/ethernet_jhome/IR.ino b/arduino/all the sketchs of my life/0sony/ethernet_jhome/IR.ino new file mode 100644 index 0000000..ca44cc9 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/ethernet_jhome/IR.ino @@ -0,0 +1,37 @@ +IRsend irsend; +char* irSender_write(char* args) { + int codigo = atoi(args); + if(codigo==0) { + irsend.sendNEC(0x81CEE01F,32); //on off + } + else if(codigo==1) { + irsend.sendNEC(0x81CE807F,32); //Phono + } + else if(codigo==2) { + irsend.sendNEC(0x81CEC03F,32); //FM + } + else if(codigo==3) { + irsend.sendNEC(0x81CE40BF,32); //CD + } + else if(codigo==4) { + irsend.sendNEC(0x81CE08F7,32); //AUX + } + else if(codigo==5) { + irsend.sendNEC(0x81CE20DF,32); //TAPE MONITOR + } + else if(codigo==6) { + irsend.sendNEC(0x81CE609F,32); //Volume Down + } + else if(codigo==7) { + irsend.sendNEC(0x81CEA05F,32); //Volume UP + } + else if(codigo==8) { + irsend.sendNEC(0x81CE10EF,32); //MUTE + } +} + +//Nao tem leitura de emissor de IR... +char* irSender_read() { + char* r="\0"; +} + diff --git a/arduino/all the sketchs of my life/0sony/ethernet_jhome/RS232.ino b/arduino/all the sketchs of my life/0sony/ethernet_jhome/RS232.ino new file mode 100644 index 0000000..c13c612 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/ethernet_jhome/RS232.ino @@ -0,0 +1,23 @@ + +char* rs232_write(char* args) { + Serial.begin(19200); + int codigo = atoi(args); + if(codigo==1) { + Serial.write(0x02); + Serial.write("PON"); + Serial.write(0x03); + } + else if(codigo==2) { + Serial.write(0x02); + Serial.write("POF"); + Serial.write(0x03); + } +} + +char* rs232_read() { + char* r="\0"; + while(Serial.available()) { + Serial.print((char) Serial.read()); + } +} + diff --git a/arduino/all the sketchs of my life/0sony/ethernet_jhome/ethernet_jhome.ino b/arduino/all the sketchs of my life/0sony/ethernet_jhome/ethernet_jhome.ino new file mode 100644 index 0000000..0430665 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/ethernet_jhome/ethernet_jhome.ino @@ -0,0 +1,30 @@ +#include "Device.h" +#include +#include +#include + +Device homeDevice=Device("central-device"); +byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; +IPAddress ip(192,168,0, 200); +EthernetServer server(80); + +void setup() { + Serial.begin(115200); + homeDevice.add("LED", DIGITAL, 6); + homeDevice.add("relay2", DIGITAL, 7); + homeDevice.add("light", ANALOG, 3); + homeDevice.add("temp", ANALOG, 2); + homeDevice.add("ir", CUSTOM, 3, irSender_read , irSender_write); + homeDevice.add("rs232", CUSTOM, 0, rs232_read, rs232_write); + + Ethernet.begin(mac, ip); + server.begin(); +} + +void loop() { + //Para aceitar requisições por Serial + homeDevice.loop(); + //Para aceitar requisições por TCP/IP + ethernet(); +} + diff --git a/arduino/all the sketchs of my life/0sony/exemplo_ir/exemplo_ir.ino b/arduino/all the sketchs of my life/0sony/exemplo_ir/exemplo_ir.ino new file mode 100644 index 0000000..2420f54 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/exemplo_ir/exemplo_ir.ino @@ -0,0 +1,167 @@ +/* + * IRrecord: record and play back IR signals as a minimal + * An IR detector/demodulator must be connected to the input RECV_PIN. + * An IR LED must be connected to the output PWM pin 3. + * A button must be connected to the input BUTTON_PIN; this is the + * send button. + * A visible LED can be connected to STATUS_PIN to provide status. + * + * The logic is: + * If the button is pressed, send the IR code. + * If an IR code is received, record it. + * + * Version 0.11 September, 2009 + * Copyright 2009 Ken Shirriff + * http://arcfn.com + */ + +#include + +int RECV_PIN = 11; +int BUTTON_PIN = 2; +int STATUS_PIN = 13; + +IRrecv irrecv(RECV_PIN); +IRsend irsend; + +decode_results results; + +void setup() +{ + Serial.begin(9600); + irrecv.enableIRIn(); // Start the receiver + pinMode(BUTTON_PIN, INPUT); + pinMode(STATUS_PIN, OUTPUT); +} + +// Storage for the recorded code +int codeType = -1; // The type of code +unsigned long codeValue; // The code value if not raw +unsigned int rawCodes[RAWBUF]; // The durations if raw +int codeLen; // The length of the code +int toggle = 0; // The RC5/6 toggle state + +// Stores the code for later playback +// Most of this code is just logging +void storeCode(decode_results *results) { + codeType = results->decode_type; + int count = results->rawlen; + if (codeType == UNKNOWN) { + Serial.println("Received unknown code, saving as raw"); + codeLen = results->rawlen - 1; + // To store raw codes: + // Drop first value (gap) + // Convert from ticks to microseconds + // Tweak marks shorter, and spaces longer to cancel out IR receiver distortion + for (int i = 1; i <= codeLen; i++) { + if (i % 2) { + // Mark + rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS; + Serial.print(" m"); + } + else { + // Space + rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS; + Serial.print(" s"); + } + Serial.print(rawCodes[i - 1], DEC); + } + Serial.println(""); + } + else { + if (codeType == NEC) { + Serial.print("Received NEC: "); + if (results->value == REPEAT) { + // Don't record a NEC repeat value as that's useless. + Serial.println("repeat; ignoring."); + return; + } + } + else if (codeType == SONY) { + Serial.print("Received SONY: "); + } + else if (codeType == RC5) { + Serial.print("Received RC5: "); + } + else if (codeType == RC6) { + Serial.print("Received RC6: "); + } + else { + Serial.print("Unexpected codeType "); + Serial.print(codeType, DEC); + Serial.println(""); + } + Serial.println(results->value, HEX); + codeValue = results->value; + codeLen = results->bits; + } +} + +void sendCode(int repeat) { + if (codeType == NEC) { + if (repeat) { + irsend.sendNEC(REPEAT, codeLen); + Serial.println("Sent NEC repeat"); + } + else { + irsend.sendNEC(codeValue, codeLen); + Serial.print("Sent NEC "); + Serial.println(codeValue, HEX); + } + } + else if (codeType == SONY) { + irsend.sendSony(codeValue, codeLen); + Serial.print("Sent Sony "); + Serial.println(codeValue, HEX); + } + else if (codeType == RC5 || codeType == RC6) { + if (!repeat) { + // Flip the toggle bit for a new button press + toggle = 1 - toggle; + } + // Put the toggle bit into the code to send + codeValue = codeValue & ~(1 << (codeLen - 1)); + codeValue = codeValue | (toggle << (codeLen - 1)); + if (codeType == RC5) { + Serial.print("Sent RC5 "); + Serial.println(codeValue, HEX); + irsend.sendRC5(codeValue, codeLen); + } + else { + irsend.sendRC6(codeValue, codeLen); + Serial.print("Sent RC6 "); + Serial.println(codeValue, HEX); + } + } + else if (codeType == UNKNOWN /* i.e. raw */) { + // Assume 38 KHz + irsend.sendRaw(rawCodes, codeLen, 38); + Serial.println("Sent raw"); + } +} + +int lastButtonState; + +void loop() { + // If button pressed, send the code. + int buttonState = digitalRead(BUTTON_PIN); + if (lastButtonState == LOW && buttonState == HIGH) { + Serial.println("Released"); + irrecv.enableIRIn(); // Re-enable receiver + } + + if (!buttonState) { + Serial.println("Pressed, sending"); + digitalWrite(STATUS_PIN, HIGH); + sendCode(lastButtonState == buttonState); + digitalWrite(STATUS_PIN, LOW); + delay(50); // Wait a bit between retransmissions + } + else if (irrecv.decode(&results)) { + digitalWrite(STATUS_PIN, HIGH); + storeCode(&results); + irrecv.resume(); // resume receiver + digitalWrite(STATUS_PIN, LOW); + } + lastButtonState = buttonState; +} diff --git a/arduino/all the sketchs of my life/0sony/keyes015_humidade_temperatura/keyes015_humidade_temperatura.ino b/arduino/all the sketchs of my life/0sony/keyes015_humidade_temperatura/keyes015_humidade_temperatura.ino new file mode 100644 index 0000000..189f042 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/keyes015_humidade_temperatura/keyes015_humidade_temperatura.ino @@ -0,0 +1,192 @@ +#define dht_dpin A1 + +byte bGlobalErr; + +byte dht_dat[5]; + + + +void setup(){ + + InitDHT(); + + Serial.begin(115200); + + delay(300); + + Serial.println("Humidity and temperaturenn"); + + delay(700); + +} + + + +void loop(){ + + ReadDHT(); + + switch (bGlobalErr){ + + case 0: + + Serial.print("Current humdity = "); + + Serial.print(dht_dat[0], DEC); + + Serial.print("."); + + Serial.print(dht_dat[1], DEC); + + Serial.print("% "); + + Serial.print("temperature = "); + + Serial.print(dht_dat[2], DEC); + + Serial.print("."); + + Serial.print(dht_dat[3], DEC); + + Serial.println("C "); + + break; + + case 1: + + Serial.println("Error 1: DHT start condition 1 not met."); + + break; + + case 2: + + Serial.println("Error 2: DHT start condition 2 not met."); + + break; + + case 3: + + Serial.println("Error 3: DHT checksum error."); + + break; + + default: + + Serial.println("Error: Unrecognized code encountered."); + + break; + + } + + delay(800); + +} + + + +void InitDHT(){ + + pinMode(dht_dpin,OUTPUT); + + digitalWrite(dht_dpin,HIGH); + +} + + + +void ReadDHT(){ + + bGlobalErr=0; + + byte dht_in; + + byte i; + + digitalWrite(dht_dpin,LOW); + + delay(20); + + + + digitalWrite(dht_dpin,HIGH); + + delayMicroseconds(40); + + pinMode(dht_dpin,INPUT); + + //delayMicroseconds(40); + + dht_in=digitalRead(dht_dpin); + + + + if(dht_in){ + + bGlobalErr=1; + + return; + + } + + delayMicroseconds(80); + + dht_in=digitalRead(dht_dpin); + + + + if(!dht_in){ + + bGlobalErr=2; + + return; + + } + + delayMicroseconds(80); + + for (i=0; i<5; i++) + + dht_dat[i] = read_dht_dat(); + + pinMode(dht_dpin,OUTPUT); + + digitalWrite(dht_dpin,HIGH); + + byte dht_check_sum = + + dht_dat[0]+dht_dat[1]+dht_dat[2]+dht_dat[3]; + + if(dht_dat[4]!= dht_check_sum) + + { + bGlobalErr=3; + } + +}; + + + +byte read_dht_dat(){ + + byte i = 0; + + byte result=0; + + for(i=0; i< 8; i++){ + + while(digitalRead(dht_dpin)==LOW); + + delayMicroseconds(30); + + if (digitalRead(dht_dpin)==HIGH) + + result |=(1<<(7-i)); + + while (digitalRead(dht_dpin)==HIGH); + + } + + return result; + +} + diff --git a/arduino/all the sketchs of my life/0sony/libraries/readme.txt b/arduino/all the sketchs of my life/0sony/libraries/readme.txt new file mode 100644 index 0000000..a8f1390 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/libraries/readme.txt @@ -0,0 +1 @@ +For information on installing libraries, see: http://arduino.cc/en/Guide/Libraries diff --git a/arduino/all the sketchs of my life/0sony/motor_ponte_h/motor_ponte_h.ino b/arduino/all the sketchs of my life/0sony/motor_ponte_h/motor_ponte_h.ino new file mode 100644 index 0000000..7cf7f4a --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/motor_ponte_h/motor_ponte_h.ino @@ -0,0 +1,27 @@ +#define MOTOR1_A 7 +#define MOTOR1_B 8 +#define MOTOR1_PWM 10 + +void setup() { + pinMode(MOTOR1_A, OUTPUT); + pinMode(MOTOR1_B, OUTPUT); + +} + +void loop() { + digitalWrite(MOTOR1_A, HIGH); + digitalWrite(MOTOR1_B, LOW); + funcionarMotor(); + digitalWrite(MOTOR1_A, LOW); + digitalWrite(MOTOR1_B, HIGH); + funcionarMotor(); +} + +void funcionarMotor() { + analogWrite(MOTOR1_PWM, 150); + delay(2000); + analogWrite(MOTOR1_PWM, 250); + delay(2000); + analogWrite(MOTOR1_PWM, 0); + delay(2000); +} diff --git a/arduino/all the sketchs of my life/0sony/panasonic/panasonic.ino b/arduino/all the sketchs of my life/0sony/panasonic/panasonic.ino new file mode 100644 index 0000000..24c58a3 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/panasonic/panasonic.ino @@ -0,0 +1,29 @@ +/* + * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend + * An IR LED must be connected to Arduino PWM pin 3. + * Version 0.1 July, 2009 + * Copyright 2009 Ken Shirriff + * http://arcfn.com + */ + +#include + +#define PanasonicAddress 0x4004 // Panasonic address (Pre data) +#define PanasonicPower 0x112005E // Panasonic Power button +//#define PanasonicPower 0x1120049 // Panasonic Power button + +IRsend irsend; + +void setup() +{ + Serial.begin(9600); + unsigned int menu[100]={-3500,3550,-1650,500,-350,500,-1200,500,-350,500,-400,500,-350,500,-350,500,-350,500,-350,550,-350,500,-350,500,-350,500,-350,500,-400,500,-1200,500,-350,500,-350,550,-350,500,-350,500,-350,500,-350,500,-400,500,-350,500,-350,500,-1200,500,-400,500,-350,500,-350,500,-1250,500,-350,500,-350,500,-1200,500,-400,500,-350,500,-350,500,-350,500,-400,500,-350,500,-350,500,-350,500,-350,500,-400,500,-1200,500,-350,500,-1250,500,-1200,500,-1250,500,-1200,500,-350,500}; + irsend.sendRaw(menu, 100, 38); + delay(200); +} + + + +void loop() { + +} diff --git a/arduino/all the sketchs of my life/0sony/panasonic_2/panasonic_2.ino b/arduino/all the sketchs of my life/0sony/panasonic_2/panasonic_2.ino new file mode 100644 index 0000000..40e4b08 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/panasonic_2/panasonic_2.ino @@ -0,0 +1,32 @@ +/* + * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend + * An IR LED must be connected to Arduino PWM pin 3. + * Version 0.1 July, 2009 + * Copyright 2009 Ken Shirriff + * http://arcfn.com + * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) + */ +#include + +#define PanasonicAddress 0x4004 // Panasonic address (Pre data) +#define PanasonicPower 0x112005E // Panasonic Power button + +#define JVCPower 0xC5E8 + +IRsend irsend; + +void setup() +{ + irsend.sendPanasonic(PanasonicAddress,PanasonicPower); // This should turn your TV on and off + delay(30); + irsend.sendPanasonic(PanasonicAddress,PanasonicPower); // This should turn your TV on and off + delay(30); +} + +void loop() { + + //irsend.sendJVC(JVCPower, 16,0); // hex value, 16 bits, no repeat + //delayMicroseconds(50); // see http://www.sbprojects.com/knowledge/ir/jvc.php for information + //irsend.sendJVC(JVCPower, 16,1); // hex value, 16 bits, repeat + //delayMicroseconds(50); +} diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_android_body/ping.ino b/arduino/all the sketchs of my life/0sony/things_rpi_android_body/ping.ino new file mode 100644 index 0000000..ad8cb9f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_android_body/ping.ino @@ -0,0 +1,19 @@ +// --------------------------------------------------------------------------- +// Example NewPing library sketch that does a ping about 20 times per second. +// --------------------------------------------------------------------------- + +#include + +#define TRIGGER_PIN 13 // Arduino pin tied to trigger pin on the ultrasonic sensor. +#define ECHO_PIN 12 // 1Arduino pin tied to echo pin on the ultrasonic sensor. +#define MAX_DISTANCE 200 // M1aximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. + +NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. +char dis[4]; + +char* distance_read() { + unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS). + int cm =uS / US_ROUNDTRIP_CM; + itoa(cm,dis,10); + return dis; +} diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_android_body/sensors.ino b/arduino/all the sketchs of my life/0sony/things_rpi_android_body/sensors.ino new file mode 100644 index 0000000..d5af74c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_android_body/sensors.ino @@ -0,0 +1,111 @@ +#define dht_dpin A1 + +byte bGlobalErr; +byte dht_dat[5]; +byte initSensor = 0; +char retorno[6]; + +char* temperature_out() { + //if(!initSensor) + InitDHT(); + ReadDHT(); + if(!bGlobalErr) { + itoa(dht_dat[2],retorno,10); + retorno[2]='.'; + char conv2[3]; + itoa(dht_dat[3],conv2,10); + retorno[3]=conv2[0]; + retorno[4]=conv2[1]; + retorno[5]='\0'; + return retorno; + } + else { + return "0"; + } +} + +char* humidity() { + //if(!initSensor) + InitDHT(); + ReadDHT(); + if(!bGlobalErr) { + itoa(dht_dat[0],retorno,10); + retorno[2]='.'; + char conv2[3]; + itoa(dht_dat[1],conv2,10); + retorno[3]=conv2[0]; + retorno[4]=conv2[1]; + retorno[5]='\0'; + return retorno; + } + else { + return "0"; + } +} + + +void InitDHT(){ + initSensor=1; + pinMode(dht_dpin,OUTPUT); + digitalWrite(dht_dpin,HIGH); +} + +void ReadDHT(){ + bGlobalErr=0; + byte dht_in; + byte i; + digitalWrite(dht_dpin,LOW); + delay(20); + digitalWrite(dht_dpin,HIGH); + delayMicroseconds(40); + pinMode(dht_dpin,INPUT); + //delayMicroseconds(40); + dht_in=digitalRead(dht_dpin); + if(dht_in){ + bGlobalErr=1; + return; + } + delayMicroseconds(80); + dht_in=digitalRead(dht_dpin); + if(!dht_in){ + bGlobalErr=2; + return; + } + delayMicroseconds(80); + for (i=0; i<5; i++) + dht_dat[i] = read_dht_dat(); + pinMode(dht_dpin,OUTPUT); + digitalWrite(dht_dpin,HIGH); + byte dht_check_sum = + dht_dat[0]+dht_dat[1]+dht_dat[2]+dht_dat[3]; + if(dht_dat[4]!= dht_check_sum) + { + bGlobalErr=3; + } +}; + +byte read_dht_dat(){ + byte i = 0; + byte result=0; + for(i=0; i< 8; i++){ + while(digitalRead(dht_dpin)==LOW); + delayMicroseconds(30); + if (digitalRead(dht_dpin)==HIGH) + result |=(1<<(7-i)); + while (digitalRead(dht_dpin)==HIGH); + } + return result; +} + +char* sample_write(char* args) { + int codigo = atoi(args); + if(codigo==11) { + } + else if(codigo==12) { + } + else if(codigo==21) { + } + else if(codigo==22) { + } +} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_android_body/servo.ino b/arduino/all the sketchs of my life/0sony/things_rpi_android_body/servo.ino new file mode 100644 index 0000000..23c7845 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_android_body/servo.ino @@ -0,0 +1,25 @@ +#include + +Servo servo11; +Servo servo12; +Servo servo2; +Servo servo3; + + +char* servo_read() { + return "0"; +} + +char* servo_write_head(char* args) { + servo11.attach(5); + int pos = atoi(args); + servo11.write(pos); + return args; +} +char* servo_write_arm(char* args) { + servo2.attach(11); + int pos = atoi(args); + servo2.write(pos); + return args; +} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_android_body/things_rpi_android_body.ino b/arduino/all the sketchs of my life/0sony/things_rpi_android_body/things_rpi_android_body.ino new file mode 100644 index 0000000..9ee3ebb --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_android_body/things_rpi_android_body.ino @@ -0,0 +1,35 @@ +#include + +void setup() { + thing.addComponent("red", PWM, 3); + thing.addComponent("green", PWM, 6); + thing.addComponent("blue", PWM, 9); + thing.addComponent("speaker", DIGITAL, 4); + thing.addComponent("distance", CUSTOM, 5, distance_read, sample_write); + + thing.addComponent("light", ANALOG, 3); + thing.addComponent("temp_in", ANALOG, 2); + thing.addComponent("alcohol", ANALOG, 0); + thing.addComponent("temp_out", CUSTOM, 1, temperature_out, sample_write); + thing.addComponent("humidity", CUSTOM, 1, humidity, sample_write); + thing.addComponent("head", CUSTOM, 6, servo_read, servo_write_head); + thing.addComponent("servoarm", CUSTOM, 6, servo_read, servo_write_arm); + + thing.addMode(0, automation); + thing.start(); + Serial.begin(115200); +} + +char* all() { + + //Serial.println(temp_out); + // Serial.println(humidity); + +} + +void loop() { + thing.loop(); +} + +void automation() {} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos/ping.ino b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos/ping.ino new file mode 100644 index 0000000..60ff9d6 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos/ping.ino @@ -0,0 +1,19 @@ +// --------------------------------------------------------------------------- +// Example NewPing library sketch that does a ping about 20 times per second. +// --------------------------------------------------------------------------- + +#include + +#define TRIGGER_PIN 11 // Arduino pin tied to trigger pin on the ultrasonic sensor. +#define ECHO_PIN 10 // Arduino pin tied to echo pin on the ultrasonic sensor. +#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. + +NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. +char dis[4]; + +char* distance_read() { + unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS). + int cm =uS / US_ROUNDTRIP_CM; + itoa(cm,dis,10); + return dis; +} diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos/sensors.ino b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos/sensors.ino new file mode 100644 index 0000000..d5af74c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos/sensors.ino @@ -0,0 +1,111 @@ +#define dht_dpin A1 + +byte bGlobalErr; +byte dht_dat[5]; +byte initSensor = 0; +char retorno[6]; + +char* temperature_out() { + //if(!initSensor) + InitDHT(); + ReadDHT(); + if(!bGlobalErr) { + itoa(dht_dat[2],retorno,10); + retorno[2]='.'; + char conv2[3]; + itoa(dht_dat[3],conv2,10); + retorno[3]=conv2[0]; + retorno[4]=conv2[1]; + retorno[5]='\0'; + return retorno; + } + else { + return "0"; + } +} + +char* humidity() { + //if(!initSensor) + InitDHT(); + ReadDHT(); + if(!bGlobalErr) { + itoa(dht_dat[0],retorno,10); + retorno[2]='.'; + char conv2[3]; + itoa(dht_dat[1],conv2,10); + retorno[3]=conv2[0]; + retorno[4]=conv2[1]; + retorno[5]='\0'; + return retorno; + } + else { + return "0"; + } +} + + +void InitDHT(){ + initSensor=1; + pinMode(dht_dpin,OUTPUT); + digitalWrite(dht_dpin,HIGH); +} + +void ReadDHT(){ + bGlobalErr=0; + byte dht_in; + byte i; + digitalWrite(dht_dpin,LOW); + delay(20); + digitalWrite(dht_dpin,HIGH); + delayMicroseconds(40); + pinMode(dht_dpin,INPUT); + //delayMicroseconds(40); + dht_in=digitalRead(dht_dpin); + if(dht_in){ + bGlobalErr=1; + return; + } + delayMicroseconds(80); + dht_in=digitalRead(dht_dpin); + if(!dht_in){ + bGlobalErr=2; + return; + } + delayMicroseconds(80); + for (i=0; i<5; i++) + dht_dat[i] = read_dht_dat(); + pinMode(dht_dpin,OUTPUT); + digitalWrite(dht_dpin,HIGH); + byte dht_check_sum = + dht_dat[0]+dht_dat[1]+dht_dat[2]+dht_dat[3]; + if(dht_dat[4]!= dht_check_sum) + { + bGlobalErr=3; + } +}; + +byte read_dht_dat(){ + byte i = 0; + byte result=0; + for(i=0; i< 8; i++){ + while(digitalRead(dht_dpin)==LOW); + delayMicroseconds(30); + if (digitalRead(dht_dpin)==HIGH) + result |=(1<<(7-i)); + while (digitalRead(dht_dpin)==HIGH); + } + return result; +} + +char* sample_write(char* args) { + int codigo = atoi(args); + if(codigo==11) { + } + else if(codigo==12) { + } + else if(codigo==21) { + } + else if(codigo==22) { + } +} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos/servo.ino b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos/servo.ino new file mode 100644 index 0000000..d2dcd66 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos/servo.ino @@ -0,0 +1,41 @@ +#include + +Servo arm1a; +Servo arm1b; +Servo base; +Servo arm2; +Servo topcircle; + + +char* servo_read() { + return "0"; +} + +char* servoarm1_write(char* args) { + arm1a.attach(5); + arm1b.attach(6); + int pos = atoi(args); + arm1a.write(pos); + arm1b.write(180 - pos); + return args; +} +char* servobase_write(char* args) { + base.attach(9); + int pos = atoi(args); + base.write(pos); + return args; +} +char* servoarm2_write(char* args) { + arm2.attach(10); + int pos = atoi(args); + arm2.write(pos); + return args; +} + +char* servotopcircle_write(char* args) { + topcircle.attach(3); + int pos = atoi(args); + topcircle.write(pos); + return args; +} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos/things_rpi_arm_servos.ino b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos/things_rpi_arm_servos.ino new file mode 100644 index 0000000..5a31e97 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos/things_rpi_arm_servos.ino @@ -0,0 +1,28 @@ +#include + +void setup() { + thing.addComponent("red", PWM, 3); + thing.addComponent("green", PWM, 6); + thing.addComponent("blue", PWM, 9); + thing.addComponent("speaker", DIGITAL, 4); + + thing.addComponent("light", ANALOG, 3); + thing.addComponent("temp_in", ANALOG, 2); + thing.addComponent("temp_out", CUSTOM, 1, temperature_out, sample_write); + thing.addComponent("humidity", CUSTOM, 1, humidity, sample_write); + thing.addComponent("servos", CUSTOM, 5, servo_read, servos_write); + //thing.addComponent("servob", CUSTOM, 5, servo_read, servob_write); + //thing.addComponent("servoc", CUSTOM, 5, servo_read, servoc_write); + thing.addComponent("distance", CUSTOM, 5, distance_read, sample_write); + + thing.addMode(0, automation); + thing.start(); + Serial.begin(115200); +} + +void loop() { + thing.loop(); +} + +void automation() {} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos_ok/ping.ino b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos_ok/ping.ino new file mode 100644 index 0000000..60ff9d6 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos_ok/ping.ino @@ -0,0 +1,19 @@ +// --------------------------------------------------------------------------- +// Example NewPing library sketch that does a ping about 20 times per second. +// --------------------------------------------------------------------------- + +#include + +#define TRIGGER_PIN 11 // Arduino pin tied to trigger pin on the ultrasonic sensor. +#define ECHO_PIN 10 // Arduino pin tied to echo pin on the ultrasonic sensor. +#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. + +NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. +char dis[4]; + +char* distance_read() { + unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS). + int cm =uS / US_ROUNDTRIP_CM; + itoa(cm,dis,10); + return dis; +} diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos_ok/sensors.ino b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos_ok/sensors.ino new file mode 100644 index 0000000..d5af74c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos_ok/sensors.ino @@ -0,0 +1,111 @@ +#define dht_dpin A1 + +byte bGlobalErr; +byte dht_dat[5]; +byte initSensor = 0; +char retorno[6]; + +char* temperature_out() { + //if(!initSensor) + InitDHT(); + ReadDHT(); + if(!bGlobalErr) { + itoa(dht_dat[2],retorno,10); + retorno[2]='.'; + char conv2[3]; + itoa(dht_dat[3],conv2,10); + retorno[3]=conv2[0]; + retorno[4]=conv2[1]; + retorno[5]='\0'; + return retorno; + } + else { + return "0"; + } +} + +char* humidity() { + //if(!initSensor) + InitDHT(); + ReadDHT(); + if(!bGlobalErr) { + itoa(dht_dat[0],retorno,10); + retorno[2]='.'; + char conv2[3]; + itoa(dht_dat[1],conv2,10); + retorno[3]=conv2[0]; + retorno[4]=conv2[1]; + retorno[5]='\0'; + return retorno; + } + else { + return "0"; + } +} + + +void InitDHT(){ + initSensor=1; + pinMode(dht_dpin,OUTPUT); + digitalWrite(dht_dpin,HIGH); +} + +void ReadDHT(){ + bGlobalErr=0; + byte dht_in; + byte i; + digitalWrite(dht_dpin,LOW); + delay(20); + digitalWrite(dht_dpin,HIGH); + delayMicroseconds(40); + pinMode(dht_dpin,INPUT); + //delayMicroseconds(40); + dht_in=digitalRead(dht_dpin); + if(dht_in){ + bGlobalErr=1; + return; + } + delayMicroseconds(80); + dht_in=digitalRead(dht_dpin); + if(!dht_in){ + bGlobalErr=2; + return; + } + delayMicroseconds(80); + for (i=0; i<5; i++) + dht_dat[i] = read_dht_dat(); + pinMode(dht_dpin,OUTPUT); + digitalWrite(dht_dpin,HIGH); + byte dht_check_sum = + dht_dat[0]+dht_dat[1]+dht_dat[2]+dht_dat[3]; + if(dht_dat[4]!= dht_check_sum) + { + bGlobalErr=3; + } +}; + +byte read_dht_dat(){ + byte i = 0; + byte result=0; + for(i=0; i< 8; i++){ + while(digitalRead(dht_dpin)==LOW); + delayMicroseconds(30); + if (digitalRead(dht_dpin)==HIGH) + result |=(1<<(7-i)); + while (digitalRead(dht_dpin)==HIGH); + } + return result; +} + +char* sample_write(char* args) { + int codigo = atoi(args); + if(codigo==11) { + } + else if(codigo==12) { + } + else if(codigo==21) { + } + else if(codigo==22) { + } +} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos_ok/servo.ino b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos_ok/servo.ino new file mode 100644 index 0000000..370192d --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos_ok/servo.ino @@ -0,0 +1,41 @@ +#include + +Servo arm1a; +Servo arm1b; +Servo base; +Servo arm2; +Servo topcircle; + + +char* servo_read() { + return "0"; +} + +char* servo_arm1(char* args) { + arm1a.attach(5); + arm1b.attach(6); + int pos = atoi(args); + arm1a.write(pos); + arm1b.write(180 - pos); + return args; +} +char* servo_base(char* args) { + base.attach(9); + int pos = atoi(args); + base.write(pos); + return args; +} +char* servo_arm2(char* args) { + arm2.attach(10); + int pos = atoi(args); + arm2.write(pos); + return args; +} + +char* servo_topcircle(char* args) { + topcircle.attach(3); + int pos = atoi(args); + topcircle.write(pos); + return args; +} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos_ok/things_rpi_arm_servos_ok.ino b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos_ok/things_rpi_arm_servos_ok.ino new file mode 100644 index 0000000..76f3aad --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_arm_servos_ok/things_rpi_arm_servos_ok.ino @@ -0,0 +1,29 @@ +#include + +void setup() { + thing.addComponent("red", PWM, 3); + thing.addComponent("green", PWM, 6); + thing.addComponent("blue", PWM, 9); + thing.addComponent("speaker", DIGITAL, 4); + + thing.addComponent("light", ANALOG, 3); + thing.addComponent("temp_in", ANALOG, 2); + //thing.addComponent("temp_out", CUSTOM, 1, temperature_out, sample_write); + //thing.addComponent("humidity", CUSTOM, 1, humidity, sample_write); + thing.addComponent("arm1", CUSTOM, 5, servo_read, servo_arm1); + thing.addComponent("arm2", CUSTOM, 5, servo_read, servo_arm2); + thing.addComponent("base", CUSTOM, 5, servo_read, servo_base); + thing.addComponent("topcircle", CUSTOM, 5, servo_read, servo_topcircle); + //thing.addComponent("distance", CUSTOM, 5, distance_read, sample_write); + + thing.addMode(0, automation); + thing.start(); + Serial.begin(115200); +} + +void loop() { + thing.loop(); +} + +void automation() {} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_automation/ping.ino b/arduino/all the sketchs of my life/0sony/things_rpi_automation/ping.ino new file mode 100644 index 0000000..ad8cb9f --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_automation/ping.ino @@ -0,0 +1,19 @@ +// --------------------------------------------------------------------------- +// Example NewPing library sketch that does a ping about 20 times per second. +// --------------------------------------------------------------------------- + +#include + +#define TRIGGER_PIN 13 // Arduino pin tied to trigger pin on the ultrasonic sensor. +#define ECHO_PIN 12 // 1Arduino pin tied to echo pin on the ultrasonic sensor. +#define MAX_DISTANCE 200 // M1aximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. + +NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. +char dis[4]; + +char* distance_read() { + unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS). + int cm =uS / US_ROUNDTRIP_CM; + itoa(cm,dis,10); + return dis; +} diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_automation/sensors.ino b/arduino/all the sketchs of my life/0sony/things_rpi_automation/sensors.ino new file mode 100644 index 0000000..d5af74c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_automation/sensors.ino @@ -0,0 +1,111 @@ +#define dht_dpin A1 + +byte bGlobalErr; +byte dht_dat[5]; +byte initSensor = 0; +char retorno[6]; + +char* temperature_out() { + //if(!initSensor) + InitDHT(); + ReadDHT(); + if(!bGlobalErr) { + itoa(dht_dat[2],retorno,10); + retorno[2]='.'; + char conv2[3]; + itoa(dht_dat[3],conv2,10); + retorno[3]=conv2[0]; + retorno[4]=conv2[1]; + retorno[5]='\0'; + return retorno; + } + else { + return "0"; + } +} + +char* humidity() { + //if(!initSensor) + InitDHT(); + ReadDHT(); + if(!bGlobalErr) { + itoa(dht_dat[0],retorno,10); + retorno[2]='.'; + char conv2[3]; + itoa(dht_dat[1],conv2,10); + retorno[3]=conv2[0]; + retorno[4]=conv2[1]; + retorno[5]='\0'; + return retorno; + } + else { + return "0"; + } +} + + +void InitDHT(){ + initSensor=1; + pinMode(dht_dpin,OUTPUT); + digitalWrite(dht_dpin,HIGH); +} + +void ReadDHT(){ + bGlobalErr=0; + byte dht_in; + byte i; + digitalWrite(dht_dpin,LOW); + delay(20); + digitalWrite(dht_dpin,HIGH); + delayMicroseconds(40); + pinMode(dht_dpin,INPUT); + //delayMicroseconds(40); + dht_in=digitalRead(dht_dpin); + if(dht_in){ + bGlobalErr=1; + return; + } + delayMicroseconds(80); + dht_in=digitalRead(dht_dpin); + if(!dht_in){ + bGlobalErr=2; + return; + } + delayMicroseconds(80); + for (i=0; i<5; i++) + dht_dat[i] = read_dht_dat(); + pinMode(dht_dpin,OUTPUT); + digitalWrite(dht_dpin,HIGH); + byte dht_check_sum = + dht_dat[0]+dht_dat[1]+dht_dat[2]+dht_dat[3]; + if(dht_dat[4]!= dht_check_sum) + { + bGlobalErr=3; + } +}; + +byte read_dht_dat(){ + byte i = 0; + byte result=0; + for(i=0; i< 8; i++){ + while(digitalRead(dht_dpin)==LOW); + delayMicroseconds(30); + if (digitalRead(dht_dpin)==HIGH) + result |=(1<<(7-i)); + while (digitalRead(dht_dpin)==HIGH); + } + return result; +} + +char* sample_write(char* args) { + int codigo = atoi(args); + if(codigo==11) { + } + else if(codigo==12) { + } + else if(codigo==21) { + } + else if(codigo==22) { + } +} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_automation/servo.ino b/arduino/all the sketchs of my life/0sony/things_rpi_automation/servo.ino new file mode 100644 index 0000000..23c7845 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_automation/servo.ino @@ -0,0 +1,25 @@ +#include + +Servo servo11; +Servo servo12; +Servo servo2; +Servo servo3; + + +char* servo_read() { + return "0"; +} + +char* servo_write_head(char* args) { + servo11.attach(5); + int pos = atoi(args); + servo11.write(pos); + return args; +} +char* servo_write_arm(char* args) { + servo2.attach(11); + int pos = atoi(args); + servo2.write(pos); + return args; +} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_automation/things_rpi_automation.ino b/arduino/all the sketchs of my life/0sony/things_rpi_automation/things_rpi_automation.ino new file mode 100644 index 0000000..c42f05b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_automation/things_rpi_automation.ino @@ -0,0 +1,33 @@ +#include + +void setup() { + thing.addComponent("red", PWM, 3); + thing.addComponent("green", PWM, 6); + thing.addComponent("blue", PWM, 9); + thing.addComponent("speaker", DIGITAL, 4); + + thing.addComponent("light", ANALOG, 3); + thing.addComponent("temp_in", ANALOG, 2); + thing.addComponent("alcohol", ANALOG, 0); + thing.addComponent("temp_out", CUSTOM, 1, temperature_out, sample_write); + thing.addComponent("humidity", CUSTOM, 1, humidity, sample_write); + thing.addComponent("servoarm", CUSTOM, 6, servo_read, servo_write_arm); + + thing.addMode(0, automation); + thing.start(-1); //this mean that we dont want multiple behavior / loops here... any other number + Serial.begin(115200); +} + +char* all() { + + //Serial.println(temp_out); + // Serial.println(humidity); + +} + +void loop() { + thing.loop(); +} + +void automation() {} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/ping.ino b/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/ping.ino new file mode 100644 index 0000000..60ff9d6 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/ping.ino @@ -0,0 +1,19 @@ +// --------------------------------------------------------------------------- +// Example NewPing library sketch that does a ping about 20 times per second. +// --------------------------------------------------------------------------- + +#include + +#define TRIGGER_PIN 11 // Arduino pin tied to trigger pin on the ultrasonic sensor. +#define ECHO_PIN 10 // Arduino pin tied to echo pin on the ultrasonic sensor. +#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. + +NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. +char dis[4]; + +char* distance_read() { + unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS). + int cm =uS / US_ROUNDTRIP_CM; + itoa(cm,dis,10); + return dis; +} diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/sensors.ino b/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/sensors.ino new file mode 100644 index 0000000..d5af74c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/sensors.ino @@ -0,0 +1,111 @@ +#define dht_dpin A1 + +byte bGlobalErr; +byte dht_dat[5]; +byte initSensor = 0; +char retorno[6]; + +char* temperature_out() { + //if(!initSensor) + InitDHT(); + ReadDHT(); + if(!bGlobalErr) { + itoa(dht_dat[2],retorno,10); + retorno[2]='.'; + char conv2[3]; + itoa(dht_dat[3],conv2,10); + retorno[3]=conv2[0]; + retorno[4]=conv2[1]; + retorno[5]='\0'; + return retorno; + } + else { + return "0"; + } +} + +char* humidity() { + //if(!initSensor) + InitDHT(); + ReadDHT(); + if(!bGlobalErr) { + itoa(dht_dat[0],retorno,10); + retorno[2]='.'; + char conv2[3]; + itoa(dht_dat[1],conv2,10); + retorno[3]=conv2[0]; + retorno[4]=conv2[1]; + retorno[5]='\0'; + return retorno; + } + else { + return "0"; + } +} + + +void InitDHT(){ + initSensor=1; + pinMode(dht_dpin,OUTPUT); + digitalWrite(dht_dpin,HIGH); +} + +void ReadDHT(){ + bGlobalErr=0; + byte dht_in; + byte i; + digitalWrite(dht_dpin,LOW); + delay(20); + digitalWrite(dht_dpin,HIGH); + delayMicroseconds(40); + pinMode(dht_dpin,INPUT); + //delayMicroseconds(40); + dht_in=digitalRead(dht_dpin); + if(dht_in){ + bGlobalErr=1; + return; + } + delayMicroseconds(80); + dht_in=digitalRead(dht_dpin); + if(!dht_in){ + bGlobalErr=2; + return; + } + delayMicroseconds(80); + for (i=0; i<5; i++) + dht_dat[i] = read_dht_dat(); + pinMode(dht_dpin,OUTPUT); + digitalWrite(dht_dpin,HIGH); + byte dht_check_sum = + dht_dat[0]+dht_dat[1]+dht_dat[2]+dht_dat[3]; + if(dht_dat[4]!= dht_check_sum) + { + bGlobalErr=3; + } +}; + +byte read_dht_dat(){ + byte i = 0; + byte result=0; + for(i=0; i< 8; i++){ + while(digitalRead(dht_dpin)==LOW); + delayMicroseconds(30); + if (digitalRead(dht_dpin)==HIGH) + result |=(1<<(7-i)); + while (digitalRead(dht_dpin)==HIGH); + } + return result; +} + +char* sample_write(char* args) { + int codigo = atoi(args); + if(codigo==11) { + } + else if(codigo==12) { + } + else if(codigo==21) { + } + else if(codigo==22) { + } +} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/servo.ino b/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/servo.ino new file mode 100644 index 0000000..0c0b954 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/servo.ino @@ -0,0 +1,40 @@ +#include +Servo servo; +Servo servo11; +Servo servo12; +Servo servo2; +Servo servo3; + + +char* servo_read() { + return "0"; +} + +char* servos_write(char* args) { + servo11.attach(5); + servo11.attach(6); + int pos = atoi(args); + servo11.write(pos); + servo12.write(180 - pos); + return args; +} +char* servob_write(char* args) { + servo2.attach(9); + int pos = atoi(args); + servo2.write(pos); + return args; +} +char* servoc_write(char* args) { + servo3.attach(10); + int pos = atoi(args); + servo3.write(pos); + return args; +} + +char* servo_write(char* args) { + servo.attach(5); + int pos = atoi(args); + servo.write(pos); + return args; +} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/temp_celsius.ino b/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/temp_celsius.ino new file mode 100644 index 0000000..bea7bde --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/temp_celsius.ino @@ -0,0 +1,11 @@ + +char* temp_read() { +float tempC = analogRead(2); //read the value from the sensor +tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature +int ff = (int) tempC; +Serial.print(tempC); +char c[]={'\t'};//send the data to the computer +return c; +} + +char* temp_write(char c[]) {} diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/things_rpi_automation_12.ino b/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/things_rpi_automation_12.ino new file mode 100644 index 0000000..a00f9a1 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_automation_12/things_rpi_automation_12.ino @@ -0,0 +1,25 @@ +#include + +void setup() { + thing.addComponent("red", PWM, 3); + thing.addComponent("green", PWM, 6); + thing.addComponent("blue", PWM, 9); + thing.addComponent("speaker", DIGITAL, 4); + + thing.addComponent("light", ANALOG, 3); + thing.addComponent("temp_in", ANALOG, 2); + thing.addComponent("temp_celsius", CUSTOM, 2, temp_read, temp_write ); + thing.addComponent("alcohol", ANALOG, 0); + thing.addComponent("servo", CUSTOM, 6, servo_read, servo_write); + + thing.addMode(0, automation); + thing.start(); + Serial.begin(115200); +} + +void loop() { + thing.loop(); +} + +void automation() {} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_javaone/ping.ino b/arduino/all the sketchs of my life/0sony/things_rpi_javaone/ping.ino new file mode 100644 index 0000000..60ff9d6 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_javaone/ping.ino @@ -0,0 +1,19 @@ +// --------------------------------------------------------------------------- +// Example NewPing library sketch that does a ping about 20 times per second. +// --------------------------------------------------------------------------- + +#include + +#define TRIGGER_PIN 11 // Arduino pin tied to trigger pin on the ultrasonic sensor. +#define ECHO_PIN 10 // Arduino pin tied to echo pin on the ultrasonic sensor. +#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. + +NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. +char dis[4]; + +char* distance_read() { + unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS). + int cm =uS / US_ROUNDTRIP_CM; + itoa(cm,dis,10); + return dis; +} diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_javaone/sensors.ino b/arduino/all the sketchs of my life/0sony/things_rpi_javaone/sensors.ino new file mode 100644 index 0000000..d5af74c --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_javaone/sensors.ino @@ -0,0 +1,111 @@ +#define dht_dpin A1 + +byte bGlobalErr; +byte dht_dat[5]; +byte initSensor = 0; +char retorno[6]; + +char* temperature_out() { + //if(!initSensor) + InitDHT(); + ReadDHT(); + if(!bGlobalErr) { + itoa(dht_dat[2],retorno,10); + retorno[2]='.'; + char conv2[3]; + itoa(dht_dat[3],conv2,10); + retorno[3]=conv2[0]; + retorno[4]=conv2[1]; + retorno[5]='\0'; + return retorno; + } + else { + return "0"; + } +} + +char* humidity() { + //if(!initSensor) + InitDHT(); + ReadDHT(); + if(!bGlobalErr) { + itoa(dht_dat[0],retorno,10); + retorno[2]='.'; + char conv2[3]; + itoa(dht_dat[1],conv2,10); + retorno[3]=conv2[0]; + retorno[4]=conv2[1]; + retorno[5]='\0'; + return retorno; + } + else { + return "0"; + } +} + + +void InitDHT(){ + initSensor=1; + pinMode(dht_dpin,OUTPUT); + digitalWrite(dht_dpin,HIGH); +} + +void ReadDHT(){ + bGlobalErr=0; + byte dht_in; + byte i; + digitalWrite(dht_dpin,LOW); + delay(20); + digitalWrite(dht_dpin,HIGH); + delayMicroseconds(40); + pinMode(dht_dpin,INPUT); + //delayMicroseconds(40); + dht_in=digitalRead(dht_dpin); + if(dht_in){ + bGlobalErr=1; + return; + } + delayMicroseconds(80); + dht_in=digitalRead(dht_dpin); + if(!dht_in){ + bGlobalErr=2; + return; + } + delayMicroseconds(80); + for (i=0; i<5; i++) + dht_dat[i] = read_dht_dat(); + pinMode(dht_dpin,OUTPUT); + digitalWrite(dht_dpin,HIGH); + byte dht_check_sum = + dht_dat[0]+dht_dat[1]+dht_dat[2]+dht_dat[3]; + if(dht_dat[4]!= dht_check_sum) + { + bGlobalErr=3; + } +}; + +byte read_dht_dat(){ + byte i = 0; + byte result=0; + for(i=0; i< 8; i++){ + while(digitalRead(dht_dpin)==LOW); + delayMicroseconds(30); + if (digitalRead(dht_dpin)==HIGH) + result |=(1<<(7-i)); + while (digitalRead(dht_dpin)==HIGH); + } + return result; +} + +char* sample_write(char* args) { + int codigo = atoi(args); + if(codigo==11) { + } + else if(codigo==12) { + } + else if(codigo==21) { + } + else if(codigo==22) { + } +} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_javaone/servo.ino b/arduino/all the sketchs of my life/0sony/things_rpi_javaone/servo.ino new file mode 100644 index 0000000..d1f9426 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_javaone/servo.ino @@ -0,0 +1,33 @@ +#include + +Servo servo11; +Servo servo12; +Servo servo2; +Servo servo3; + + +char* servo_read() { + return "0"; +} + +char* servos_write(char* args) { + servo11.attach(5); + servo11.attach(6); + int pos = atoi(args); + servo11.write(pos); + servo12.write(180 - pos); + return args; +} +char* servob_write(char* args) { + servo2.attach(9); + int pos = atoi(args); + servo2.write(pos); + return args; +} +char* servoc_write(char* args) { + servo3.attach(10); + int pos = atoi(args); + servo3.write(pos); + return args; +} + diff --git a/arduino/all the sketchs of my life/0sony/things_rpi_javaone/things_rpi_javaone.ino b/arduino/all the sketchs of my life/0sony/things_rpi_javaone/things_rpi_javaone.ino new file mode 100644 index 0000000..8d5add0 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_rpi_javaone/things_rpi_javaone.ino @@ -0,0 +1,22 @@ +#include + +void setup() { + thing.addComponent("speaker", DIGITAL, 4); + thing.addMode(0, automation); + thing.start(); + Serial.begin(115200); +} + +char* all() { + + //Serial.println(temp_out); + // Serial.println(humidity); + +} + +void loop() { + thing.loop(); +} + +void automation() {} + diff --git a/arduino/all the sketchs of my life/0sony/things_sample1/mode_avoid.ino b/arduino/all the sketchs of my life/0sony/things_sample1/mode_avoid.ino new file mode 100644 index 0000000..4c47e8b --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_sample1/mode_avoid.ino @@ -0,0 +1,9 @@ +int distancia; +void avoidance() { + //Serial.println(2); + +} + +void slave() { + //Serial.println(1); +} diff --git a/arduino/all the sketchs of my life/0sony/things_sample1/mysensor.ino b/arduino/all the sketchs of my life/0sony/things_sample1/mysensor.ino new file mode 100644 index 0000000..565f645 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_sample1/mysensor.ino @@ -0,0 +1,18 @@ + +char* mySensorWrite(char* args) { + int codigo = atoi(args); + if(codigo==11) { + } + else if(codigo==12) { + } + else if(codigo==21) { + } + else if(codigo==22) { + } +} + +char* mySensorRead() { + char* r="\0"; +} + + diff --git a/arduino/all the sketchs of my life/0sony/things_sample1/things_sample1.ino b/arduino/all the sketchs of my life/0sony/things_sample1/things_sample1.ino new file mode 100644 index 0000000..e1fcc84 --- /dev/null +++ b/arduino/all the sketchs of my life/0sony/things_sample1/things_sample1.ino @@ -0,0 +1,23 @@ +#include + +void setup() { + thing.addComponent("agua", DIGITAL, 6); + thing.addComponent("luzfria", DIGITAL, 7); + thing.addComponent("luzquente", DIGITAL, 8); + thing.addComponent("vento", DIGITAL, 9); + //thing.addComponent("mySensor", CUSTOM, 10, mySensorRead, mySensorWrite); + thing.addComponent("light", ANALOG, 3); + thing.addComponent("temp", ANALOG, 2); + + thing.addMode(0, slave); + thing.addMode(1, avoidance); + thing.start(); + Serial.begin(115200); +} + +void loop() { + thing.loop(); + //Serial.println(222); + + +} diff --git a/arduino/all the sketchs of my life/ArduCAM_OV2640_FIFO_SD_JPEG/ArduCAM_OV2640_FIFO_SD_JPEG.ino b/arduino/all the sketchs of my life/ArduCAM_OV2640_FIFO_SD_JPEG/ArduCAM_OV2640_FIFO_SD_JPEG.ino new file mode 100644 index 0000000..b465002 --- /dev/null +++ b/arduino/all the sketchs of my life/ArduCAM_OV2640_FIFO_SD_JPEG/ArduCAM_OV2640_FIFO_SD_JPEG.ino @@ -0,0 +1,192 @@ +// ArduCAM demo (C)2013 Lee +// web: http://www.ArduCAM.com +// This program is a demo of how to use most of the functions +// of the library with a supported camera modules. +// +// This demo was made for Omnivision OV2640 sensor. +// 1. Set the sensor to JPEG output mode. +// 2. Capture and buffer the image to FIFO. +// 3. Store the image to Micro SD/TF card with JPEG format. +// 4. Resolution can be changed by myCAM.OV2640_set_JPEG_size() function. +// This program requires the ArduCAM V3.0.0 (or above) library and Rev.C ArduCAM shield +// and use Arduino IDE 1.5.2 compiler + +#include +#include +#include +#include +#include +#if defined(__arm__) +#include +#endif + +#define SD_CS 9 +// set pin 10 as the slave select for SPI: +const int slaveSelectPin = 10; + +ArduCAM myCAM(OV2640,10); +//UTFT myGLCD(slaveSelectPin); + +void setup() +{ +#if defined (__AVR__) + Wire.begin(); +#endif +#if defined(__arm__) + Wire1.begin(); +#endif + Serial.begin(115200); + Serial.println("hello"); + // set the slaveSelectPin as an output: + pinMode(slaveSelectPin, OUTPUT); + + // initialize SPI: + SPI.begin(); + + myCAM.write_reg(ARDUCHIP_MODE, 0x00); + + //myGLCD.InitLCD(); + myCAM.set_format(JPEG); + + myCAM.InitCAM(); + + //myCAM.OV2640_set_JPEG_size(OV2640_320x240); + myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); + + //Initialize SD Card + if (!SD.begin(SD_CS)) + { + //while (1); //If failed, stop here + } + + Serial.println("init done"); + Serial.println(ARDUCHIP_TRIG); + cap(); + +} + +void cap() { + char str[8]; + File outFile; + static int k = 0; + static int n = 0; + uint8_t temp,temp_last; + uint8_t start_capture = 0; + Serial.println("starting capture"); + //Flush the FIFO + myCAM.flush_fifo(); + //Clear the capture done flag + myCAM.clear_fifo_flag(); + //Start capture + myCAM.start_capture(); + //Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str,".jpg"); + //Open the new file + outFile = SD.open(str,FILE_WRITE); + if (! outFile) + { + Serial.println("open file failed"); + return; + } + + temp = myCAM.read_fifo(); + Serial.println("init write"); + + outFile.write(temp); + Serial.println("end write"); + + //Read JPEG data from FIFO + while( (temp != 0xD9) | (temp_last != 0xFF) ) + { + temp_last = temp; + temp = myCAM.read_fifo(); + //Write image data to file + outFile.write(temp); + } + //Close the file + outFile.close(); + Serial.println("file closed"); + + //Clear the capture done flag + myCAM.clear_fifo_flag(); + //Clear the start capture flag + start_capture = 0; + +} + +void loop() +{ + char str[8]; + File outFile; + static int k = 0; + static int n = 0; + uint8_t temp,temp_last; + uint8_t start_capture = 0; + + //Wait trigger from shutter buttom + if(myCAM.read_reg(ARDUCHIP_TRIG) & SHUTTER_MASK) + { + //Wait until buttom released + while(myCAM.read_reg(ARDUCHIP_TRIG) & SHUTTER_MASK); + start_capture = 1; + } + + //Start capture when detect a valid shutter press + if(start_capture) + { + Serial.println("starting capture"); + //Flush the FIFO + myCAM.flush_fifo(); + //Clear the capture done flag + myCAM.clear_fifo_flag(); + //Start capture + myCAM.start_capture(); + } + + if(myCAM.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK) + { + //Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str,".jpg"); + //Open the new file + outFile = SD.open(str,FILE_WRITE); + if (! outFile) + { + Serial.println("open file failed"); + return; + } + + temp = myCAM.read_fifo(); + Serial.println("init write"); + + outFile.write(temp); + Serial.println("end write"); + + //Read JPEG data from FIFO + while( (temp != 0xD9) | (temp_last != 0xFF) ) + { + temp_last = temp; + temp = myCAM.read_fifo(); + //Write image data to file + outFile.write(temp); + } + //Close the file + outFile.close(); + Serial.println("file closed"); + + //Clear the capture done flag + myCAM.clear_fifo_flag(); + //Clear the start capture flag + start_capture = 0; + } +} + + + + + + + diff --git a/arduino/all the sketchs of my life/BR1/Android/AtualizarDisplay.pde b/arduino/all the sketchs of my life/BR1/Android/AtualizarDisplay.pde new file mode 100644 index 0000000..51b700a --- /dev/null +++ b/arduino/all the sketchs of my life/BR1/Android/AtualizarDisplay.pde @@ -0,0 +1,46 @@ +/*void atualizaDisplay() { + lcd.clear(); + + //atualiza temperatura + //lcd.setCursor(col,row); + lcd.setCursor(8,1); + lcd.print(analogRead(SensorTemperatura)/2); + lcd.print("oC"); + + Serial.print("Temperatura= "); + Serial.println(analogRead(SensorTemperatura)/2); + + //atualiza luminosidade + //lcd.setCursor(col,row); + lcd.setCursor(0,1); + lcd.print(map((analogRead(LDR)), 0, 1023, 100,0)); + lcd.print(" %"); + + Serial.print("Luminosidade= "); + Serial.println(map((analogRead(LDR)), 0, 1023, 100,0)); + Serial.println(" "); + + + //lcd.setCursor(col,row); + lcd.setCursor(0,0); + lcd.print(DistanciaEsquerda); + lcd.print(" cms"); + + //atualiza distancia esquerda + Serial.print("Distancia Esquerda= "); + Serial.println(DistanciaEsquerda); + + //atualiza distancia direita + //lcd.setCursor(col,row); + lcd.setCursor(8,0); + lcd.print(DistanciaDireita); + lcd.print(" cms"); + + Serial.print("Distancia Direita= "); + Serial.println(DistanciaDireita); + + + +} +*/ + diff --git a/arduino/all the sketchs of my life/BR1/Android/Robo_Android.pde b/arduino/all the sketchs of my life/BR1/Android/Robo_Android.pde new file mode 100644 index 0000000..2a5fc9a --- /dev/null +++ b/arduino/all the sketchs of my life/BR1/Android/Robo_Android.pde @@ -0,0 +1,453 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int SensorTemperatura = 1 ; +int LDR = 5; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo servoV; +Servo servoH; +int modo = 1; +int sentido; + + +void setup() { + Serial.begin(115200); + servoH.attach(10); + servoV.attach(11); + meetAndroid.setSerial(&Serial); + meetAndroid.registerFunction(dedoDuro, 'A'); + meetAndroid.registerFunction(acelera, 'C'); + meetAndroid.registerFunction(encontraNorte, 'B'); + meetAndroid.registerFunction(andar, 'W'); + meetAndroid.registerFunction(leds, 'L'); + meetAndroid.registerFunction(mudarModo, 'M'); + + /* set up the LCD's number of rows and columns: + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Aguardando");*/ + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + pinMode(LED_RED, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + testeLeds(); + +} + +void loop() { + meetAndroid.receive(); + delay(50); + //meetAndroid.send(analogRead(1)); + //testeLeds(); +} +void leds(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + + if(comando[0]=='R') { + pinMode(LED_RED,INPUT); + int ligado = digitalRead(LED_RED); + pinMode(LED_RED,OUTPUT); + digitalWrite(LED_RED,!ligado); + + } + else if(comando[0]=='G') { + pinMode(LED_GREEN,INPUT); + int ligado = digitalRead(LED_GREEN); + pinMode(LED_GREEN,OUTPUT); + digitalWrite(LED_GREEN,!ligado); + } + else if(comando[0]=='B') { + pinMode(LED_BLUE,INPUT); + int ligado = digitalRead(LED_BLUE); + pinMode(LED_BLUE,OUTPUT); + digitalWrite(LED_BLUE,!ligado); + } + +} +void testeLeds() { + digitalWrite(LED_RED, HIGH); + delay(200); + digitalWrite(LED_RED, LOW); + delay(200); + digitalWrite(LED_BLUE, HIGH); + delay(200); + digitalWrite(LED_BLUE, LOW); + delay(200); + digitalWrite(LED_GREEN, HIGH); + delay(200); + digitalWrite(LED_GREEN, LOW); + delay(200); +} +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + testeLeds(); +} + +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + if(modo==4) { + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarTraz(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarFrente(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + } + else if(modo==6){ + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + delay(200); + } +} + + + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=3) return; + + if(comando[0]=='F') { + dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + dance(); + } +} + +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=1) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + testeLeds(); + } + } +} + +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=2) return; + if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + +/*void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } + }*/ + +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + + 28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ +int led_status=0; +void changeServo(int a) { + + digitalWrite(LED_RED, led_status); + led_status = led_status==0 ? 1 : 0; +} + +void dance() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + /*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/BR1/Android/Wask.pde b/arduino/all the sketchs of my life/BR1/Android/Wask.pde new file mode 100644 index 0000000..19a2ed2 --- /dev/null +++ b/arduino/all the sketchs of my life/BR1/Android/Wask.pde @@ -0,0 +1,273 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 +long duration, inches, cm; +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServoOK(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/BR1/Avoidance/dojo_solucao.pde b/arduino/all the sketchs of my life/BR1/Avoidance/dojo_solucao.pde new file mode 100644 index 0000000..e22e090 --- /dev/null +++ b/arduino/all the sketchs of my life/BR1/Avoidance/dojo_solucao.pde @@ -0,0 +1,160 @@ +#include +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define DISTANCIA 1 + +int sentido; +Servo servoV; +Servo servoH; +int contador=0; +long distancia; +long distanciaEsquerda; +long distanciaDireita; + +void setup() { + servoH.attach(11); + servoV.attach(10); + Serial.begin(9600); +} + +int lerPingComMedia() { + int d1,d2,d3; + d1 = analogRead(1); + delay(5); + d2 = analogRead(1); + delay(5); + d3 = analogRead(1); + delay(5); + return (d1 + d2 + d3)/3; +} + +void lerPing() { + distancia = lerPingComMedia(); +} +void lerPingFull() { + servoH.write(30); + delay(200); + distanciaEsquerda = lerPingComMedia(); + servoH.write(100); + delay(200); + distancia = lerPingComMedia(); + servoH.write(150); + delay(200); + distanciaDireita = lerPingComMedia(); + servoH.write(85); +} + +void loop() { + lerPing(); + + while(distancia>25) { + andarFrente(200,3); + lerPing(); + } + while(distancia>15 && distancia<25) { + parar(); + delay(200); + lerPingFull(); + if(distanciaEsquerda>distancia && distanciaEsquerda>distanciaDireita) { + girarNoEixo(300,2,1); + } + if(distanciaDireita>distancia && distanciaDireita>distanciaEsquerda) { + girarNoEixo(300,2,0); + } + lerPing(); + } + while(distancia>5 && distancia<15) { + parar(); + andarTraz(500,2); + girarNoEixo(500,2, random(10)%2==0); + lerPing(); + } + +} + + + + + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarTraz(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarFrente(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/BR2.zip b/arduino/all the sketchs of my life/BR2.zip new file mode 100644 index 0000000..0d47e9b Binary files /dev/null and b/arduino/all the sketchs of my life/BR2.zip differ diff --git a/arduino/all the sketchs of my life/Boat_Central/Boat_Central.ino b/arduino/all the sketchs of my life/Boat_Central/Boat_Central.ino new file mode 100644 index 0000000..bba820e --- /dev/null +++ b/arduino/all the sketchs of my life/Boat_Central/Boat_Central.ino @@ -0,0 +1,436 @@ +#include +#include + +#define MODE_GPS_LATLONG 0 +#define MODE_GPS_SPEED 1 +#define MODE_GPS_HEADING 2 +#define MODE_GPS_MANE 3 +#define MODE_AUTOPILOT_COMPASS 4 +#define MODE_AUTOPILOT_ACELEROMETER 5 +#define MODE_DEBUG 6 +#define MODE_MANUALPILOT 7 +#define MOTOR_A 12 +#define MOTOR_B 13 +#define MOTOR_PWM 11 +MeetAndroid meetAndroid; + +String modes[] = { + "Google Earth", "Speedy", "Heading", "Piloto Mane'", "Auto Compass", "Auto Aceler.", "Debug", "Manual Pilot" }; + +LiquidCrystal lcd(4, 9, 57, 56, 55, 54); +char line_gps[300] = ""; + +int autopilot=0; +int contaplot=0; +int byteGPS=-1; +char comandoGPR[7] = "$GPRMC"; +int indices[13]; +int cont=0; +int bien=0; +int conta=0; +char latitude[17]; +char longitude[17]; +char velocidade[17]; +char heading[17]; +int cvelocidade=0, clatitude=0, clongitude=0, cheading=0; +volatile long targetHeading; +volatile int mode; + +long lastDebounce=0; +long debounceDelay=50; +long lcdDelay=1500; +long lcdNextUpdate=0; +long lcdLastUpdate=0; + +String lcdLine1; +String lcdLine2; + +void setup() +{ + //LoL + Serial.begin(9600); + Serial2.begin(115200); + Serial1.begin(4800); + meetAndroid.setSerial(&Serial2); + attachInterrupt(3, buttonPressed, LOW); //PORTA 20, quando estiver subindo + attachInterrupt(2, changeMode, LOW); //PORTA 21, quando estiver subindo + initLCD(); + meetAndroid.registerFunction(autoCompass, 'B'); + meetAndroid.registerFunction(ghostPilot, 'C'); +} + +void setupMotor() { + pinMode(MOTOR_A, OUTPUT); + pinMode(MOTOR_B, OUTPUT); +} + +void loop() +{ + if(mode>=0 && mode<=3) savelocation(); + if(mode==MODE_GPS_MANE) pilotoMane(); + if(mode==MODE_AUTOPILOT_ACELEROMETER) android(); + if(mode==MODE_AUTOPILOT_COMPASS) android(); + if(mode==MODE_DEBUG) debug(); + if(mode==MODE_MANUALPILOT) manualPilot(); + lcdRestore(); +} + +long headings[6]; +int headCount=0; //ahahahah headCount eh bizarro +void pilotoMane() { + //headings[headCount++]=atoi(heading); + //if(headCount==5) headCount=0; + float h = atof(heading); + char c1[10]; + itoa(targetHeading,c1,10); + char c2[10]; + itoa(h,c2,10); + lcdPrint(c1, c2,0); + if(targetHeadingmillis() && mode==MODE_MANUALPILOT) { + itoa(time-millis(),c1,10); + lcdPrint("Manual Pilot in",c1 , 0); + delay(100); + } + if(mode!=MODE_MANUALPILOT) return; + lcdPrint("Manual Pilot On", "Take care!", 0); + autopilot=1; + detachInterrupt(3); //PORTA 18, quando estiver subindo + detachInterrupt(2); //PORTA 18, quando estiver subindo + attachInterrupt(3, motorForward, LOW); //PORTA 20, quando estiver subindo + attachInterrupt(2, motorBackward, LOW); //PORTA 21, quando estiver subindo + +} +void motorForward() { + digitalWrite(MOTOR_A, 0); + digitalWrite(MOTOR_B, 1); + analogWrite(MOTOR_PWM, 250); + while(!digitalRead(20)); + analogWrite(MOTOR_PWM,0); +} +void motorBackward() { + digitalWrite(MOTOR_A, 1); + digitalWrite(MOTOR_B, 0); + analogWrite(MOTOR_PWM, 250); + while(!digitalRead(21)); + analogWrite(MOTOR_PWM,0); +} + +void changeMode() { + if(millis()-lastDebounce>debounceDelay) { + mode = mode== 7 ? 0 : mode + 1; + lastDebounce=millis(); + resetMode(); + lcdPrint("Mode", modes[mode], 2000); + + } + +} + +void buttonPressed() { + char c1[10]; + if(millis()-lastDebounce>debounceDelay) { + targetHeading = targetHeading==360 ? 1 : targetHeading + 5; + lastDebounce=millis(); + itoa(targetHeading,c1,10); + lcdPrint("Target Heading",c1, 500); + + } +} + +void android() { + meetAndroid.receive(); +} + + +void savelocation () +{ + while(Serial1.available()>0) { + + byteGPS=Serial1.read(); // Read a byte of the serial port + line_gps[conta]=byteGPS; // If there is serial port data, it is put in the buffer + conta++; + if (byteGPS==13) + { // If the received byte is = to 13, end of transmission + //Serial.print(line_gps); + cont=0; + bien=0; + for (int i=1;i<7;i++) + { // Verifies if the received command starts with $GPR + if (line_gps[i]==comandoGPR[i-1]) + { + bien++; + } + } + if(bien==6) + { // If yes, continue and process the data + for (int i=0;i<300;i++) + { + if (line_gps[i]==','){ // check for the position of the "," separator + indices[cont]=i; + cont++; + } + if (line_gps[i]=='*') + { // ... and the "*" + indices[12]=i; + cont++; + } + } + Serial2.println(line_gps); + Serial.println(""); // ... and write to the serial port + Serial.println(""); + Serial.println("---------------"); + resetDados(); + for (int i=0;i<12;i++) + { + switch(i){ + case 0 : + Serial.print("Time in UTC (HhMmSs): "); + break; + case 1 : + Serial.print("Status (A=OK,V=KO): "); + break; + case 2 : + Serial.print("Latitude: "); + break; + case 3 : + Serial.print("Direction (N/S): "); + break; + case 4 : + Serial.print("Longitude: "); + break; + case 5 : + Serial.print("Direction (E/W): "); + break; + case 6 : + Serial.print("Velocity in knots: "); + break; + case 7 : + Serial.print("Heading in degrees: "); + break; + case 8 : + Serial.print("Date UTC (DdMmAa): "); + break; + case 9 : + Serial.print("Magnetic degrees: "); + break; + case 10 : + Serial.print("(E/W): "); + break; + case 11 : + Serial.print("Mode: "); + break; + case 12 : + Serial.print("Checksum: "); + break; + } + for (int j=indices[i];j<(indices[i+1]-1);j++) + { + Serial.print(line_gps[j+1]); + if(i==2) { + latitude[clatitude++]=line_gps[j+1]; + } + else if(i==3) { + latitude[clatitude++]=line_gps[j+1]; + } + else if(i==4) { + longitude[clongitude++]=line_gps[j+1]; + } + else if(i==5) { + longitude[clongitude++]=line_gps[j+1]; + } + else if(i==6) { + velocidade[cvelocidade++]=line_gps[j+1]; + } + else if(i==7) { + heading[cheading++]=line_gps[j+1]; + } + } + Serial.println(""); + if(mode==MODE_GPS_LATLONG) lcdPrint(latitude, longitude,0); + else if(mode==MODE_GPS_SPEED) lcdPrint("Speed", velocidade, 0); + else if(mode==MODE_GPS_HEADING) lcdPrint("Heading", heading, 0); + } + } + cvelocidade=0; + clatitude=0; + clongitude=0; + cheading=0; + conta=0; // Reset the buffer + for (int i=0;i<300;i++) + { + line_gps[i]=' '; + } + } + } +} + +void resetDados() { + for( int i=0;i<16;i++) { + latitude[i]=' '; + longitude[i]=' '; + velocidade[i]=' '; + heading[i]=' '; + } +} + +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcdPrint("Eletron Livre", "Tiziu", 0); + delay(2000); +} + + + + + +void lcdPrint(String line1, String line2, long time) { + if(time==0 && lcdNextUpdate>millis()) return; + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print(line1); + lcd.setCursor(0, 1); + lcd.print(line2); + if(time > 0) { //user want to keep last lines... + lcdNextUpdate = millis() + time; + } + else { + lcdLine1=line1; + lcdLine2=line2; + lcdNextUpdate = 0; + } + lcdLastUpdate=millis(); +} + + +void lcdRestore() { + if(lcdNextUpdate!=0 && lcdNextUpdate<=millis()){ + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print(lcdLine1); + lcd.setCursor(0, 1); + lcd.print(lcdLine2); + lcdNextUpdate=0; + } +} + +void debug() { + lcdPrint("Debug", "Avanca", 0); + + digitalWrite(MOTOR_A, 0); + digitalWrite(MOTOR_B, 1); + analogWrite(MOTOR_PWM, 250); + delay(1500); + if(mode!=MODE_DEBUG) return; + + lcdPrint("Debug", "Para", 0); + analogWrite(MOTOR_PWM, 0); + delay(1500); + if(mode!=MODE_DEBUG) return; + + lcdPrint("Debug", "Retro", 0); + digitalWrite(MOTOR_A, 1); + digitalWrite(MOTOR_B, 0); + analogWrite(MOTOR_PWM, 250); + delay(1500); + if(mode!=MODE_DEBUG) return; + + lcdPrint("Debug", "Para", 0); + analogWrite(MOTOR_PWM, 0); + delay(1500); + +} + +void resetMode() { + analogWrite(MOTOR_PWM,0); +} + + +void autoCompass(byte flag, byte numOfValues) { + if(mode!=MODE_AUTOPILOT_COMPASS) return; + int bussola = meetAndroid.getInt(); + char c1[10]; + itoa(bussola,c1,10); + + lcdPrint("Compass", c1, 0); + + +} + +float acelerometro[3]; +void ghostPilot(byte flag, byte numOfValues) { + if(mode!=MODE_AUTOPILOT_ACELEROMETER) return; + meetAndroid.getFloatValues(acelerometro); + + if(acelerometro[0]<-3) { //para esquerda + lcdPrint("Debug", "Retro", 0); + digitalWrite(MOTOR_A, 1); + digitalWrite(MOTOR_B, 0); + analogWrite(MOTOR_PWM, 250); + + } + else if(acelerometro[0]>3) { //para direita + lcdPrint("Debug", "Avanca", 0); + digitalWrite(MOTOR_A, 0); + digitalWrite(MOTOR_B, 1); + analogWrite(MOTOR_PWM, 250); + + } + else { + analogWrite(MOTOR_PWM, 0); + } + //lcdPrint("" + acelerometro[0], "" + acelerometro[1], 0); + +} + + +/*caso 1 + + + heading target command + + 10 0 reward + 0 10 forward + + + */ + + + + + + + diff --git a/arduino/all the sketchs of my life/Boat_Central/EletronLCD.ino b/arduino/all the sketchs of my life/Boat_Central/EletronLCD.ino new file mode 100644 index 0000000..a1593aa --- /dev/null +++ b/arduino/all the sketchs of my life/Boat_Central/EletronLCD.ino @@ -0,0 +1,8 @@ + +class EletronLCD { + private: + + public: + +}; + diff --git a/arduino/all the sketchs of my life/Boat_Central/EletronOS.ino b/arduino/all the sketchs of my life/Boat_Central/EletronOS.ino new file mode 100644 index 0000000..b483304 --- /dev/null +++ b/arduino/all the sketchs of my life/Boat_Central/EletronOS.ino @@ -0,0 +1,7 @@ + +class EletronOS { + private: + + public: + +}; diff --git a/arduino/all the sketchs of my life/Boat_Central/ProgramME.ino b/arduino/all the sketchs of my life/Boat_Central/ProgramME.ino new file mode 100644 index 0000000..aa16572 --- /dev/null +++ b/arduino/all the sketchs of my life/Boat_Central/ProgramME.ino @@ -0,0 +1,9 @@ +#define LED_P5 4 + +class ProgramME { + private: + + public: + +}; + diff --git a/arduino/all the sketchs of my life/CoffeTimer.zip b/arduino/all the sketchs of my life/CoffeTimer.zip new file mode 100644 index 0000000..2bf81cb Binary files /dev/null and b/arduino/all the sketchs of my life/CoffeTimer.zip differ diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/build.xml b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/build.xml new file mode 100644 index 0000000..04a8adb --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project ClientConsole. + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/build/jar/META-INF/MANIFEST.MF b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/build/jar/META-INF/MANIFEST.MF new file mode 100644 index 0000000..1e3875e --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/build/jar/META-INF/MANIFEST.MF @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Ant-Version: Apache Ant 1.8.1 +Created-By: 1.6.0_18-b07 (Sun Microsystems Inc.) +X-COMMENT: Main-Class will be added automatically by build +Main-Class: clientconsole.Main + diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/build/jar/META-INF/application-client.xml b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/build/jar/META-INF/application-client.xml new file mode 100644 index 0000000..d61dea1 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/build/jar/META-INF/application-client.xml @@ -0,0 +1,4 @@ + + + ClientConsole + diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/build/jar/gfv3ee6.dpf b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/build/jar/gfv3ee6.dpf new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/ant-deploy.xml b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/ant-deploy.xml new file mode 100644 index 0000000..b03100d --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/ant-deploy.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/build-impl.xml b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/build-impl.xml new file mode 100644 index 0000000..071e6fc --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/build-impl.xml @@ -0,0 +1,982 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set build.generated.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Main class must be set. Go to ClientConsole project properties -> Run and set the main class there. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. + + + Launching ${browse.url} + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/genfiles.properties b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/genfiles.properties new file mode 100644 index 0000000..6747a25 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=da2f8713 +build.xml.script.CRC32=15c62e87 +build.xml.stylesheet.CRC32=2c379194@1.16.2.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=da2f8713 +nbproject/build-impl.xml.script.CRC32=b080f751 +nbproject/build-impl.xml.stylesheet.CRC32=b21e29a6@1.16.2.1 diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/private/private.properties b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/private/private.properties new file mode 100644 index 0000000..94f1d54 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/private/private.properties @@ -0,0 +1,11 @@ +deploy.ant.properties.file=/home/vsenger/.netbeans/6.9/gfv31837373329.properties +j2ee.appclient.tool.jvmoptions=-Djava.endorsed.dirs="/java/glassfish3.1-final/glassfish/lib/endorsed":"/java/glassfish3.1-final/glassfish/modules/endorsed" -javaagent:"/java/glassfish3.1-final/glassfish/modules/gf-client.jar"=mode=acscript,arg=-configxml,arg="/java/glassfish3.1-final/glassfish/domains/domain1/config/sun-acc.xml",client=jar= +j2ee.appclient.tool.jvmoptions.class=-Djava.endorsed.dirs="/java/glassfish-3.0.1/glassfish/lib/endorsed":"/java/glassfish-3.0.1/glassfish/modules/endorsed" -javaagent:"/java/glassfish-3.0.1/glassfish/modules/gf-client.jar"=mode=acscript,arg=-configxml,arg="/java/glassfish-3.0.1/glassfish/domains/domain1/config/sun-acc.xml",client=class= +j2ee.appclient.tool.mainclass=org.glassfish.appclient.client.AppClientFacade +j2ee.appclient.tool.runtime= +j2ee.platform.is.jsr109=true +j2ee.server.home=/java/glassfish3.1-final/glassfish +j2ee.server.instance=[/java/glassfish3.1-final/glassfish]deployer:gfv3ee6:localhost:4848 +source.encoding=UTF-8 +user.properties.file=/home/vsenger/.netbeans/6.9/build.properties +wa.copy.client.jar.from=/java/glassfish3.1-final/glassfish/domains/domain1/generated/xml diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/private/private.xml b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/private/private.xml new file mode 100644 index 0000000..c1f155a --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/project.properties b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/project.properties new file mode 100644 index 0000000..522ba2c --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/project.properties @@ -0,0 +1,85 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/jar +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.ear.classes.dir=${build.dir}/jar +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.ear.jar=${dist.dir}/${jar.name} +dist.jar=${dist.dir}/${jar.name} +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath=\ + ${libs.javaee-endorsed-api-6.0.classpath} +excludes= +includes=** +j2ee.appclient.mainclass.args=${j2ee.appclient.tool.args} +j2ee.platform=1.6 +j2ee.platform.classpath=${j2ee.server.home}/modules/javax.security.jacc.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.security.auth.message.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxrpc-api-osgi.jar:${j2ee.server.home}/modules/jsf-impl.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.ejb.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.enterprise.deploy.jar:${j2ee.server.home}/modules/javax.jms.jar:${j2ee.server.home}/modules/javax.transaction.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.servlet.jar:${j2ee.server.home}/modules/endorsed/javax.annotation.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee.jar:${j2ee.server.home}/modules/javax.resource.jar:${j2ee.server.home}/modules/jsf-api.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/jstl-impl.jar +j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar +j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar +j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsit.classpath= +j2ee.server.type=gfv3ee6 +jar.compress=false +jar.name=ClientConsole.jar +javac.classpath=\ + ${reference.Coffee-Timer-EJB.dist} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=${javac.classpath} +javac.source=1.6 +javac.target=1.6 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javac.test.processorpath=${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=clientconsole.Main +manifest.file=${meta.inf}/MANIFEST.MF +meta.inf=${source.root}/conf +platform.active=default_platform +project.Coffee-Timer-EJB=../Coffee-Timer-EJB +reference.Coffee-Timer-EJB.dist=${project.Coffee-Timer-EJB}/dist/Coffee-Timer-EJB.jar +resource.dir=setup +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.root=src +src.dir=${source.root}/java +test.src.dir=test diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/project.xml b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/project.xml new file mode 100644 index 0000000..7a4e01b --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/nbproject/project.xml @@ -0,0 +1,27 @@ + + + org.netbeans.modules.j2ee.clientproject + + + ClientConsole + 1.6.5 + + + + + + + reference.Coffee-Timer-EJB.dist + + + + Coffee-Timer-EJB + jar + + dist + clean + dist + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/src/conf/MANIFEST.MF b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/src/conf/MANIFEST.MF new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/src/conf/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/src/conf/application-client.xml b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/src/conf/application-client.xml new file mode 100644 index 0000000..d61dea1 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/src/conf/application-client.xml @@ -0,0 +1,4 @@ + + + ClientConsole + diff --git a/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/src/java/clientconsole/Main.java b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/src/java/clientconsole/Main.java new file mode 100644 index 0000000..5cf260c --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/ClientConsole/src/java/clientconsole/Main.java @@ -0,0 +1,25 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package clientconsole; + +import java.rmi.RemoteException; +import javax.ejb.EJB; + +/** + * + * @author vsenger + */ +public class Main { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) throws RemoteException { + // TODO code application logic here + //wakeUpBean.agendarTarefa(); + } + +} diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/build.xml b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/build.xml new file mode 100644 index 0000000..b02a2ba --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/build.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + Builds, tests, and runs the project CoffeeTimerEJB. + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/build/classes/META-INF/MANIFEST.MF b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/build/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/build/classes/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/ant-deploy.xml b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/ant-deploy.xml new file mode 100644 index 0000000..b03100d --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/ant-deploy.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/build-impl.xml b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/build-impl.xml new file mode 100644 index 0000000..ba7738c --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/build-impl.xml @@ -0,0 +1,764 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set main.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/genfiles.properties b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/genfiles.properties new file mode 100644 index 0000000..39d826c --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/genfiles.properties @@ -0,0 +1,9 @@ +build.xml.data.CRC32=124b022d +build.xml.script.CRC32=ffa052f7 +build.xml.stylesheet.CRC32=5910fda3@1.22.2 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=124b022d +nbproject/build-impl.xml.script.CRC32=8d3f4e00 +nbproject/build-impl.xml.stylesheet.CRC32=33606734@1.22.2 +nbproject/jaxws-build.xml.stylesheet.CRC32=c57740bd diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/jax-ws.xml b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/jax-ws.xml new file mode 100644 index 0000000..7888689 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/jax-ws.xml @@ -0,0 +1,9 @@ + + + + + br.com.eletronlivre.cofffeetimer.ws.CoffeeSchedullerWS + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/jaxws-build.xml b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/jaxws-build.xml new file mode 100644 index 0000000..75ca966 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/jaxws-build.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/private/private.properties b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/private/private.properties new file mode 100644 index 0000000..e960801 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/private/private.properties @@ -0,0 +1,7 @@ +deploy.ant.properties.file=/home/vsenger/.netbeans/6.9/gfv3-1780747739.properties +j2ee.platform.is.jsr109=true +j2ee.server.home=/java/nb7-glassfish-3.1.1/glassfish +j2ee.server.instance=[/java/nb7-glassfish-3.1.1/glassfish]deployer:gfv3ee6:localhost:4848 +javac.debug=true +javadoc.preview=true +netbeans.user=/home/vsenger/.netbeans/6.9 diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/private/private.xml b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/private/private.xml new file mode 100644 index 0000000..0125e76 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/private/private.xml @@ -0,0 +1,9 @@ + + + + + file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/arduino/ArduinoBoard.java + file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java + file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOnBean.java + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/project.properties b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/project.properties new file mode 100644 index 0000000..f05d915 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/project.properties @@ -0,0 +1,80 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form,**/.nbattrs +build.dir=build +build.ear.classes.dir=${build.dir}/classes +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +debug.classpath=${javac.classpath}:${build.classes.dir} +debug.test.classpath=\ + ${run.test.classpath} +dist.dir=dist +dist.ear.jar=${dist.dir}/${jar.name} +dist.jar=${dist.dir}/${jar.name} +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath=\ + ${libs.javaee-endorsed-api-6.0.classpath} +excludes= +file.reference.RXTXcomm.jar=../../../../../../../usr/share/java/RXTXcomm.jar +includes=** +j2ee.compile.on.save=false +j2ee.deploy.on.save=false +j2ee.platform=1.6 +j2ee.platform.classpath=${j2ee.server.home}/modules/javax.security.jacc.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.jms.jar:${j2ee.server.home}/modules/jstl-impl.jar:${j2ee.server.home}/modules/javax.management.j2ee.jar:${j2ee.server.home}/modules/javax.transaction.jar:${j2ee.server.home}/modules/endorsed/javax.annotation.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/jsf-impl.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/jsf-api.jar:${j2ee.server.home}/modules/javax.servlet.jar:${j2ee.server.home}/modules/javax.enterprise.deploy.jar:${j2ee.server.home}/modules/jaxrpc-api-osgi.jar:${j2ee.server.home}/modules/javax.resource.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/jaxr-api-osgi.jar:${j2ee.server.home}/modules/javax.security.auth.message.jar +j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar +j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar +j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsit.classpath= +j2ee.server.type=gfv3ee6 +jar.compress=false +jar.name=CoffeeTimerEJB.jar +javac.classpath=\ + ${file.reference.RXTXcomm.jar}:\ + ${reference.CoffeeTimerInterface.jar} +javac.debug=true +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.6 +javac.target=1.6 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javac.test.processorpath=${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.preview=true +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +meta.inf=${source.root}/conf +meta.inf.excludes=sun-cmp-mappings.xml +platform.active=default_platform +project.CoffeeTimerInterface=../CoffeeTimerInterface +reference.CoffeeTimerInterface.jar=${project.CoffeeTimerInterface}/dist/CoffeeTimerInterface.jar +resource.dir=setup +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +# Space-separated list of JVM arguments used when running a class with a main method or a unit test +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): +runmain.jvmargs=-Dgnu.io.rxtx.SerialPorts=/dev/rfcomm1 +source.encoding=UTF-8 +source.root=src +src.dir=${source.root}/java +test.src.dir=test diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/project.xml b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/project.xml new file mode 100644 index 0000000..d92a8ab --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/nbproject/project.xml @@ -0,0 +1,31 @@ + + + org.netbeans.modules.j2ee.ejbjarproject + + + + + + CoffeeTimerEJB + 1.6.5 + file.reference.RXTXcomm.jar + reference.CoffeeTimerInterface.jar + + + + + + + + + + CoffeeTimerInterface + jar + + jar + clean + jar + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/conf/MANIFEST.MF b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/conf/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOffBean.java b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOffBean.java new file mode 100644 index 0000000..9d283a4 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOffBean.java @@ -0,0 +1,48 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.eletronlivre.cofffeetimer; + +import br.com.eletronlivre.cofffeetimer.arduino.ArduinoBoard; +import br.com.globalcode.eletronlivre.arduino.serial.Arduino; +import javax.ejb.Timer; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Resource; +import javax.ejb.EJB; +import javax.ejb.SessionContext; +import javax.ejb.Stateless; +import javax.ejb.Timeout; +import javax.ejb.TimerService; + +/** + * + * @author vsenger + */ +@Stateless +public class TurnOffBean { + @EJB + ArduinoBoard board; + + @Resource + TimerService timerService; + @Resource + SessionContext ctx; + + public void agendarTarefa(long tempo) { + TimerService agendador = ctx.getTimerService(); + agendador.createTimer(tempo,null); + } + + @Timeout + private void wakeUp(Timer timer) { + System.out.println("Vamos desligar!"); + try { + //Arduino.enviar("A-B"); + board.enviar("A-B"); + } catch (Exception ex) { + Logger.getLogger(TurnOffBean.class.getName()).log(Level.SEVERE, null, ex); + } + } +} diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOnBean.java b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOnBean.java new file mode 100644 index 0000000..0e6b706 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/TurnOnBean.java @@ -0,0 +1,62 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.eletronlivre.cofffeetimer; + +import br.com.eletronlivre.cofffeetimer.arduino.ArduinoBoard; +import br.com.globalcode.eletronlivre.arduino.serial.Arduino; +import javax.ejb.EJB; +import javax.ejb.Timer; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Resource; +import javax.ejb.SessionContext; +import javax.ejb.Stateless; +import javax.ejb.Timeout; +import javax.ejb.TimerService; + +/** + * + * @author vsenger + */ +@Stateless +public class TurnOnBean implements WakeUpScheduler { + + @EJB + private TurnOffBean turnOffBean; + @EJB + private ArduinoBoard board; + + public TurnOnBean() { + } + @Resource + TimerService timerService; + @Resource + SessionContext ctx; + + @Override + public void agendarTarefa(long emQuantoTempo, long porQuantoTempo) { + System.out.println("Serviço agendado!"); + System.out.println("Ligando em " + emQuantoTempo + " por " + porQuantoTempo + " segundos"); + TimerService agendador = ctx.getTimerService(); + board.testando(); + agendador.createTimer(emQuantoTempo, null); + turnOffBean.agendarTarefa(porQuantoTempo + emQuantoTempo); + + } + + + + + @Timeout + public void wakeUp(Timer timer) { + System.out.println("Vamos ligarrr!"); + try { + //Arduino.enviar("A+B"); + board.enviar("A+B"); + } catch (Exception ex) { + Logger.getLogger(TurnOnBean.class.getName()).log(Level.SEVERE, null, ex); + } + } +} diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java new file mode 100644 index 0000000..cbbf463 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java @@ -0,0 +1,20 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package br.com.eletronlivre.cofffeetimer; + +import java.rmi.RemoteException; +import javax.ejb.Remote; + +/** + * + * @author vsenger + */ +@Remote +public interface WakeUpScheduler { + + void agendarTarefa(long time, long tt) throws RemoteException; + +} diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/arduino/ArduinoBoard.java b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/arduino/ArduinoBoard.java new file mode 100644 index 0000000..11e5109 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/arduino/ArduinoBoard.java @@ -0,0 +1,103 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.eletronlivre.cofffeetimer.arduino; + +import gnu.io.CommPortIdentifier; +import gnu.io.SerialPort; +import gnu.io.UnsupportedCommOperationException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Enumeration; +import javax.annotation.PostConstruct; +import javax.ejb.Singleton; +import javax.ejb.LocalBean; + +/** + * + * @author vsenger + */ +@Singleton +@LocalBean +public class ArduinoBoard { + Enumeration portList; + CommPortIdentifier portId; + String messageString = "10"; + SerialPort serialPort; + OutputStream outputStream; + InputStream inputStream; + boolean outputBufferEmptyFlag = false; + String defaultPort = "/dev/rfcomm1"; + int x = 0; + + public SerialPort getSerialPort() { + return serialPort; + } + + public void setSerialPort(SerialPort serialPort) { + this.serialPort = serialPort; + } + + public void testando() { + System.out.println("x++" + x++); + } + + public void delay(long milis) { + try { + Thread.sleep(milis); + } catch (InterruptedException ex) { + } + + } + + @PostConstruct + public void init() { + + portList = CommPortIdentifier.getPortIdentifiers(); + + System.out.println("Iniciando"); + while (portList.hasMoreElements()) { + portId = (CommPortIdentifier) portList.nextElement(); + System.out.println(portId.getName()); + if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { + if (portId.getName().equals(defaultPort)) { + System.out.println("Found port " + defaultPort); + try { + serialPort = + (SerialPort) portId.open("SimpleWriteCOM17", 115200); + } catch (Exception e) { + System.out.println("Port in use."); + continue; + } + + try { + outputStream = serialPort.getOutputStream(); + inputStream = serialPort.getInputStream(); + serialPort.setSerialPortParams(115200, + SerialPort.DATABITS_8, + SerialPort.STOPBITS_1, + SerialPort.PARITY_NONE); + + serialPort.notifyOnOutputEmpty(true); + } catch (UnsupportedCommOperationException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + System.out.println("Error setting event notification"); + System.out.println(e.toString()); + } + } + } + } + } + + public void enviar(String s) throws Exception { + outputStream.write(s.getBytes()); + outputStream.flush(); + } + + +} diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/ws/CoffeeSchedullerWS.java b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/ws/CoffeeSchedullerWS.java new file mode 100644 index 0000000..3cf2c8b --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/eletronlivre/cofffeetimer/ws/CoffeeSchedullerWS.java @@ -0,0 +1,31 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.eletronlivre.cofffeetimer.ws; + +import br.com.eletronlivre.cofffeetimer.WakeUpScheduler; +import java.rmi.RemoteException; +import javax.ejb.EJB; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.ejb.Stateless; + +/** + * + * @author vsenger + */ +@WebService() +@Stateless() +public class CoffeeSchedullerWS { + + @EJB + private WakeUpScheduler ejbRef;// Add business logic below. (Right-click in editor and choose + // "Insert Code > Add Web Service Operation") + + @WebMethod(operationName = "agendarTarefa") + public void agendarTarefa(@WebParam(name = "time") long time, @WebParam(name = "tt") long tt) throws RemoteException { + ejbRef.agendarTarefa(time, tt); + } +} diff --git a/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java new file mode 100644 index 0000000..d1c0ea2 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/Coffee-Timer-EJB/src/java/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java @@ -0,0 +1,144 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.globalcode.eletronlivre.arduino.serial; + +import gnu.io.CommPortIdentifier; +import gnu.io.SerialPort; +import gnu.io.UnsupportedCommOperationException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Enumeration; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author vsenger + */ +public class Arduino { + + static boolean init = false; + static Enumeration portList; + static CommPortIdentifier portId; + static String messageString = "10"; + static SerialPort serialPort; + static OutputStream outputStream; + static InputStream inputStream; + static boolean outputBufferEmptyFlag = false; + static String defaultPort = "/dev/rfcomm0"; + //static String defaultPort = "/dev/tty.usbserial-A6007W3X"; + //static String defaultPort = "/dev/ttyUSB0"; + public static void begin(int bps) { + if (!init) { + init(); + } + + } + public static void delay(long milis) { + try { + Thread.sleep(milis); + } catch (InterruptedException ex) { + } + + } + + public static void init() { + init = true; + portList = CommPortIdentifier.getPortIdentifiers(); + + System.out.println("Iniciando"); + while (portList.hasMoreElements()) { + portId = (CommPortIdentifier) portList.nextElement(); + System.out.println(portId.getName()); + if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { + if (portId.getName().equals(defaultPort)) { + System.out.println("Found port " + defaultPort); + try { + serialPort = + (SerialPort) portId.open("SimpleWriteCOM17", 115200); + } catch (Exception e) { + System.out.println("Port in use."); + continue; + } + + + try { + outputStream = serialPort.getOutputStream(); + inputStream = serialPort.getInputStream(); + serialPort.setSerialPortParams(115200, + SerialPort.DATABITS_8, + SerialPort.STOPBITS_1, + SerialPort.PARITY_NONE); + + serialPort.notifyOnOutputEmpty(true); + } catch (UnsupportedCommOperationException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + System.out.println("Error setting event notification"); + System.out.println(e.toString()); + } + } + } + } + } + + public static void enviar(String s) throws Exception { + if (!init) { + init(); + } + + outputStream.write(s.getBytes()); + outputStream.flush(); + } + + public static void enviar(float f) throws Exception { + + enviar(new byte[]{(byte) f}); + } + //100, 1, 1024, 1, 9 + public static int map(int val, int minOriginal, int maxOriginal, int minTarget, int maxTarget) { + return val / ((maxOriginal - minOriginal) / (maxTarget - minTarget)); + + + } + public static void main(String[] args) throws Exception{ + enviar("L"); + } + public static void enviar(byte bytes[]) throws Exception { + if (!init) { + init(); + } + + System.out.println("Escrevendo..."); + outputStream.write((int)'B'); //my I2C ID + System.out.println(bytes[0]); + + outputStream.write(bytes[0] ==0 ? 10 : bytes[0] ); + outputStream.flush(); + System.out.println("Esperando..."); + + + } + class BluetoothListener extends Thread { + public void run() { + while(true) { + try { + if (inputStream.available() > 0) { + while(inputStream.available()>0) { + System.out.print(inputStream.read()); + } + } + } catch (IOException ex) { + Logger.getLogger(Arduino.class.getName()).log(Level.SEVERE, null, ex); + } + Arduino.delay(50); + + } + } + } +} diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/build.xml b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/build.xml new file mode 100644 index 0000000..2b91f59 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project CoffeeTimerInterface. + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/build/built-jar.properties b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/build/built-jar.properties new file mode 100644 index 0000000..9fa36ae --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/build/built-jar.properties @@ -0,0 +1,3 @@ +#Wed, 28 Sep 2011 12:13:11 -0300 + +/media/Vinicius/EletronLivre/Program-ME/Arduino\ Sketches/CoffeTimer/CoffeeTimerInterface= diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/dist/README.TXT b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/dist/README.TXT new file mode 100644 index 0000000..c254c93 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/dist/README.TXT @@ -0,0 +1,33 @@ +======================== +BUILD OUTPUT DESCRIPTION +======================== + +When you build an Java application project that has a main class, the IDE +automatically copies all of the JAR +files on the projects classpath to your projects dist/lib folder. The IDE +also adds each of the JAR files to the Class-Path element in the application +JAR files manifest file (MANIFEST.MF). + +To run the project from the command line, go to the dist folder and +type the following: + +java -jar "CoffeeTimerInterface.jar" + +To distribute this project, zip up the dist folder (including the lib folder) +and distribute the ZIP file. + +Notes: + +* If two JAR files on the project classpath have the same name, only the first +JAR file is copied to the lib folder. +* Only JAR files are copied to the lib folder. +If the classpath contains other types of files or folders, none of the +classpath elements are copied to the lib folder. In such a case, +you need to copy the classpath elements to the lib folder manually after the build. +* If a library on the projects classpath also has a Class-Path element +specified in the manifest,the content of the Class-Path element has to be on +the projects runtime path. +* To set a main class in a standard Java project, right-click the project node +in the Projects window and choose Properties. Then click Run and enter the +class name in the Main Class field. Alternatively, you can manually type the +class name in the manifest Main-Class element. diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/manifest.mf b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/build-impl.xml b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/build-impl.xml new file mode 100644 index 0000000..b93fbb9 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/build-impl.xml @@ -0,0 +1,1042 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + Must select one file in the IDE or set profile.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/genfiles.properties b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/genfiles.properties new file mode 100644 index 0000000..b15c5bf --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=68706b55 +build.xml.script.CRC32=edf4fd04 +build.xml.stylesheet.CRC32=28e38971@1.38.2.45 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=68706b55 +nbproject/build-impl.xml.script.CRC32=20404a75 +nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45 diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/private/config.properties b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/private/private.properties b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/private/private.properties new file mode 100644 index 0000000..3a89297 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/private/private.properties @@ -0,0 +1,6 @@ +compile.on.save=true +do.depend=false +do.jar=true +javac.debug=true +javadoc.preview=true +user.properties.file=/home/vsenger/.netbeans/6.9/build.properties diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/project.properties b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/project.properties new file mode 100644 index 0000000..f11bd26 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/project.properties @@ -0,0 +1,75 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=CoffeeTimerInterface +application.vendor=vsenger +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/CoffeeTimerInterface.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +jar.compress=false +javac.classpath=\ + ${libs.javaee-api-6.0.classpath} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=coffeetimerinterface.Main +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/project.xml b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/project.xml new file mode 100644 index 0000000..0d53d82 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + CoffeeTimerInterface + + + + + + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/src/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/src/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java new file mode 100644 index 0000000..cc2e512 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeTimerInterface/src/br/com/eletronlivre/cofffeetimer/WakeUpScheduler.java @@ -0,0 +1,21 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package br.com.eletronlivre.cofffeetimer; + +import java.rmi.RemoteException; +import javax.ejb.Remote; + +/** + * + * @author vsenger + */ +@Remote +public interface WakeUpScheduler { + + void agendarTarefa() throws RemoteException; + void agendarTarefa(long time, long tt) throws RemoteException; + +} diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build.xml b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build.xml new file mode 100644 index 0000000..cb35d0d --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + Builds, tests, and runs the project CoffeeWebScheduler. + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/META-INF/MANIFEST.MF b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/META-INF/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/classes/.netbeans_automatic_build b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/classes/.netbeans_update_resources b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/sun-web.xml b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/sun-web.xml new file mode 100644 index 0000000..227d849 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/WEB-INF/sun-web.xml @@ -0,0 +1,11 @@ + + + + /CoffeeWebScheduler + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/duke.gif b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/duke.gif new file mode 100644 index 0000000..a358362 Binary files /dev/null and b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/duke.gif differ diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/index.jsp b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/index.jsp new file mode 100644 index 0000000..47b0821 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/build/web/index.jsp @@ -0,0 +1,34 @@ +<%@page import="java.util.Date"%> +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + Cafeteira na Web + + +

Vida além do Java...

+
+ +

Agendar por tempo

+ + Segundos + Minutos +
+ Em quanto tempo que ligar a cafeteira ?
+ Por quanto tempo quer ligar a cafeteira ?
+ + + <% + if (request.getAttribute("horarioAgendado") != null) { + Date horario = (Date) request.getAttribute("horarioAgendado"); + out.println("

Café agendado para "); + out.println(horario); + out.println("

"); + } + %> + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/ant-deploy.xml b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/ant-deploy.xml new file mode 100644 index 0000000..b03100d --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/ant-deploy.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/build-impl.xml b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/build-impl.xml new file mode 100644 index 0000000..49f4b6b --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/build-impl.xml @@ -0,0 +1,1081 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set build.web.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.war + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + Must select a file in the IDE or set jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. + + + Launching ${browse.url} + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/genfiles.properties b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/genfiles.properties new file mode 100644 index 0000000..e4c2012 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=8dde883d +build.xml.script.CRC32=1f0e6d58 +build.xml.stylesheet.CRC32=651128d4@1.33.1.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=8dde883d +nbproject/build-impl.xml.script.CRC32=66c6dde0 +nbproject/build-impl.xml.stylesheet.CRC32=0cbf5bb7@1.33.1.1 diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/private/private.properties b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/private/private.properties new file mode 100644 index 0000000..286ece9 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/private/private.properties @@ -0,0 +1,7 @@ +deploy.ant.properties.file=/home/vsenger/.netbeans/6.9/gfv3-1780747739.properties +j2ee.platform.is.jsr109=true +j2ee.server.home=/java/nb7-glassfish-3.1.1/glassfish +j2ee.server.instance=[/java/nb7-glassfish-3.1.1/glassfish]deployer:gfv3ee6:localhost:4848 +javac.debug=true +javadoc.preview=true +user.properties.file=/home/vsenger/.netbeans/6.9/build.properties diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/private/private.xml b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/private/private.xml new file mode 100644 index 0000000..c1f155a --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/project.properties b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/project.properties new file mode 100644 index 0000000..3dae937 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/project.properties @@ -0,0 +1,90 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.web.dir}/WEB-INF/classes +build.classes.excludes=**/*.java,**/*.form +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +build.web.dir=${build.dir}/web +build.web.excludes=${build.classes.excludes} +client.urlPart= +compile.jsps=false +conf.dir=${source.root}/conf +debug.classpath=${build.classes.dir}:${javac.classpath} +debug.test.classpath=\ + ${run.test.classpath} +display.browser=true +dist.dir=dist +dist.ear.war=${dist.dir}/${war.ear.name} +dist.javadoc.dir=${dist.dir}/javadoc +dist.war=${dist.dir}/${war.name} +endorsed.classpath=\ + ${libs.javaee-endorsed-api-6.0.classpath} +excludes= +includes=** +j2ee.compile.on.save=true +j2ee.deploy.on.save=true +j2ee.platform=1.6 +j2ee.platform.classpath=${j2ee.server.home}/modules/javax.security.jacc.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.jms.jar:${j2ee.server.home}/modules/jstl-impl.jar:${j2ee.server.home}/modules/javax.management.j2ee.jar:${j2ee.server.home}/modules/javax.transaction.jar:${j2ee.server.home}/modules/endorsed/javax.annotation.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/jsf-impl.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/jsf-api.jar:${j2ee.server.home}/modules/javax.servlet.jar:${j2ee.server.home}/modules/javax.enterprise.deploy.jar:${j2ee.server.home}/modules/jaxrpc-api-osgi.jar:${j2ee.server.home}/modules/javax.resource.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/jaxr-api-osgi.jar:${j2ee.server.home}/modules/javax.security.auth.message.jar +j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar +j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar +j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar +j2ee.platform.wsit.classpath= +j2ee.server.type=gfv3ee6 +jar.compress=false +javac.classpath=\ + ${reference.CoffeeTimerInterface.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.debug=true +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.6 +javac.target=1.6 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.preview=true +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +lib.dir=${web.docbase.dir}/WEB-INF/lib +persistence.xml.dir=${conf.dir} +platform.active=default_platform +project.CoffeeTimerInterface=../CoffeeTimerInterface +reference.CoffeeTimerInterface.jar=${project.CoffeeTimerInterface}/dist/CoffeeTimerInterface.jar +resource.dir=setup +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +# Space-separated list of JVM arguments used when running a class with a main method or a unit test +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): +runmain.jvmargs=-Dgnu.io.rxtx.SerialPorts=/dev/rfcomm1 +source.encoding=UTF-8 +source.root=src +src.dir=${source.root}/java +test.src.dir=test +war.content.additional= +war.ear.name=CoffeeWebScheduler.war +war.name=CoffeeWebScheduler.war +web.docbase.dir=web +webinf.dir=web/WEB-INF diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/project.xml b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/project.xml new file mode 100644 index 0000000..bfe940b --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/nbproject/project.xml @@ -0,0 +1,33 @@ + + + org.netbeans.modules.web.project + + + CoffeeWebScheduler + 1.6.5 + + + ${reference.CoffeeTimerInterface.jar} + WEB-INF/lib + + + + + + + + + + + + + CoffeeTimerInterface + jar + + jar + clean + jar + + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/src/conf/MANIFEST.MF b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/src/conf/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/src/java/teste/Agendador.java b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/src/java/teste/Agendador.java new file mode 100644 index 0000000..98af6eb --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/src/java/teste/Agendador.java @@ -0,0 +1,97 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package teste; + +import br.com.eletronlivre.cofffeetimer.WakeUpScheduler; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Calendar; +import javax.ejb.EJB; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author vsenger + */ +@WebServlet(name = "Agendador", urlPatterns = {"/Agendador"}) +public class Agendador extends HttpServlet { + + @EJB + private WakeUpScheduler wakeUpBean; + + /** + * Processes requests for both HTTP GET and POST methods. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + PrintWriter out = response.getWriter(); + try { + int tipo = Integer.parseInt(request.getParameter("tipoValor")); + int emQuantoTempo = Integer.parseInt(request.getParameter("txtEmQuantoTempo")); + int porQuantoTempo = Integer.parseInt(request.getParameter("txtPorQuantoTempo")); + Calendar cal = Calendar.getInstance(); + cal.add(tipo == 2 ? Calendar.MINUTE : Calendar.SECOND, emQuantoTempo); + request.setAttribute("horarioAgendado", cal.getTime()); + + emQuantoTempo *= 1000; + porQuantoTempo *= 1000; + if (tipo == 2) { + emQuantoTempo *= 60; + porQuantoTempo *= 60; + } + wakeUpBean.agendarTarefa(emQuantoTempo, porQuantoTempo); + RequestDispatcher dispatcher = request.getRequestDispatcher("index.jsp"); + dispatcher.forward(request, response); + } finally { + out.close(); + } + } + + // + /** + * Handles the HTTP GET method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/web/WEB-INF/sun-web.xml b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/web/WEB-INF/sun-web.xml new file mode 100644 index 0000000..227d849 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/web/WEB-INF/sun-web.xml @@ -0,0 +1,11 @@ + + + + /CoffeeWebScheduler + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/web/duke.gif b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/web/duke.gif new file mode 100644 index 0000000..a358362 Binary files /dev/null and b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/web/duke.gif differ diff --git a/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/web/index.jsp b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/web/index.jsp new file mode 100644 index 0000000..47b0821 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeTimer/CoffeeWebScheduler/web/index.jsp @@ -0,0 +1,34 @@ +<%@page import="java.util.Date"%> +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + Cafeteira na Web + + +

Vida além do Java...

+
+ +

Agendar por tempo

+
+ Segundos + Minutos +
+ Em quanto tempo que ligar a cafeteira ?
+ Por quanto tempo quer ligar a cafeteira ?
+ +
+ <% + if (request.getAttribute("horarioAgendado") != null) { + Date horario = (Date) request.getAttribute("horarioAgendado"); + out.println("

Café agendado para "); + out.println(horario); + out.println("

"); + } + %> + + + diff --git a/arduino/all the sketchs of my life/CoffeeWebInterface/build/web/WEB-INF/sun-web.xml b/arduino/all the sketchs of my life/CoffeeWebInterface/build/web/WEB-INF/sun-web.xml new file mode 100644 index 0000000..99279a2 --- /dev/null +++ b/arduino/all the sketchs of my life/CoffeeWebInterface/build/web/WEB-INF/sun-web.xml @@ -0,0 +1,11 @@ + + + + /CoffeeWebInterface + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/arduino/all the sketchs of my life/Componentes/BlueSmirf/BlueSmirf.pde b/arduino/all the sketchs of my life/Componentes/BlueSmirf/BlueSmirf.pde new file mode 100644 index 0000000..77c31bb --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/BlueSmirf/BlueSmirf.pde @@ -0,0 +1,74 @@ +#include +#include + +char comando[16]; +int luz= 0; + +LiquidCrystal lcd(4, 9, 14, 15, 16, 17); +// set up a new serial port + +void setup() +{ + pinMode(3, OUTPUT); + pinMode(4, OUTPUT); + Wire.begin(); + Serial.begin(115200); + initLCD(); +} + +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Mater I2C On"); + lcd.setCursor(0, 1); + lcd.print("Waiting command."); +} + +void loop () +{ + if(Serial.available()>0) { + limpaComando(); + + int counter =0; + while(Serial.available()>0) { + comando[counter++]=Serial.read(); + delay(20); + } + lcd.clear(); + lcd.setCursor(0, 0); + + lcd.print(comando); + executarComando(); + //lcd.print("Aguardando...."); + for(int x=0;x<4;x++) { + digitalWrite(4, HIGH); + delay(30); + digitalWrite(4, LOW); + delay(30); + } + } +} + +void executarComando() { + lcd.setCursor(0, 1); + lcd.print(comando[0]); + lcd.setCursor(2, 1); + lcd.print("commuicated..."); + Wire.beginTransmission(comando[0]); + Wire.send(comando); + Wire.endTransmission(); +} +void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } +} + + + + + + + + diff --git a/arduino/all the sketchs of my life/Componentes/EZ1_Analogica_teste/EZ1_Analogica_teste.pde b/arduino/all the sketchs of my life/Componentes/EZ1_Analogica_teste/EZ1_Analogica_teste.pde new file mode 100644 index 0000000..bbe9c44 --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/EZ1_Analogica_teste/EZ1_Analogica_teste.pde @@ -0,0 +1,15 @@ +void setup() { + Serial.begin(9600); + +} + +void loop(){ + + int valor = analogRead(1); + Serial.println(valor); + Serial.println(valor*1.6); + Serial.println("---------------"); + + delay(300); +} + diff --git a/arduino/all the sketchs of my life/Componentes/FitaLed_ViaSerial/FitaLed_ViaSerial.pde b/arduino/all the sketchs of my life/Componentes/FitaLed_ViaSerial/FitaLed_ViaSerial.pde new file mode 100644 index 0000000..560faf1 --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/FitaLed_ViaSerial/FitaLed_ViaSerial.pde @@ -0,0 +1,70 @@ +#define Q2 9 +#define Q3 6 +#define Q4 18 + + + +void setup() { + Serial.begin(9600); + pinMode(Q2, OUTPUT); //red + pinMode(Q3, OUTPUT); //green + pinMode(Q4, OUTPUT); +} + +int red; +int green; +int blue; + +void loop() { + + + /*if(Serial.available()>0) + { + red = byte(Serial.read()); + delay(20); + + green = byte(Serial.read()); + delay(20); + blue= byte(Serial.read()); + delay(20); + //red = red = -1 ? 0 : red; + //blue = blue = -1 ? 0 : blue; + //green = green = -1 ? 0 : green; + } + analogWrite(Q2, red); + //analogWrite(Q3, green); + //digitalWrite(Q4, blue); + */ + for(int x=0;x<255;x++) { + analogWrite(Q2, x); + delay(10); + } + for(int x=0;x<255;x++) { + analogWrite(Q3, x); + delay(10); + } + desligar(); + delay(500); + ligar(); + delay(500); + desligar(); + delay(500); + ligar(); + delay(500); + desligar(); + delay(500); + ligar(); + delay(500); + +} +void desligar() { + analogWrite(Q2,0); + analogWrite(Q3,0); +} +void ligar() { + analogWrite(Q2,255); + analogWrite(Q3,255); +} + + + diff --git a/arduino/all the sketchs of my life/Componentes/Fita_RGB_Serial_OK/Fita_RGB_Serial_OK.pde b/arduino/all the sketchs of my life/Componentes/Fita_RGB_Serial_OK/Fita_RGB_Serial_OK.pde new file mode 100644 index 0000000..87ad6c8 --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/Fita_RGB_Serial_OK/Fita_RGB_Serial_OK.pde @@ -0,0 +1,55 @@ +#define RED 9 +#define GREEN 10 +#define BLUE 11 +#define ABRIDOR 12 + + +void setup() { + Serial.begin(9600); + pinMode(RED, OUTPUT); //red + pinMode(GREEN, OUTPUT); //green + pinMode(BLUE, OUTPUT); + pinMode(ABRIDOR, OUTPUT); + +} + +int red=200; +int green=200; +int blue=200; + +void loop() { + if(Serial.available()>0) + { + lerSerial(); + } + ligarStatus(); + +} +void lerSerial() { + red = byte(Serial.read()); + delay(5); + green = byte(Serial.read()); + delay(5); + blue= byte(Serial.read()); + delay(5); + +} +void ligarStatus() { + analogWrite(RED, red); + analogWrite(GREEN, green); + analogWrite(BLUE, blue); +} +void desligar() { + analogWrite(RED, 0); + analogWrite(GREEN, 0); + analogWrite(BLUE, 0); +} +/* +void ligar() { + analogWrite(Q2,255); + analogWrite(Q3,255); + }*/ + + + + diff --git a/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/Fita_de_LEDs.pde b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/Fita_de_LEDs.pde new file mode 100644 index 0000000..2ddcb1f --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/Fita_de_LEDs.pde @@ -0,0 +1,113 @@ +#define BLUE 8 +#define GREEN 9 +#define RED 17 + +void setup() { + pinMode(5, OUTPUT); + pinMode(8, OUTPUT); + pinMode(9, OUTPUT); + pinMode(17, OUTPUT); +} + +void loop() { + int op = random(1,5); + piscaMaluco(20,20); + + switch(op) { + case 1: + piscaMaluco(random(50,100),random(20,50)); + break; + case 2: + ligaG(); + break; + case 3: + desligaG(); + break; + case 4: + liga(); + break; + case 5: + comLDR(); + break; + case 6: + piscaMaluco(random(10,100), random(10,100)); + break; + } + +} +void comLDR() { + + analogWrite(escolheLed(), analogRead(5)); + delay(random(1000,3000)); + +} + +int escolheLed() { + int r = random(1,3); + if(r==1) return 8; + if(r==2) return 9; + if(r==3) return 17; +} +void desligaTudo() { + digitalWrite(RED, LOW); + digitalWrite(GREEN, LOW); + digitalWrite(BLUE, LOW); +} +void liga() { + desligaTudo(); + int l = escolheLed(); + digitalWrite(l,HIGH); + +} + +void pisca(int led, int repeticoes, int d) { + desligaTudo(); + for(int x=0;x-1;x--) { + analogWrite(9, x); + delay(10); + } +} + + + + + + + diff --git a/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/a1.pde b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/a1.pde new file mode 100644 index 0000000..24251d7 --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/a1.pde @@ -0,0 +1,5 @@ +int soma(int x, int y) { + return x + y; + +} + diff --git a/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/applet/Fita_de_LEDs.cpp b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/applet/Fita_de_LEDs.cpp new file mode 100644 index 0000000..9ef2bbb --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/applet/Fita_de_LEDs.cpp @@ -0,0 +1,145 @@ +#define BLUE 8 +#define GREEN 9 +#define RED 17 + +#include "WProgram.h" +void setup(); +void loop(); +void comLDR(); +int escolheLed(); +void desligaTudo(); +void liga(); +void pisca(int led, int repeticoes, int d); +void piscaMaluco(int repeticoes, int d); +void ligaG(); +void ligaRB(); +void desligaG(); +int soma(int x, int y); +void setup() { + pinMode(5, OUTPUT); + pinMode(8, OUTPUT); + pinMode(9, OUTPUT); + pinMode(17, OUTPUT); +} + +void loop() { + int op = random(1,5); + piscaMaluco(20,20); + + switch(op) { + case 1: + piscaMaluco(random(50,100),random(20,50)); + break; + case 2: + ligaG(); + break; + case 3: + desligaG(); + break; + case 4: + liga(); + break; + case 5: + comLDR(); + break; + case 6: + piscaMaluco(random(10,100), random(10,100)); + break; + } + +} +void comLDR() { + + analogWrite(escolheLed(), analogRead(5)); + delay(random(1000,3000)); + +} + +int escolheLed() { + int r = random(1,3); + if(r==1) return 8; + if(r==2) return 9; + if(r==3) return 17; +} +void desligaTudo() { + digitalWrite(RED, LOW); + digitalWrite(GREEN, LOW); + digitalWrite(BLUE, LOW); +} +void liga() { + desligaTudo(); + int l = escolheLed(); + digitalWrite(l,HIGH); + +} + +void pisca(int led, int repeticoes, int d) { + desligaTudo(); + for(int x=0;x-1;x--) { + analogWrite(9, x); + delay(10); + } +} + + + + + + + +int soma(int x, int y) { + return x + y; + +} + + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/applet/wiring.c.o b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/applet/wiring.c.o new file mode 100644 index 0000000..d7fdf00 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/applet/wiring_pulse.c.o new file mode 100644 index 0000000..985ee90 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/applet/wiring_shift.c.o new file mode 100644 index 0000000..1f193bc Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/exemplo.pde b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/exemplo.pde new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/Fita_de_LEDs/exemplo.pde @@ -0,0 +1 @@ + diff --git a/arduino/all the sketchs of my life/Componentes/H48C/H48C.pde b/arduino/all the sketchs of my life/Componentes/H48C/H48C.pde new file mode 100644 index 0000000..95e288b --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/H48C/H48C.pde @@ -0,0 +1,126 @@ +//// VARS +int CS_pin = 9; +int DIO_pin = 10; +int CLK_pin = 11; + +byte tempLSB = 0; +byte tempMSB = 0; + +int aX = 0; +int aY = 0; +int aZ = 0; + +//// FUNCTIONS +void StartMassurement() { + pinMode(DIO_pin, OUTPUT); + digitalWrite(CS_pin, LOW); + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + digitalWrite(DIO_pin, HIGH); + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + + } + +void ShiftOutNibble(byte DataOutNibble) { + for(int i = 3; i >= 0; i--) { // i = 3 ... 2 ... 1 ... 0 + digitalWrite(CLK_pin, LOW); + // set DIO first + if ((DataOutNibble & (1 << i)) == (1 << i)) { // DataOutNibble AND 1 x 2^i Equals 1 x 2^i ? + digitalWrite(DIO_pin, HIGH); + + } + else { + digitalWrite(DIO_pin, LOW); + + } + // with CLK rising edge the chip reads the DIO from arduino in + digitalWrite(CLK_pin, HIGH); + // data rate is f_clk 2.0 Mhz --> 0,5 micro seeconds + delayMicroseconds(1); // :-) just nothing + } + +} + +void SampleIt() { + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + + pinMode(DIO_pin, INPUT); + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + digitalWrite(CLK_pin, HIGH); + if (digitalRead(DIO_pin)== LOW) { + // Blink LED because ok + } +} + +byte ShiftInNibble() { + byte resultNibble; + resultNibble = 0; + + for(int i = 3 ; i >= 0; i--) { + // The chip Shift out results on falling CLK + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); // :-) just nothing + if( digitalRead(DIO_pin) == HIGH) { + resultNibble += 1 << i; + } + else { + resultNibble += 0 << i; + } + digitalWrite(CLK_pin, HIGH); + } +return resultNibble; +} + +void EndMessurement() { + digitalWrite(CS_pin, HIGH); + digitalWrite(CLK_pin, HIGH); +} + +int GetValue(byte Axis) { // x = B1000, y = 1001, z = B1010 + int Result = 0; + StartMassurement(); + ShiftOutNibble(Axis); + SampleIt(); + Result = (ShiftInNibble() << 8) + (ShiftInNibble() << 4) + ShiftInNibble(); + EndMessurement(); + + return Result; + } + +//// SETUP +void setup() { + Serial.begin(9600); + pinMode(CS_pin, OUTPUT); + pinMode(CLK_pin, OUTPUT); + pinMode(DIO_pin, OUTPUT); + // initialize device & reset + digitalWrite(CS_pin,LOW); + digitalWrite(CLK_pin,LOW); + delayMicroseconds(1); + digitalWrite(CS_pin, HIGH); + digitalWrite(CLK_pin,HIGH); +} + + +//// LOOP +void loop() { + Serial.print("X"); + Serial.print(2048 - GetValue(B1000)); + Serial.print("Y"); + Serial.print(2048 - GetValue(B1001)); + //Serial.print(2048 - GetValue(B1010)); + + + Serial.println(""); + delay(100); +} + + + + + diff --git a/arduino/all the sketchs of my life/Componentes/Hitachi_H48C/Hitachi_H48C.pde b/arduino/all the sketchs of my life/Componentes/Hitachi_H48C/Hitachi_H48C.pde new file mode 100644 index 0000000..2cd441d --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/Hitachi_H48C/Hitachi_H48C.pde @@ -0,0 +1,133 @@ +/* +///////////////////////////////// +Htachi H48C3 Axis Accelerometer +parallax (#28026) + +AUTHOR: kiilo kiilo@kiilo.org +License: http://creativecommons.org/licenses/by-nc-sa/2.5/ch/ + +http://parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/28026/List/1/ProductID/97/Default.aspx?SortField=ProductName%2cProductName +http://sage.medienkunst.ch/tiki-index.php?page=HowTo_Arduino_Parallax_H48C_Accelerometer +http://arduino.cc + +///////////////////////////////// +*/ +//// VARS +int CS_pin = 9; +int CLK_pin = 11; +int DIO_pin = 10; + +int aX = 0; +int aY = 0; +int aZ = 0; + +//// FUNCTIONS +void StartBit() { + pinMode(DIO_pin, OUTPUT); + digitalWrite(CS_pin, LOW); + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + digitalWrite(DIO_pin, HIGH); + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + + } + +void ShiftOutNibble(byte DataOutNibble) { + for(int i = 3; i >= 0; i--) { // i = 3 ... 2 ... 1 ... 0 + digitalWrite(CLK_pin, LOW); + // set DIO first + if ((DataOutNibble & (1 << i)) == (1 << i)) { // DataOutNibble AND 1 x 2^i Equals 1 x 2^i ? + digitalWrite(DIO_pin, HIGH); + } + else { + digitalWrite(DIO_pin, LOW); + } + // with CLK rising edge the chip reads the DIO from arduino in + digitalWrite(CLK_pin, HIGH); + // data rate is f_clk 2.0 Mhz --> 0,5 micro seeconds + delayMicroseconds(1); // :-) just nothing + } +} + +void SampleIt() { + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + + pinMode(DIO_pin, INPUT); + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + digitalWrite(CLK_pin, HIGH); + if (digitalRead(DIO_pin)== LOW) { + // Blink LED because ok + } +} + +byte ShiftInNibble() { + byte resultNibble; + resultNibble = 0; + + for(int i = 3 ; i >= 0; i--) { // from bit 3 to 0 + // The chip Shift out results on falling CLK + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); // :-) just nothing + if( digitalRead(DIO_pin) == HIGH) { // BIT set or not? + resultNibble += 1 << i; // Store 1 x 2^i in our ResultNibble + } + else { + resultNibble += 0 << i; // YES this is alway 0, just for symetry ;-) + } + digitalWrite(CLK_pin, HIGH); + //delayMicroseconds(1); // :-) just nothing + } +return resultNibble; +} + +void EndBit() { + digitalWrite(CS_pin, HIGH); + digitalWrite(CLK_pin, HIGH); +} + +int GetValue(byte Command) { // x = B1000, y = B1001, z = B1010 + int Result = 0; + StartBit(); + ShiftOutNibble(Command); + SampleIt(); + Result = 2048 - ((ShiftInNibble() << 8) + (ShiftInNibble() << 4) + ShiftInNibble()); + EndBit(); + + return Result; + } + +//// SETUP +void setup() { + Serial.begin(115200); + pinMode(CS_pin, OUTPUT); + pinMode(CLK_pin, OUTPUT); + pinMode(DIO_pin, OUTPUT); + // initialize device & reset + digitalWrite(CS_pin,LOW); + digitalWrite(CLK_pin,LOW); + delayMicroseconds(1); + digitalWrite(CS_pin, HIGH); + digitalWrite(CLK_pin,HIGH); +} + + +//// LOOP +void loop() { + + aX = GetValue(B1000); + aY = GetValue(B1010); + aZ = GetValue(B1011); + + Serial.print(aX); + Serial.print(" "); + Serial.print(aY); + Serial.print(" "); + Serial.print(aZ); + Serial.println(" "); + delay(100); // loop every 10 times per sec. +} diff --git a/arduino/all the sketchs of my life/Componentes/Servo/Servo.pde b/arduino/all the sketchs of my life/Componentes/Servo/Servo.pde new file mode 100644 index 0000000..b4553af --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/Servo/Servo.pde @@ -0,0 +1,21 @@ +#include + +Servo myservo9; // create servo object to control a servo +Servo myservo10; // create servo object to control a servo + +int pos = 0; // variable to store the servo position + +void setup() +{ + myservo9.attach(11); // attaches the servo on pin 9 to the servo object + myservo10.attach(10); // attaches the servo on pin 10 to the servo object +} + +void loop() +{ + int val = map(analogRead(1), 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) + myservo10.write(val); // sets the servo position according to the scaled value + delay(15); // waits for the servo to get there + +} + diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Componentes/Servo/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..dc28a59 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/Print.cpp.o b/arduino/all the sketchs of my life/Componentes/Servo/applet/Print.cpp.o new file mode 100644 index 0000000..6205c51 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.cpp b/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.cpp new file mode 100644 index 0000000..b53f628 --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.cpp @@ -0,0 +1,35 @@ +#include + +#include "WProgram.h" +void setup(); +void loop(); +Servo myservo10; // create servo object to control a servo + +int pos = 0; // variable to store the servo position + +void setup() +{ + myservo10.attach(10); // attaches the servo on pin 10 to the servo object +} + +void loop() +{ + int val = map(analogRead(1), 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) + myservo10.write(val); // sets the servo position according to the scaled value + delay(15); // waits for the servo to get there + +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.cpp.o b/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.cpp.o new file mode 100644 index 0000000..dd8af4e Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.cpp.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.eep b/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.elf b/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.elf new file mode 100644 index 0000000..b57ff8f Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.elf differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.hex b/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.hex new file mode 100644 index 0000000..76cbef4 --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.hex @@ -0,0 +1,125 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C94A5010C948A000C948A000C948A00EC +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C00000004C0111241FBECFEFD8E0DEBFCDBF32 +:1000D00011E0A0E0B1E0E0EBF7E002C005900D9286 +:1000E000A230B107D9F711E0A2E0B1E001C01D9242 +:1000F000A431B107E1F710E0C4ECD0E004C02297CE +:10010000FE010E94D203C23CD107C9F70E949E01A2 +:100110000C94D6030C940000FC0110828FEF8183B5 +:100120000895EF92FF920F931F93CF93DF93EC010B +:100130009B0177FF03C020E030E005C0653B7105FF +:1001400014F024EB30E02983EA806B8170E06E19B3 +:100150007109882777FD8095982F982F872F762F04 +:10016000662730E040E050E00E944D0324EB30E091 +:1001700040E050E00E947F03FF2400E010E0102FD9 +:100180000F2DFE2CEE24E20EF31E041F151FC801D6 +:10019000B70128E030E040E050E00E947F03888112 +:1001A000893029F4309389002093880006C08A3072 +:1001B00021F430938B0020938A00DF91CF911F911F +:1001C0000F91FF90EF900895CF93DF93EC01FB0127 +:1001D000CB010997029710F080E054C0CA0160E19A +:1001E00070E00E946C036A83C90160E170E00E94C4 +:1001F0006C036B83E8838FEF89838E2F60E00E940E +:10020000B702888161E00E949702809102018823F1 +:1002100011F5809103018823F1F42FB7F89482E05F +:10022000809380008AE18093810088EB9BE090932B +:1002300089008093880090938B0080938A0080E4EB +:100240009CE9909387008093860080916F00887F5F +:1002500080936F002FBF8881893041F481E08093C3 +:100260000201809180008F73806809C08A3049F450 +:1002700081E080930301809180008F7C8062809375 +:10028000800081E0DF91CF91089540E252E020E6C6 +:1002900039E00E94E400089584E091E00E948C001F +:1002A0000895AF92BF92CF92DF92EF92FF920F9399 +:1002B0001F9381E00E94790200D000D0AA2797FD09 +:1002C000A095BA2F23EB30E040E050E0EDB7FEB749 +:1002D0002183328343835483BC01CD0120E030E08D +:1002E00040E050E0EFEFEE2EE3E0FE2E012D112D69 +:1002F000AA24BB2465010E9404039B01AC010F905A +:100300000F900F900F9084E091E0B9010E9491004E +:100310006FE070E080E090E00E9415021F910F9165 +:10032000FF90EF90DF90CF90BF90AF90089584E062 +:1003300091E06AE070E00E94450108950E943F024A +:100340000E9497010E945101FDCF1F920F920FB69C +:100350000F9211242F938F939F93AF93BF9380910C +:10036000080190910901A0910A01B0910B01019639 +:10037000A11DB11D8093080190930901A0930A016A +:10038000B0930B0180910C0190910D01A0910E0191 +:10039000B0910F018050904CAF4FBF4F80930C0134 +:1003A00090930D01A0930E01B0930F0127C080918F +:1003B0000C0190910D01A0910E01B0910F01805898 +:1003C0009E43A040B04080930C0190930D01A093F8 +:1003D0000E01B0930F018091100190911101A09135 +:1003E0001201B09113010196A11DB11D809310015E +:1003F00090931101A0931201B093130180910C010D +:1004000090910D01A0910E01B0910F0181589E4372 +:10041000A040B04060F6BF91AF919F918F912F9116 +:100420000F900FBE0F901F901895EF92FF920F93B1 +:100430001F937B018C018FB7F8944091100150916C +:10044000110160911201709113018FBF2FB7F894C1 +:100450008091100190911101A0911201B0911301AE +:100460002FBF841B950BA60BB70BE816F9060A07DE +:100470001B0760F71F910F91FF90EF9008957894FC +:1004800084B5826084BD84B5816084BD85B5826099 +:1004900085BD85B5816085BDEEE6F0E08081816037 +:1004A0008083E1E8F0E080818260808380818160E8 +:1004B0008083E0E8F0E0808181608083E1EBF0E020 +:1004C000808184608083E0EBF0E0808181608083C4 +:1004D000EAE7F0E0808184608083808182608083AD +:1004E0008081816080838081806880831092C100D8 +:1004F00008958770909100019295990F990F907CC3 +:10050000982B90937C0080917A00806480937A008D +:1005100080917A0086FDFCCF20917800409179008F +:10052000942F80E030E0282B392BC9010895282F23 +:1005300030E0C90186569F4FFC0194912A573F4FE6 +:10054000F9018491882391F0E82FF0E0EE0FFF1F6E +:10055000E859FF4FA591B491662329F48C919095A9 +:1005600089238C9308958C91892B8C930895482F1F +:1005700050E0CA0182559F4FFC012491CA01865662 +:100580009F4FFC0194914A575F4FFA0134913323F6 +:10059000D1F1222331F1233021F4809180008F7733 +:1005A00005C0243031F4809180008F7D80938000DD +:1005B00018C0213019F484B58F7704C0223021F49B +:1005C00084B58F7D84BD0DC0263021F48091B000AC +:1005D0008F7705C0273029F48091B0008F7D8093FC +:1005E000B000E32FF0E0EE0FFF1FEE58FF4FA59194 +:1005F000B491662329F48C91909589238C93089566 +:100600008C91892B8C9308952F923F924F925F92F9 +:100610006F927F928F929F92AF92BF92CF92DF9212 +:10062000EF92FF920F931F93DF93CF93CDB7DEB777 +:100630003B014C0119012A016D897E898F89988DB2 +:100640006A197B098C099D09621A730A840A950A42 +:10065000A40193010E944D03E218F308040915094F +:10066000A80197010E947F032A0D3B1D4C1D5D1DB3 +:10067000B901CA01CF91DF911F910F91FF90EF90C7 +:10068000DF90CF90BF90AF909F908F907F906F90B2 +:100690005F904F903F902F900895629FD001739F7D +:1006A000F001829FE00DF11D649FE00DF11D929F0E +:1006B000F00D839FF00D749FF00D659FF00D99274D +:1006C000729FB00DE11DF91F639FB00DE11DF91F71 +:1006D000BD01CF011124089597FB092E07260AD0EA +:1006E00077FD04D027D006D000201AF470956195CC +:1006F0007F4F0895F6F7909581959F4F089597FB4A +:10070000092E05260ED057FD04D028D00AD0001C93 +:1007100038F450954095309521953F4F4F4F5F4F9E +:100720000895F6F790958095709561957F4F8F4F5E +:100730009F4F0895AA1BBB1B51E107C0AA1FBB1FF7 +:10074000A617B70710F0A61BB70B881F991F5A955D +:10075000A9F780959095BC01CD010895A1E21A2ECC +:10076000AA1BBB1BFD010DC0AA1FBB1FEE1FFF1F55 +:10077000A217B307E407F50720F0A21BB30BE40BA5 +:10078000F50B661F771F881F991F1A9469F76095EC +:100790007095809590959B01AC01BD01CF010895A6 +:1007A000EE0FFF1F0590F491E02D0994F894FFCF10 +:0207B000010046 +:00000001FF diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.pde b/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.pde new file mode 100644 index 0000000..b4553af --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/Servo/applet/Servo.pde @@ -0,0 +1,21 @@ +#include + +Servo myservo9; // create servo object to control a servo +Servo myservo10; // create servo object to control a servo + +int pos = 0; // variable to store the servo position + +void setup() +{ + myservo9.attach(11); // attaches the servo on pin 9 to the servo object + myservo10.attach(10); // attaches the servo on pin 10 to the servo object +} + +void loop() +{ + int val = map(analogRead(1), 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) + myservo10.write(val); // sets the servo position according to the scaled value + delay(15); // waits for the servo to get there + +} + diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Componentes/Servo/applet/WInterrupts.c.o new file mode 100644 index 0000000..b74dfbb Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Componentes/Servo/applet/WMath.cpp.o new file mode 100644 index 0000000..4e4cf44 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/core.a b/arduino/all the sketchs of my life/Componentes/Servo/applet/core.a new file mode 100644 index 0000000..0cb3dcf Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Componentes/Servo/applet/pins_arduino.c.o new file mode 100644 index 0000000..c450af7 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring.c.o b/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring.c.o new file mode 100644 index 0000000..acbd542 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_analog.c.o new file mode 100644 index 0000000..b56797d Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_digital.c.o new file mode 100644 index 0000000..3928ccd Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_pulse.c.o new file mode 100644 index 0000000..525eda2 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_serial.c.o b/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_serial.c.o new file mode 100644 index 0000000..b8d4c17 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_serial.c.o differ diff --git a/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_shift.c.o new file mode 100644 index 0000000..8e0db5b Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/Servo/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Componentes/fita_led_vok/fita_led_vok.pde b/arduino/all the sketchs of my life/Componentes/fita_led_vok/fita_led_vok.pde new file mode 100644 index 0000000..67c60d9 --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/fita_led_vok/fita_led_vok.pde @@ -0,0 +1,34 @@ +void setup() { + pinMode(6,OUTPUT); //blue + pinMode(9,OUTPUT); //verde + pinMode(18,OUTPUT); //vermelho + +} + +void loop() { + for(int x=0;x<2;x++) { + digitalWrite(9, HIGH); + delay(200); + digitalWrite(9, LOW); + delay(200); + } + + for(int x=0;x<2;x++) { + for(int x=0;x<250;x++) { + analogWrite(9, x); + delay(10); + } + digitalWrite(18, HIGH); + delay(200); + for(int x=250;x>0;x--) { + analogWrite(9, x); + delay(10); + } + + digitalWrite(18, LOW); + delay(200); + } + +} + + diff --git a/arduino/all the sketchs of my life/Componentes/hrmi/__MACOSX/hrmi_demos/._.DS_Store b/arduino/all the sketchs of my life/Componentes/hrmi/__MACOSX/hrmi_demos/._.DS_Store new file mode 100644 index 0000000..460d887 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/hrmi/__MACOSX/hrmi_demos/._.DS_Store differ diff --git a/arduino/all the sketchs of my life/Componentes/hrmi/__MACOSX/hrmi_demos/._arduino_simple b/arduino/all the sketchs of my life/Componentes/hrmi/__MACOSX/hrmi_demos/._arduino_simple new file mode 100644 index 0000000..b34a552 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/hrmi/__MACOSX/hrmi_demos/._arduino_simple differ diff --git a/arduino/all the sketchs of my life/Componentes/hrmi/__MACOSX/hrmi_demos/arduino_simple/._.DS_Store b/arduino/all the sketchs of my life/Componentes/hrmi/__MACOSX/hrmi_demos/arduino_simple/._.DS_Store new file mode 100644 index 0000000..460d887 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/hrmi/__MACOSX/hrmi_demos/arduino_simple/._.DS_Store differ diff --git a/arduino/all the sketchs of my life/Componentes/hrmi/__MACOSX/hrmi_demos/arduino_simple/._hrmi_funcs.h b/arduino/all the sketchs of my life/Componentes/hrmi/__MACOSX/hrmi_demos/arduino_simple/._hrmi_funcs.h new file mode 100644 index 0000000..536879d Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/hrmi/__MACOSX/hrmi_demos/arduino_simple/._hrmi_funcs.h differ diff --git a/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/.DS_Store b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/.DS_Store new file mode 100644 index 0000000..2571483 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/.DS_Store differ diff --git a/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/arduino_simple/.DS_Store b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/arduino_simple/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/arduino_simple/.DS_Store differ diff --git a/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/arduino_simple/arduino_simple.pde b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/arduino_simple/arduino_simple.pde new file mode 100644 index 0000000..108c51b --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/arduino_simple/arduino_simple.pde @@ -0,0 +1,95 @@ +/* + * Simple Arduino-based program to read values from the HRMI using the I2C interface + * + * Connections + * Arduino HRMI + * ----------------------- + * +5 +5 (Power for the HRMI) + * GND GND + * Analog In 5 TX (I2C SCL) (recommend 4.7 kOhm pullup) + * Analog In 4 RX (I2C SDA) (recommend 4.7 kOhm pullup) + * + * + * Note: By default the Arduino Wiring library is limited to a maximum + * I2C read of 32 bytes. The Get Heartrate command is limited + * by this code to a maximum of 30 values (for a max I2C packet + * of 32 bytes). + * + */ + +#include "Wire.h" +#include "hrmi_funcs.h" + +/* + * Configuration Information + * + * Change these constants to match your specific configuration. These + * values are the factory default (no OP1-OP7 jumpers installed). Jumper + * OP0 should be installed and jumper SJ1 removed. + * + * HRMI_HOST_BAUDRATE should be set to the baudrate the host will use + * to communicate with the Arduino over the serial interface. + * + * HRMI_I2C_ADDR should be set to the I2C address the HRMI is configured + * with. + */ +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 + + +/* + * Program constants + */ +#define MAX_IN_BUFFSIZE 16 + + +/* + * Global variables + */ +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use + + +/* + * Arduino initialization code segment + */ +void setup() +{ + // Initialize the I2C communication + hrmi_open(); + + // Initialize the serial interface + Serial.begin(HRMI_HOST_BAUDRATE); +} + + +/* + * Arduino main code loop + */ +void loop() +{ + // Request a set of heart rate values + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + + // Get the response from the HRMI + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + // send the results back on the serial interface in ASCII form + Serial.print("Request "); Serial.print(numEntries); Serial.print(" => "); + for (int i=0; i 30) + numEntries = 0; + delay(1000); // Delay 1 second between commands +} + + diff --git a/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/arduino_simple/hrmi_funcs.cpp b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/arduino_simple/hrmi_funcs.cpp new file mode 100644 index 0000000..3fae9aa --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/arduino_simple/hrmi_funcs.cpp @@ -0,0 +1,60 @@ +/* + * hrmi_funcs.cpp + * + * Arduino library to communicate with a HRMI using I2C + * + * Written by Dan Julio, www.danjuliodesigns.com + * Version 1.1, 12/28/2008 + * + */ + + #include + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.send(cmd); + Wire.send(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.send(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/hrmi_simple/data/CourierNew36.vlw b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/hrmi_simple/data/CourierNew36.vlw new file mode 100644 index 0000000..9047714 Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/hrmi_simple/data/CourierNew36.vlw differ diff --git a/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/hrmi_simple/data/Ziggurat-HTF-Black-32.vlw b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/hrmi_simple/data/Ziggurat-HTF-Black-32.vlw new file mode 100644 index 0000000..84c2d4b Binary files /dev/null and b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/hrmi_simple/data/Ziggurat-HTF-Black-32.vlw differ diff --git a/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/hrmi_simple/hrmi_simple.pde b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/hrmi_simple/hrmi_simple.pde new file mode 100644 index 0000000..0ab8bd1 --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/hrmi_simple/hrmi_simple.pde @@ -0,0 +1,72 @@ +// +// Demonstration program for communicating with the HRMI over a serial interface +// + + +// Include the serial library +import processing.serial.*; + +// Variable declaration +Serial port; // The serial port +byte[] rspCharArray = new byte[32]; // Where we'll put the raw data read from the HRMI device +int[] rspArgArray = new int[3]; // Where we'll put the converted response values +int validData = 0; +int CR = 13; // constant + +void setup() { + // Open a specific serial device (this will change for each HRMI device) + port = new Serial(this, "/dev/tty.usbserial-A9003PDh", 9600); + + // Setup the serialEvent to be called when we receive complete response + // packets from the HRMI device + port.bufferUntil(CR); + +} + +void draw() { + + // Send a command to get a single heart rate value + validData = 0; + port.write('G'); + port.write('1'); + port.write(CR); + + // Wait for a response from the HRMI device + while (validData == 0) { + delay(1000); // Delay 1 second between checks + } + + // Display mode, count and heartrate + if ((rspArgArray[0] & 0x01) == 0x01) + print("Averaged mode "); + else + print("Raw mode "); + print(rspArgArray[1]); print(" "); // Count + println(rspArgArray[2]); // Heart rate +} + +// Catch the event from the serial interface. Make sure there is +// actually data to read before attempting to do any processing. +void serialEvent(Serial port) { + if (port.readBytesUntil(CR, rspCharArray) != 0) { + // Read bytes until we get to the end of the packet converting + // each ASCII digit into a number. We make use of the space + // character between sets of digits to delimit numbers. + // Argument 0: Status Flags + // Argument 1: Second Count + // Argument 2: Heartrate + // + int ArgIndex = 0; + int CharIndex = 0; + for (int i=0; i<3; i++) rspArgArray[i] = 0; + while (rspCharArray[CharIndex] != CR) { + if (rspCharArray[CharIndex] != ((byte) ' ')) { + rspArgArray[ArgIndex] = (rspArgArray[ArgIndex]*10) + (rspCharArray[CharIndex] - ((byte) '0')); + } else { + ArgIndex++; + } + CharIndex++; + } + validData = 1; + } +} diff --git a/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/unix_simple.c b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/unix_simple.c new file mode 100644 index 0000000..d6bec66 --- /dev/null +++ b/arduino/all the sketchs of my life/Componentes/hrmi/hrmi_demos/unix_simple.c @@ -0,0 +1,185 @@ +/* + * Demonstration program for communicating with the HRMI over a serial interface + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +// Define a constant specifying the largest response string we could get from the HRMI +#define MAX_RSP_CHARS 140 + + +// Global to hold original serial port attributes +static struct termios gOriginalTTYAttrs; + + +// +// OpenSerialPort: Routine to open and configure the serial prot +// +static int OpenSerialPort(const char *deviceFilePath) +{ + // variables + int fd = -1; // file descriptor for serial port + struct termios options; // serial port configuration options + + // Open the serial port + if ((fd = open(deviceFilePath, O_RDWR | O_NOCTTY )) == -1) { + printf("Error opening serial port %s - %s(%d)\n", + deviceFilePath, strerror(errno), errno); + return(-1); + } + + // Prevent other processes from opening the serial port + if (ioctl(fd, TIOCEXCL) == -1) { + printf("Error setting TIOCEXCL on %s - %s(%d)\n", + deviceFilePath, strerror(errno), errno); + return(-1); + } + + // Get the serial port current options and save them to restore on exit + if (tcgetattr(fd, &gOriginalTTYAttrs) == -1) { + printf("Error getting tty attributes %s - %s(%d)\n", + deviceFilePath, strerror(errno), errno); + return(-1); + } + + // Configure the serial port + options = gOriginalTTYAttrs; + // Set raw input (non-canonical) mode, with reads blocking until either a + // single character has been received or a one second timeout expires + cfmakeraw(&options); + options.c_cc[VMIN] = 1; + options.c_cc[VTIME] = 10; + // Set the baud rate and word length + cfsetspeed(&options, B9600); + options.c_cflag |= (CS8); + // Cause the new options to take effect immediately + if (tcsetattr(fd, TCSANOW, &options) == -1) { + printf("Error setting tty attributes!\n"); + return(-1); + } + + return(fd); +} + + + +// +// CloseSerialPort: Close our connection and restore the original settings +// +void CloseSerialPort(int fd) +{ + // Block until all written output has been sent from the device + if (tcdrain(fd) == -1) { + printf("Error waiting for drain - %s(%d)\n", strerror(errno), errno); + } + + // Reset the serial port back to the state in which we found it + if (tcsetattr(fd, TCSANOW, &gOriginalTTYAttrs) == -1) { + printf("Error restoring tty attributes - %s(%d)\n", strerror(errno), errno); + } + + // Close the port + close(fd); +} + + + +// +// SendGetHeartRate: Function to send a command to get the number of heart rate values +// specified in NumEntries +// +// Returns 1 for success, 0 for failure +// +int SendGetHeartRate(int fd, int NumEntries) +{ + char SendCommand[8]; // Array sized to hold the largest command string + int CmdLength; // Number of characters in the command string + + // Validate NumEntries + if (NumEntries < 0) + NumEntries = 0; + else if (NumEntries > 32) + NumEntries = 32; + + // Build the command string + // Note: "\015" is the carriage return character + CmdLength = sprintf(SendCommand, "G%0d\015", NumEntries); + + // Send the command string + return(write(fd, SendCommand, CmdLength) == CmdLength); +} + + + +// +// GetResponseString: Function to read a response string back from the HRMI +// +int GetResponseString(int fd, char* ResponseString) +{ + char b[2]; + int i = 0; + + do { + int n = read(fd, b, 1); // read a char at a time + if (n == -1) + return(-1); // read failed + if (n == 0) { + usleep(10 * 1000); // wait 10 msec before trying again + continue; + } + + ResponseString[i] = b[0]; // store the character + i++; + + // repeat until we see the character or exceed the buffer + } while ((b[0] != 0x0D) && (i < MAX_RSP_CHARS)); + + ResponseString[i-1] = 0; // null terminate the string (replace the ) + return(0); +} + + + +int main() +{ + int sfd; // serial port file descriptor + int i = 0; // loop counter + char RspBytes[MAX_RSP_CHARS]; // Response string + int numBytes; + + // Open the serial port device associated with the HRMI + if ((sfd = OpenSerialPort("/dev/cu.usbserial-A9003PDh")) == -1) { + return(-1); + } + + // Send a series of Get Heart Rate commands, each time requesting more history buffer + // entries + while (i++ < 33) { + if (SendGetHeartRate(sfd, i) == 0) { + printf("Error: SendGetHeartRate failed!\n"); + break; + } + + if (GetResponseString(sfd, RspBytes) == -1) { + printf("Error: GetResponseString failed!\n"); + break; + } else { + printf("Request %2d => %s\n", i, RspBytes); + } + + sleep(1); + } + + CloseSerialPort(sfd); +} diff --git a/arduino/all the sketchs of my life/DemoLuzDistanciaJJ/DemoLuzDistanciaJJ.pde b/arduino/all the sketchs of my life/DemoLuzDistanciaJJ/DemoLuzDistanciaJJ.pde new file mode 100644 index 0000000..6f61fb1 --- /dev/null +++ b/arduino/all the sketchs of my life/DemoLuzDistanciaJJ/DemoLuzDistanciaJJ.pde @@ -0,0 +1,17 @@ +void setup() { + Serial.begin(9600); +} + +void loop() { + int luz = analogRead(3); + if(luz>700) { + Serial.println("apagada"); + } + else { + Serial.println("acesa"); + } + delay(500); +} + + + diff --git a/arduino/all the sketchs of my life/DevBot/DevBot_Aranha/DevBot_Aranha.ino b/arduino/all the sketchs of my life/DevBot/DevBot_Aranha/DevBot_Aranha.ino new file mode 100644 index 0000000..dfbe39d --- /dev/null +++ b/arduino/all the sketchs of my life/DevBot/DevBot_Aranha/DevBot_Aranha.ino @@ -0,0 +1,72 @@ +#include "DevBot.h" +#include + +void setup() +{ + robot.configurar(programME_v2); + robot.configurar(bateria_7_volts); + robot.configurar(motor_6_volts); + robot.motores.independente=2; + //robot.configurar(servo_comum); + //robot.configurar(sensor_distancia_parallax); + robot.iniciar(); + + robot.modo(0, comunicacaoPC); + robot.modo(1, sensores); + robot.modo(2, medoDoEscuro); + robot.modo(3, desviar); +} + +void loop() +{ + robot.loop(); +} + +void comunicacaoPC() +{ + robot.controleRemoto(); +} +void sensores() +{ + robot.enviar("Idle - Parado"); + robot.enviar("Luz"); + robot.enviar(robot.sensorLuz()); + robot.enviar("Temperatura"); + robot.enviar(robot.sensorTemperatura()); + robot.enviar("Distancia"); + robot.enviar(robot.sensorDistancia1()); + robot.esperar(500); +} + +void teste() { + robot.mudarServo(90); + robot.enviar("Frente"); + robot.motores.frente(4); + robot.esperar(1000); + robot.motores.parar(); + robot.esperar(1000); + + robot.mudarServo(0); + robot.enviar("Girar"); + robot.motores.girar(4,0); + robot.esperar(300); + robot.motores.parar(); + robot.esperar(1000); + + robot.mudarServo(178); + robot.enviar("Re"); + robot.motores.re(4); + robot.esperar(1000); + robot.motores.parar(); + robot.esperar(1000); + + robot.enviar("Girar"); + robot.motores.girar(4,1); + robot.esperar(300); + robot.motores.parar(); + robot.esperar(5000); + +} + + + diff --git a/arduino/all the sketchs of my life/DevBot/DevBot_Aranha/desviar.ino b/arduino/all the sketchs of my life/DevBot/DevBot_Aranha/desviar.ino new file mode 100644 index 0000000..1588585 --- /dev/null +++ b/arduino/all the sketchs of my life/DevBot/DevBot_Aranha/desviar.ino @@ -0,0 +1,13 @@ +int distancia; +void desviar() { + robot.mudarServo(93); + distancia = robot.sensorDistancia1(); + if(distancia<10) { + robot.motores.girar(4); + robot.esperar(500); + robot.motores.movimentoAleatorio(4); + robot.esperar(500); + } + robot.motores.frente(4); +} + diff --git a/arduino/all the sketchs of my life/DevBot/DevBot_Aranha/medoDoEscuro.ino b/arduino/all the sketchs of my life/DevBot/DevBot_Aranha/medoDoEscuro.ino new file mode 100644 index 0000000..ca07d8f --- /dev/null +++ b/arduino/all the sketchs of my life/DevBot/DevBot_Aranha/medoDoEscuro.ino @@ -0,0 +1,31 @@ +int escuridao = 800; //quanto menor o numero, maior a iluminacao do ambiente. +int luzAtual; + +boolean estaClaro() { + return luzAtual + +MeetAndroid meetAndroid; + +int modoAndroid=1; + +void android() { + meetAndroid.registerFunction(androidSensorProximidade, 'A'); + meetAndroid.registerFunction(androidAcelerometro, 'C'); + meetAndroid.registerFunction(androidBussola, 'B'); + meetAndroid.registerFunction(androidMudarModo, 'M'); + + while(!robot.mudouModo()) { + meetAndroid.receive(); + //delay(50); + } +} +void androidMudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modoAndroid = atoi(c); + //if(modoAndroid<0 || modoAndroid>5) modoAndroid=1; +} + +void androidAcelerometro(byte flag, byte numOfValues) { + float acelerometro[3]; + meetAndroid.getFloatValues(acelerometro); + if(modoAndroid==1) { + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + robot.motores.re(map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + robot.motores.frente(map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + robot.motores.parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + robot.motores.girar(map(acelerometro[0],-3,-10,1,5),0); + } + else { + robot.motores.esquerda(3); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + robot.motores.girar(map(acelerometro[0],-3,-10,1,5),1); + } + else { + robot.motores.direita(3); + } + } + } +} + + +void androidSensorProximidade(byte flag, byte numOfValues) { + int state = meetAndroid.getInt(); + if(modoAndroid!=3) return; + + if(state==0) { + for(int x=0;x<3;x++) { + robot.motores.girar(4,0); + delay(250); + robot.motores.girar(4,1); + delay(250); + robot.motores.girar(4,0); + delay(250); + robot.motores.girar(4,1); + delay(250); + + robot.motores.parar(); + } + } +} + +void androidBussola(byte flag, byte numOfValues) { + int bussola = meetAndroid.getInt(); + if(modoAndroid!=2) return; + if(bussola>350 && bussola<360) { + robot.motores.girar(3,1); + delay(80); + robot.motores.parar(); + } + else if(bussola>180 && bussola<350) { + robot.motores.girar(3,1); + delay(200); + robot.motores.parar(); + } + else if(bussola>15 && bussola<180) { + robot.motores.girar(3,0); + delay(200); + robot.motores.parar(); + } + else if(bussola>3 && bussola<15) { + robot.motores.girar(3,0); + delay(80); + robot.motores.parar(); + } + else if(bussola>0 && bussola<3) { + robot.motores.parar(); + } +} + + + diff --git a/arduino/all the sketchs of my life/DevBot/DevBot_first/medoDoEscuro.ino b/arduino/all the sketchs of my life/DevBot/DevBot_first/medoDoEscuro.ino new file mode 100644 index 0000000..b07ea72 --- /dev/null +++ b/arduino/all the sketchs of my life/DevBot/DevBot_first/medoDoEscuro.ino @@ -0,0 +1,31 @@ +int escuridao = 700; //quanto menor o numero, maior a iluminacao do ambiente. +int luzAtual; + +boolean estaClaro() { + return luzAtual + +void setup() +{ + robot.configurar(programME_v2); + robot.configurar(bateria_7_volts); + robot.configurar(motor_6_volts); + robot.configurar(servo_comum); + robot.configurar(sensor_distancia_parallax); + robot.portas.red=10; + robot.portas.green=5; + robot.portas.blue=9; + + robot.iniciar(); + + robot.modo(0, comunicacaoPC); + robot.modo(1, sensores); + robot.modo(2, medoDoEscuro); + robot.modo(3, desviar); +} + +void loop() +{ + robot.loop(); +} + +void comunicacaoPC() +{ + robot.controleRemoto(); +} +void sensores() +{ + robot.enviar("Idle - Parado"); + robot.enviar("Luz"); + robot.enviar(robot.sensorLuz()); + robot.enviar("Temperatura"); + robot.enviar(robot.sensorTemperatura()); + robot.enviar("Distancia 1"); + robot.enviar(robot.sensorDistancia(1)); + robot.enviar("Distancia 2"); + robot.enviar(robot.sensorDistancia(2)); + + robot.esperar(500); +} + +void teste() { + robot.mudarServo(90); + robot.enviar("Frente"); + robot.motores.frente(4); + robot.esperar(1000); + robot.motores.parar(); + robot.esperar(1000); + + robot.mudarServo(0); + robot.enviar("Girar"); + robot.motores.girar(4,0); + robot.esperar(300); + robot.motores.parar(); + robot.esperar(1000); + + robot.mudarServo(178); + robot.enviar("Re"); + robot.motores.re(4); + robot.esperar(1000); + robot.motores.parar(); + robot.esperar(1000); + + robot.enviar("Girar"); + robot.motores.girar(4,1); + robot.esperar(300); + robot.motores.parar(); + robot.esperar(5000); + +} + + + diff --git a/arduino/all the sketchs of my life/DevBot/DevBot_first_Servo/desviar.ino b/arduino/all the sketchs of my life/DevBot/DevBot_first_Servo/desviar.ino new file mode 100644 index 0000000..09459cd --- /dev/null +++ b/arduino/all the sketchs of my life/DevBot/DevBot_first_Servo/desviar.ino @@ -0,0 +1,16 @@ +int distancia; +void desviar() { + robot.mudarServo(90); + distancia = robot.sensorDistancia1(); + if(distancia<10) { + robot.motores.girar(4); + robot.esperar(500); + robot.motores.movimentoAleatorio(4); + robot.esperar(500); + } + robot.motores.frente(4); + + + +} + diff --git a/arduino/all the sketchs of my life/DevBot/DevBot_first_Servo/medoDoEscuro.ino b/arduino/all the sketchs of my life/DevBot/DevBot_first_Servo/medoDoEscuro.ino new file mode 100644 index 0000000..ca07d8f --- /dev/null +++ b/arduino/all the sketchs of my life/DevBot/DevBot_first_Servo/medoDoEscuro.ino @@ -0,0 +1,31 @@ +int escuridao = 800; //quanto menor o numero, maior a iluminacao do ambiente. +int luzAtual; + +boolean estaClaro() { + return luzAtual + +void setup() +{ + robot.configurar(bateria_7_volts); + robot.configurar(motor_6_volts); + robot.configurar(programME_v2); + robot.configurar(servo_comum); + robot.configurar(sensor_distancia_parallax); + + robot.iniciar(); + robot.modo(0, comunicacaoPC); + robot.modo(1, sensores); + robot.modo(2, medoDoEscuro); + robot.modo(3, desviar); +} + +void loop() +{ + robot.loop(); +} + +void comunicacaoPC() +{ + robot.controleRemoto(); +} +void sensores() +{ + robot.enviar("Idle - Parado"); + robot.enviar("Luz"); + robot.enviar(robot.sensorLuz()); + robot.enviar("Temperatura"); + robot.enviar(robot.sensorTemperatura()); + robot.enviar("Distancia"); + robot.enviar(robot.sensorDistancia1()); + robot.esperar(500); +} + +void teste() { + robot.mudarServo(90); + robot.enviar("Frente"); + robot.motores.frente(4); + robot.esperar(1000); + robot.motores.parar(); + robot.esperar(1000); + + robot.mudarServo(0); + robot.enviar("Girar"); + robot.motores.girar(4,0); + robot.esperar(300); + robot.motores.parar(); + robot.esperar(1000); + + robot.mudarServo(178); + robot.enviar("Re"); + robot.motores.re(4); + robot.esperar(1000); + robot.motores.parar(); + robot.esperar(1000); + + robot.enviar("Girar"); + robot.motores.girar(4,1); + robot.esperar(300); + robot.motores.parar(); + robot.esperar(5000); + +} + + + diff --git a/arduino/all the sketchs of my life/DevBot/DevBot_first_sonar/desviar.ino b/arduino/all the sketchs of my life/DevBot/DevBot_first_sonar/desviar.ino new file mode 100644 index 0000000..ff3b8ba --- /dev/null +++ b/arduino/all the sketchs of my life/DevBot/DevBot_first_sonar/desviar.ino @@ -0,0 +1,16 @@ +int distancia; +void desviar() { + distancia = robot.sensorDistancia1(); + //esta claro + /*while(estaClaro()) { + robot.motores.frente(4); + robot.esperar(100); + if(robot.mudouModo()) return; //metodo de libertacao do while se o robo mudar de modo + luzAtual = robot.sensorLuz(); + }*/ + robot.motores.girar(4); + robot.esperar(500); + robot.motores.movimentoAleatorio(4); + robot.esperar(500); +} + diff --git a/arduino/all the sketchs of my life/DevBot/DevBot_first_sonar/medoDoEscuro.ino b/arduino/all the sketchs of my life/DevBot/DevBot_first_sonar/medoDoEscuro.ino new file mode 100644 index 0000000..ca07d8f --- /dev/null +++ b/arduino/all the sketchs of my life/DevBot/DevBot_first_sonar/medoDoEscuro.ino @@ -0,0 +1,31 @@ +int escuridao = 800; //quanto menor o numero, maior a iluminacao do ambiente. +int luzAtual; + +boolean estaClaro() { + return luzAtual-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarTraz(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarFrente(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + +} + + + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=ANDAR) return; + + if(comando[0]=='F') { + //dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + //dance(); + } +} + +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=DEDO_DURO) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + //testeLeds(); + } + } +} + +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=ENCONTRAR_NORTE) return; + //if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + //else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + + diff --git a/arduino/all the sketchs of my life/DevBot/Devbot_Android_teste/Devbot_Android_teste.ino b/arduino/all the sketchs of my life/DevBot/Devbot_Android_teste/Devbot_Android_teste.ino new file mode 100644 index 0000000..e38d3ef --- /dev/null +++ b/arduino/all the sketchs of my life/DevBot/Devbot_Android_teste/Devbot_Android_teste.ino @@ -0,0 +1,74 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +boolean DEBUG_LIGADO = false; + +int modo=1; +boolean calibrado = false; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; + +Servo servoV; +Servo servoH; + +#define IDLE 0 +#define DEDO_DURO 1 +#define ENCONTRAR_NORTE 2 +#define ANDAR 3 +#define ACELEROMETRO 4 +#define SEGUIR_LINHA 5 + +void setup(){ + setupMotor(); + delay(500); + Serial.begin(115200); + //meetAndroid.setSerial(&Serial); + meetAndroid.registerFunction(dedoDuro, 'A'); + meetAndroid.registerFunction(encontraNorte, 'B'); + meetAndroid.registerFunction(acelera, 'C'); + meetAndroid.registerFunction(mudarModo, 'M'); + meetAndroid.registerFunction(andar, 'W'); + modo=IDLE; +} + +void loop(){ + meetAndroid.receive(); + delay(50); + //if(modo==SEGUIR_LINHA) seguirLinha2(); + if(modo==IDLE) modoZero(); + +} +int direita; +int centro; +int esquerda; + + + + +void modoZero() { + digitalWrite(13, HIGH); + delay(1000); + digitalWrite(13, LOW); + delay(1000); +} + +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + calibrado = false; //para recalibrar quando ligar seguidor de linha novamente +} + + diff --git a/arduino/all the sketchs of my life/DevBot/Devbot_Android_teste/Motores.ino b/arduino/all the sketchs of my life/DevBot/Devbot_Android_teste/Motores.ino new file mode 100644 index 0000000..30330d3 --- /dev/null +++ b/arduino/all the sketchs of my life/DevBot/Devbot_Android_teste/Motores.ino @@ -0,0 +1,95 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + + +int sentido=0; +void setupMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/Dimmer_JL_Final.pde b/arduino/all the sketchs of my life/Dimmer_JL_Final.pde new file mode 100644 index 0000000..5075b90 --- /dev/null +++ b/arduino/all the sketchs of my life/Dimmer_JL_Final.pde @@ -0,0 +1,129 @@ +#include +#include +//define portas associadas ao display 7seg +//int displaySeg[] = {a, b, c, d, e, f, g, pd}; +int displaySeg[] = {6, 9, 17, 15, 14, 5, 18, 12}; +//int displayPorts[] = {Anodo1, Anodo2, Anodo3}; +int displayPort[] = {7, 4, 3}; + +// define padroes do display 7SEG, de 0 - 9 e apagado +// 1 = segmento apagado, 0 = segmento aceso +byte seven_seg_digits[11][8] = { + { 0,0,0,0,0,0,1,1 }, // = 0 + { 1,0,0,1,1,1,1,1 }, // = 1 + { 0,0,1,0,0,1,0,1 }, // = 2 + { 0,0,0,0,1,1,0,1 }, // = 3 + { 1,0,0,1,1,0,0,1 }, // = 4 + { 0,1,0,0,1,0,0,1 }, // = 5 + { 0,1,0,0,0,0,0,1 }, // = 6 + { 0,0,0,1,1,1,1,1 }, // = 7 + { 0,0,0,0,0,0,0,1 }, // = 8 + { 0,0,0,1,1,0,0,1 }, // = 9 + { 1,1,1,1,1,1,1,1 } // = blank +}; + +int sensorDistancia = 2; // porta associada ao sensor distancia IR +int triacGatePin = 10 ; // porta associada ao gate do TRIAC + +int distancia = 0 ; // variavel para armazenar distancia +int power= 0 ; //inicializa variavel que controla potencia na lampada com 0 (lampada apagada) +int centena = 10 ; // armazena informacao a ser apresentada no display de centena (inicializa com 10 = apagado) +int dezena = 10 ; // armazena informacao a ser apresentada no display de dezena (inicializa com 10 = apagado) +int unidade = 10 ; // armazena informacao a ser apresentada no display de unidade (inicializa com 10 = apagado) + +void setup() { + Serial.begin(19200); + pinMode(triacGatePin, OUTPUT); + for (int i=0 ; i<=3 ; i++) { + pinMode(displayPort[i], OUTPUT); + } + for (int j=0 ; j<=7 ; j++) { + pinMode(displaySeg[j], OUTPUT); + } + attachInterrupt(0, zeroCrossInterrupt, CHANGE); //associa interrupcao INT0 com funcao "zeroCrossInterrupt" + + MsTimer2::set(200, leSensor); // inicializa Timer2 com 200 milisegundos (tempo entre leituras do sensor de dintancia) + MsTimer2::start(); // start do timer2 +} + +void loop() { + atualizaDisplay(unidade, dezena, centena); // atualiza informacoes nos displays de 7 segmentos +//* + //verifica se veio comando remoto pela serial + if (Serial.available() > 0) { + power = Serial.read(); + Serial.print(power, BYTE); + } + //finaliza aqui a verificacao de dados na serial + +} + +void atualizaDisplay(int uni, int dez, int cen) { + for (int k = 0; k < 8; ++k) { + digitalWrite(displaySeg[k], seven_seg_digits[uni][k]); + } + digitalWrite(displayPort[2], HIGH); + delay (1); + digitalWrite(displayPort[2], LOW); + + for (int k = 0; k < 8; ++k) { + digitalWrite(displaySeg[k], seven_seg_digits[dez][k]); + } + digitalWrite(displayPort[1], HIGH); + delay (1); + digitalWrite(displayPort[1], LOW); + + for (int k = 0; k < 8; ++k) { + digitalWrite(displaySeg[k], seven_seg_digits[cen][k]); + } + digitalWrite(displayPort[0], HIGH); + delay (1); + digitalWrite(displayPort[0], LOW); + +} + +void zeroCrossInterrupt(){ // trata interrupcao INT0 + if(power > 0) { + long dimtime = int(map(power,0,100,8000,150)); // calcula o tempo de delay para o disparo do TRIAC + Timer1.initialize (dimtime); // inicializa o TIMER1 com o delay calculado + Timer1.attachInterrupt(gateTRIAC); //associa a funcao gateTRIAC com Interrupcao do TIMER1 + Timer1.start(); // inicia contagem TIMER1 + } else { + digitalWrite(triacGatePin, LOW); // mantem gate do TRIAC desativado. + Timer1.stop(); + } +} + +void gateTRIAC () { // trata interrupcao do TIMER1 gerando pulso no gate do TRIAC + digitalWrite(triacGatePin, HIGH); // dispara o Triac + delayMicroseconds(15); // aguarda 15 microsegundos para garantir disparo do TRIAC + digitalWrite(triacGatePin, LOW); // desabibilta gate do TRIAC + Timer1.stop(); +} + +void leSensor() { + distancia = analogRead(sensorDistancia); // le sensor de distancia + //Serial.println(distancia); + distancia = map(distancia,70,600,120,0); // mapeia distancia lida para uma faixa de potencia entre 0 e 120 + if (distancia < 0) { + distancia = 0; + } + + if (distancia >=0 && distancia <= 100) { // se distancia <= a 100 atualiza potencia + power=distancia; + } + + + + centena = int(power / 100); // atualiza variaveis que contem informacoes dos displays + dezena = int((power - (centena*100)) / 10); + unidade = int(power - (centena*100)-(dezena*10)); + if (centena == 0 && dezena == 0){ + centena = 10; + dezena = 10; + } + if (centena == 0){ + centena = 10; + } +} + diff --git a/arduino/all the sketchs of my life/Dimmer_JL_Final/Dimmer_JL_Final.pde b/arduino/all the sketchs of my life/Dimmer_JL_Final/Dimmer_JL_Final.pde new file mode 100644 index 0000000..5075b90 --- /dev/null +++ b/arduino/all the sketchs of my life/Dimmer_JL_Final/Dimmer_JL_Final.pde @@ -0,0 +1,129 @@ +#include +#include +//define portas associadas ao display 7seg +//int displaySeg[] = {a, b, c, d, e, f, g, pd}; +int displaySeg[] = {6, 9, 17, 15, 14, 5, 18, 12}; +//int displayPorts[] = {Anodo1, Anodo2, Anodo3}; +int displayPort[] = {7, 4, 3}; + +// define padroes do display 7SEG, de 0 - 9 e apagado +// 1 = segmento apagado, 0 = segmento aceso +byte seven_seg_digits[11][8] = { + { 0,0,0,0,0,0,1,1 }, // = 0 + { 1,0,0,1,1,1,1,1 }, // = 1 + { 0,0,1,0,0,1,0,1 }, // = 2 + { 0,0,0,0,1,1,0,1 }, // = 3 + { 1,0,0,1,1,0,0,1 }, // = 4 + { 0,1,0,0,1,0,0,1 }, // = 5 + { 0,1,0,0,0,0,0,1 }, // = 6 + { 0,0,0,1,1,1,1,1 }, // = 7 + { 0,0,0,0,0,0,0,1 }, // = 8 + { 0,0,0,1,1,0,0,1 }, // = 9 + { 1,1,1,1,1,1,1,1 } // = blank +}; + +int sensorDistancia = 2; // porta associada ao sensor distancia IR +int triacGatePin = 10 ; // porta associada ao gate do TRIAC + +int distancia = 0 ; // variavel para armazenar distancia +int power= 0 ; //inicializa variavel que controla potencia na lampada com 0 (lampada apagada) +int centena = 10 ; // armazena informacao a ser apresentada no display de centena (inicializa com 10 = apagado) +int dezena = 10 ; // armazena informacao a ser apresentada no display de dezena (inicializa com 10 = apagado) +int unidade = 10 ; // armazena informacao a ser apresentada no display de unidade (inicializa com 10 = apagado) + +void setup() { + Serial.begin(19200); + pinMode(triacGatePin, OUTPUT); + for (int i=0 ; i<=3 ; i++) { + pinMode(displayPort[i], OUTPUT); + } + for (int j=0 ; j<=7 ; j++) { + pinMode(displaySeg[j], OUTPUT); + } + attachInterrupt(0, zeroCrossInterrupt, CHANGE); //associa interrupcao INT0 com funcao "zeroCrossInterrupt" + + MsTimer2::set(200, leSensor); // inicializa Timer2 com 200 milisegundos (tempo entre leituras do sensor de dintancia) + MsTimer2::start(); // start do timer2 +} + +void loop() { + atualizaDisplay(unidade, dezena, centena); // atualiza informacoes nos displays de 7 segmentos +//* + //verifica se veio comando remoto pela serial + if (Serial.available() > 0) { + power = Serial.read(); + Serial.print(power, BYTE); + } + //finaliza aqui a verificacao de dados na serial + +} + +void atualizaDisplay(int uni, int dez, int cen) { + for (int k = 0; k < 8; ++k) { + digitalWrite(displaySeg[k], seven_seg_digits[uni][k]); + } + digitalWrite(displayPort[2], HIGH); + delay (1); + digitalWrite(displayPort[2], LOW); + + for (int k = 0; k < 8; ++k) { + digitalWrite(displaySeg[k], seven_seg_digits[dez][k]); + } + digitalWrite(displayPort[1], HIGH); + delay (1); + digitalWrite(displayPort[1], LOW); + + for (int k = 0; k < 8; ++k) { + digitalWrite(displaySeg[k], seven_seg_digits[cen][k]); + } + digitalWrite(displayPort[0], HIGH); + delay (1); + digitalWrite(displayPort[0], LOW); + +} + +void zeroCrossInterrupt(){ // trata interrupcao INT0 + if(power > 0) { + long dimtime = int(map(power,0,100,8000,150)); // calcula o tempo de delay para o disparo do TRIAC + Timer1.initialize (dimtime); // inicializa o TIMER1 com o delay calculado + Timer1.attachInterrupt(gateTRIAC); //associa a funcao gateTRIAC com Interrupcao do TIMER1 + Timer1.start(); // inicia contagem TIMER1 + } else { + digitalWrite(triacGatePin, LOW); // mantem gate do TRIAC desativado. + Timer1.stop(); + } +} + +void gateTRIAC () { // trata interrupcao do TIMER1 gerando pulso no gate do TRIAC + digitalWrite(triacGatePin, HIGH); // dispara o Triac + delayMicroseconds(15); // aguarda 15 microsegundos para garantir disparo do TRIAC + digitalWrite(triacGatePin, LOW); // desabibilta gate do TRIAC + Timer1.stop(); +} + +void leSensor() { + distancia = analogRead(sensorDistancia); // le sensor de distancia + //Serial.println(distancia); + distancia = map(distancia,70,600,120,0); // mapeia distancia lida para uma faixa de potencia entre 0 e 120 + if (distancia < 0) { + distancia = 0; + } + + if (distancia >=0 && distancia <= 100) { // se distancia <= a 100 atualiza potencia + power=distancia; + } + + + + centena = int(power / 100); // atualiza variaveis que contem informacoes dos displays + dezena = int((power - (centena*100)) / 10); + unidade = int(power - (centena*100)-(dezena*10)); + if (centena == 0 && dezena == 0){ + centena = 10; + dezena = 10; + } + if (centena == 0){ + centena = 10; + } +} + diff --git a/arduino/all the sketchs of my life/Diversos/dojo_go/dojo_go.pde b/arduino/all the sketchs of my life/Diversos/dojo_go/dojo_go.pde new file mode 100644 index 0000000..601d300 --- /dev/null +++ b/arduino/all the sketchs of my life/Diversos/dojo_go/dojo_go.pde @@ -0,0 +1,134 @@ +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define DISTANCIA 1 +int sentido; +/* + + Duplas: + - Reinaldo e Fernando + - Marcelo e Bruno + - Fred e Natany + - Felipe e Andressa + - Fernando e Tiago +*/ + +int girar = 0; +int andar = 0; // ciclos andando pra frente +int ultimoGirar = 0; + +void setup() { + Serial.begin(9600); + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + servo +} +int lerDistancia() { + return analogRead(DISTANCIA); + //define preferencia direita +} +void loop() { + //vai para frente ate distancia 40 + if(lerDistancia()>30){ + andarFrente(1000,2); + } else{ + if(ultimoGirar == 0){ + while(lerDistancia()<30){ + girarNoEixo(100,2,1); + } + ultimoGirar = 1; + } else{ + while(lerDistancia()<30){ + girarNoEixo(100,2,0); + } + ultimoGirar = 0; + } + } + +} + + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarTraz(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarFrente(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + diff --git a/arduino/all the sketchs of my life/Diversos/dojo_ms/dojo_ms.pde b/arduino/all the sketchs of my life/Diversos/dojo_ms/dojo_ms.pde new file mode 100644 index 0000000..e366757 --- /dev/null +++ b/arduino/all the sketchs of my life/Diversos/dojo_ms/dojo_ms.pde @@ -0,0 +1,87 @@ +#define MOTOR1_P 12 +#define MOTOR1_N 11 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 6 + +#define FRENTE 1 +#define RE 0 +#define LUZRGB 9 +#define DIREITA 1 +#define ESQUERDA 0 + +void setup() { + pinMode(MOTOR1_P,OUTPUT); + pinMode(MOTOR2_P,OUTPUT); + pinMode(MOTOR1_N,OUTPUT); + pinMode(MOTOR2_N,OUTPUT); +} + +void girar(int intensidade,int direcao) +{ + if(direcao==DIREITA) { + + + digitalWrite(MOTOR1_P,FRENTE); + digitalWrite(MOTOR1_N,!FRENTE); + digitalWrite(MOTOR2_P,RE); + digitalWrite(MOTOR2_N,!RE); + analogWrite(MOTOR1_PWM, intensidade * 50); + analogWrite(MOTOR2_PWM, intensidade * 50); + delay(1000); + + } + else if(direcao==ESQUERDA) +{ + + + digitalWrite(MOTOR1_P,RE); + digitalWrite(MOTOR1_N,!RE); + digitalWrite(MOTOR2_P,FRENTE); + digitalWrite(MOTOR2_N,!FRENTE); + analogWrite(MOTOR1_PWM, intensidade * 50); + analogWrite(MOTOR2_PWM, intensidade * 50); + delay(1000); + + } +} + +void piscar(int vezes) { + for(int x=0;x +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define DISTANCIA 1 + +int sentido; +Servo servoV; +Servo servoH; +int contador=0; +long distancia; +long distanciaEsquerda; +long distanciaDireita; + +void setup() { + servoH.attach(11); + servoV.attach(10); + Serial.begin(9600); +} + +int lerPingComMedia() { + int d1,d2,d3; + d1 = analogRead(1); + delay(5); + d2 = analogRead(1); + delay(5); + d3 = analogRead(1); + delay(5); + return (d1 + d2 + d3)/3; +} + +void lerPing() { + distancia = lerPingComMedia(); +} +void lerPingFull() { + servoH.write(30); + delay(200); + distanciaEsquerda = lerPingComMedia(); + servoH.write(100); + delay(200); + distancia = lerPingComMedia(); + servoH.write(150); + delay(200); + distanciaDireita = lerPingComMedia(); + servoH.write(85); +} + +void loop() { + lerPing(); + if(random(0,1)) { + } + else { + } + while(distancia<20) { + andarTraz(200,5); + parar(); + lerPing(); + } + while(distancia>20) { + andarFrente(200,5); + lerPing(); + } + +} + + + + + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarTraz(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarFrente(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/Diversos/dojo_sjrp/dojo_sjrp.pde b/arduino/all the sketchs of my life/Diversos/dojo_sjrp/dojo_sjrp.pde new file mode 100644 index 0000000..485072a --- /dev/null +++ b/arduino/all the sketchs of my life/Diversos/dojo_sjrp/dojo_sjrp.pde @@ -0,0 +1,111 @@ +#include +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define DISTANCIA 1 + +int sentido; +Servo servoV; +Servo servoH; +int contador=0; +int direcaoServo=0; + +void setup() { + servoH.attach(11); + servoV.attach(10); + Serial.begin(9600); + servoH.write(1); + delay(1500); + servoH.write(180); + delay(1500); + servoH.write(90); + delay(1500); + +} +void loop() { + Serial.println(analogRead(1)); + delay(10); +} + + + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarTraz(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarFrente(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + diff --git a/arduino/all the sketchs of my life/Diversos/dojo_solucao/dojo_solucao.pde b/arduino/all the sketchs of my life/Diversos/dojo_solucao/dojo_solucao.pde new file mode 100644 index 0000000..e22e090 --- /dev/null +++ b/arduino/all the sketchs of my life/Diversos/dojo_solucao/dojo_solucao.pde @@ -0,0 +1,160 @@ +#include +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define DISTANCIA 1 + +int sentido; +Servo servoV; +Servo servoH; +int contador=0; +long distancia; +long distanciaEsquerda; +long distanciaDireita; + +void setup() { + servoH.attach(11); + servoV.attach(10); + Serial.begin(9600); +} + +int lerPingComMedia() { + int d1,d2,d3; + d1 = analogRead(1); + delay(5); + d2 = analogRead(1); + delay(5); + d3 = analogRead(1); + delay(5); + return (d1 + d2 + d3)/3; +} + +void lerPing() { + distancia = lerPingComMedia(); +} +void lerPingFull() { + servoH.write(30); + delay(200); + distanciaEsquerda = lerPingComMedia(); + servoH.write(100); + delay(200); + distancia = lerPingComMedia(); + servoH.write(150); + delay(200); + distanciaDireita = lerPingComMedia(); + servoH.write(85); +} + +void loop() { + lerPing(); + + while(distancia>25) { + andarFrente(200,3); + lerPing(); + } + while(distancia>15 && distancia<25) { + parar(); + delay(200); + lerPingFull(); + if(distanciaEsquerda>distancia && distanciaEsquerda>distanciaDireita) { + girarNoEixo(300,2,1); + } + if(distanciaDireita>distancia && distanciaDireita>distanciaEsquerda) { + girarNoEixo(300,2,0); + } + lerPing(); + } + while(distancia>5 && distancia<15) { + parar(); + andarTraz(500,2); + girarNoEixo(500,2, random(10)%2==0); + lerPing(); + } + +} + + + + + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarTraz(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarFrente(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/ElectronKernel_Sample1/ElectronKernel_Sample1.ino b/arduino/all the sketchs of my life/ElectronKernel_Sample1/ElectronKernel_Sample1.ino new file mode 100644 index 0000000..53a0123 --- /dev/null +++ b/arduino/all the sketchs of my life/ElectronKernel_Sample1/ElectronKernel_Sample1.ino @@ -0,0 +1,47 @@ +#include "ElectronKernel.h" + +#include +Servo servo; + +void setup() +{ + Serial.begin(9600); + setupMotor(); + //servo.attach(5); + Kernel.setup(INTERRUPTION); + Kernel.registerMode("idle"); + Kernel.registerTask(idle); + Kernel.registerMode("test"); + Kernel.registerTask(test); + Kernel.registerMode("avoidance"); + Kernel.registerTask(avoidance); +} + +void loop() +{ + + Kernel.loop(); +} + +void idle() { + //Serial.println("blink mode"); + Kernel.wait(300); + +} + +void test() { + /*for(int x=20;x<255;x++) { + andarFrente(2000,x); + Serial.println(x); + }*/ + for(int x=0;x<6;x++) { + andarFrente(2000,x); + Serial.println(x); + } +} + +void avoidance() { Serial.println("play music mode"); +} + + + diff --git a/arduino/all the sketchs of my life/ElectronKernel_Sample1/Motores.ino b/arduino/all the sketchs of my life/ElectronKernel_Sample1/Motores.ino new file mode 100644 index 0000000..dcb64d2 --- /dev/null +++ b/arduino/all the sketchs of my life/ElectronKernel_Sample1/Motores.ino @@ -0,0 +1,97 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + +int sentido=0; + + + +void setupMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTras(int tempo,int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/GPS/GPS_Display/GPS_Display.pde b/arduino/all the sketchs of my life/GPS/GPS_Display/GPS_Display.pde new file mode 100644 index 0000000..2f7bf4d --- /dev/null +++ b/arduino/all the sketchs of my life/GPS/GPS_Display/GPS_Display.pde @@ -0,0 +1,56 @@ +#include +#include +//amarelo = 2 - azul = 3 +SoftwareSerial GPS = SoftwareSerial(2, 3); +LiquidCrystal lcd(4, 9, 17, 16, 15, 14); +char linea[32] = ""; +int byteGPS = -1; +int conta = 0; + +void setup() { + Serial.begin(9600); + GPS.begin(4800); + initLCD(); + +} +void resetLinha() { + + for (int i=0;i<300;i++) + { + linea[i]=' '; + } +} + +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Master I2C On"); + lcd.setCursor(0, 1); + lcd.print("Waiting command."); +} + +void loop(){ + byteGPS = GPS.read(); + if (byteGPS == -1) + { + delay(100); + } + else { + linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer + conta++; + if (byteGPS==13 || conta==32) { + lcd.clear(); + lcd.setCursor(0,0); + lcd.print(linea); + Serial.println(linea); + resetLinha(); + conta=0; + } + } +} + + + + + diff --git a/arduino/all the sketchs of my life/GPS/GPS_Mega/GPS_Mega.pde b/arduino/all the sketchs of my life/GPS/GPS_Mega/GPS_Mega.pde new file mode 100644 index 0000000..934d154 --- /dev/null +++ b/arduino/all the sketchs of my life/GPS/GPS_Mega/GPS_Mega.pde @@ -0,0 +1,312 @@ +#include + +#define MODE_GPS_LATLONG 0 +#define MODE_GPS_SPEED 1 +#define MODE_GPS_HEADING 2 +#define MODE_AUTOPILOT_COMPASS 3 +#define MODE_AUTOPILOT_ACELEROMETOR 4 +#define MODE_DEBUG 5 + +#define MOTOR_A 12 +#define MOTOR_B 13 +#define MOTOR_PWM 11 + +String modes[] = { + "Lat. Longe.", "Speedy", "Heading", "Auto Compass", "Auto Aceler.", "Debug" }; + +LiquidCrystal lcd(4, 9, 57, 56, 55, 54); +char linea[300] = ""; + +int contaplot=0; +int byteGPS=-1; +//char linha[300]; +char comandoGPR[7] = "$GPRMC"; +int indices[13]; +int cont=0; +int bien=0; +int conta=0; +char latitude[17]; +char longitude[17]; +char velocidade[17]; +char heading[17]; +int cvelocidade=0, clatitude=0, clongitude=0, cheading=0; +volatile int targetHeading; +volatile int mode; + +long lastDebounce=0; +long debounceDelay=50; +long lcdDelay=1500; +long lcdNextUpdate=0; +long lcdLastUpdate=0; + +String lcdLine1; +String lcdLine2; + +void setup() +{ + //LoL + Serial.begin(9600); + Serial2.begin(115200); + Serial1.begin(4800); + attachInterrupt(3, buttonPressed, LOW); //PORTA 18, quando estiver subindo + attachInterrupt(2, changeMode, LOW); //PORTA 18, quando estiver subindo + initLCD(); + // resetLinha(); + //resetDados(); +} + +void setupMotor() { + pinMode(MOTOR_A, OUTPUT); + pinMode(MOTOR_B, OUTPUT); +} + +void loop() +{ + if(mode>=0 && mode<=2) savelocation(); + if(mode==3 || mode==4) android(); + if(mode==MODE_DEBUG) debug(); + lcdRestore(); +} + +void changeMode() { + if(millis()-lastDebounce>debounceDelay) { + mode = mode== 5 ? 0 : mode + 1; + lastDebounce=millis(); + resetMode(); + lcdPrint("Mode", modes[mode], 2000); + + } + +} + +void buttonPressed() { + if(millis()-lastDebounce>debounceDelay) { + targetHeading = targetHeading==360 ? 1 : targetHeading + 1; + lastDebounce=millis(); + lcdPrint("Target Heading", targetHeading, 2000); + + } +} + +void android() { + + if(Serial2.available()>0) + { + char l = Serial2.read(); + // byteGPS=Serial2.read(); // Read a byte of the serial port + + linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer + conta++; + if (byteGPS==13) + { // If the received byte is = to 13, end of transmission + Serial.print(linea); + conta=0; + } + } + /*else { + lcdPrint("Android BT", "No data!", 0); + }*/ + +} + + +void savelocation () +{ + if(Serial1.available()>0) { + + byteGPS=Serial1.read(); // Read a byte of the serial port + linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer + conta++; + if (byteGPS==13) + { // If the received byte is = to 13, end of transmission + Serial.print(linea); + cont=0; + bien=0; + for (int i=1;i<7;i++) + { // Verifies if the received command starts with $GPR + if (linea[i]==comandoGPR[i-1]) + { + bien++; + } + } + if(bien==6) + { // If yes, continue and process the data + for (int i=0;i<300;i++) + { + if (linea[i]==','){ // check for the position of the "," separator + indices[cont]=i; + cont++; + } + if (linea[i]=='*') + { // ... and the "*" + indices[12]=i; + cont++; + } + } + Serial2.println(linea); + Serial.println(""); // ... and write to the serial port + Serial.println(""); + Serial.println("---------------"); + resetDados(); + for (int i=0;i<12;i++) + { + switch(i){ + case 0 : + Serial.print("Time in UTC (HhMmSs): "); + break; + case 1 : + Serial.print("Status (A=OK,V=KO): "); + break; + case 2 : + Serial.print("Latitude: "); + break; + case 3 : + Serial.print("Direction (N/S): "); + break; + case 4 : + Serial.print("Longitude: "); + break; + case 5 : + Serial.print("Direction (E/W): "); + break; + case 6 : + Serial.print("Velocity in knots: "); + break; + case 7 : + Serial.print("Heading in degrees: "); + break; + case 8 : + Serial.print("Date UTC (DdMmAa): "); + break; + case 9 : + Serial.print("Magnetic degrees: "); + break; + case 10 : + Serial.print("(E/W): "); + break; + case 11 : + Serial.print("Mode: "); + break; + case 12 : + Serial.print("Checksum: "); + break; + } + for (int j=indices[i];j<(indices[i+1]-1);j++) + { + Serial.print(linea[j+1]); + if(i==2) { + latitude[clatitude++]=linea[j+1]; + } + else if(i==3) { + latitude[clatitude++]=linea[j+1]; + } + else if(i==4) { + longitude[clongitude++]=linea[j+1]; + } + else if(i==5) { + longitude[clongitude++]=linea[j+1]; + } + else if(i==6) { + velocidade[cvelocidade++]=linea[j+1]; + } + else if(i==7) { + heading[cheading++]=linea[j+1]; + } + } + Serial.println(""); + if(mode==MODE_GPS_LATLONG) lcdPrint(latitude, longitude,0); + else if(mode==MODE_GPS_SPEED) lcdPrint("Speed", velocidade, 0); + else if(mode==MODE_GPS_HEADING) lcdPrint("Heading", heading, 0); + } + } + cvelocidade=0; + clatitude=0; + clongitude=0; + cheading=0; + conta=0; // Reset the buffer + for (int i=0;i<300;i++) + { + linea[i]=' '; + } + } + } +} + +void resetDados() { + for( int i=0;i<16;i++) { + latitude[i]=' '; + longitude[i]=' '; + velocidade[i]=' '; + heading[i]=' '; + } +} + +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcdPrint("Eletron Livre", "Tiziu", 0); + delay(2000); +} + + +void lcdPrint(String line1, String line2, long time) { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print(line1); + lcd.setCursor(0, 1); + lcd.print(line2); + if(time > 0) { //user want to keep last lines... + lcdNextUpdate = millis() + time; + } + else { + + lcdLine1=line1; + lcdLine2=line2; + lcdNextUpdate = 0; + } + lcdLastUpdate=millis(); + +} + + +void lcdRestore() { + if(lcdNextUpdate!=0 && lcdNextUpdate<=millis()){ + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print(lcdLine1); + lcd.setCursor(0, 1); + lcd.print(lcdLine2); + lcdNextUpdate=0; + } +} + +void debug() { + lcdPrint("Debug", "Avanca", 0); + + digitalWrite(MOTOR_A, 0); + digitalWrite(MOTOR_B, 1); + analogWrite(MOTOR_PWM, 250); + delay(1500); + if(mode!=MODE_DEBUG) return; + + lcdPrint("Debug", "Para", 0); + analogWrite(MOTOR_PWM, 0); + delay(1500); + if(mode!=MODE_DEBUG) return; + + lcdPrint("Debug", "Retro", 0); + digitalWrite(MOTOR_A, 1); + digitalWrite(MOTOR_B, 0); + analogWrite(MOTOR_PWM, 250); + delay(1500); + if(mode!=MODE_DEBUG) return; + + lcdPrint("Debug", "Para", 0); + analogWrite(MOTOR_PWM, 0); + delay(1500); + +} + +void resetMode() { + analogWrite(MOTOR_PWM,0); +} diff --git a/arduino/all the sketchs of my life/GPS/GPS_Sample_Web/GPS_Sample_Web.pde b/arduino/all the sketchs of my life/GPS/GPS_Sample_Web/GPS_Sample_Web.pde new file mode 100644 index 0000000..2380a2a --- /dev/null +++ b/arduino/all the sketchs of my life/GPS/GPS_Sample_Web/GPS_Sample_Web.pde @@ -0,0 +1,131 @@ +#include +#include +#include + +int ledPin=13; +int byteGPS=-1; +char linea[300] = ""; +char comandoGPR[7] = "$GPRMC"; +int cont=0; +int bien=0; +int conta=0; +int indices[13]; + +SoftwareSerial GPS = SoftwareSerial(2, 3); + +void setup() +{ + pinMode(ledPin, OUTPUT); // Initialize LED pin + Serial.begin(9600); + GPS.begin(4800); + for (int i=0;i<300;i++) + { // Initialize a buffer for received data + linea[i]=' '; + } +} + +void loop() +{ + savelocation (); +} + +void savelocation () +{ +digitalWrite(ledPin, HIGH); + byteGPS=GPS.read(); // Read a byte of the serial port + if (byteGPS == -1) + { // See if the port is empty yet + delay(100); + } + else { + linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer + conta++; + if (byteGPS==13) + { // If the received byte is = to 13, end of transmission + digitalWrite(ledPin, LOW); + cont=0; + bien=0; + for (int i=1;i<7;i++) + { // Verifies if the received command starts with $GPR + if (linea[i]==comandoGPR[i-1]) + { + bien++; + } + } + if(bien==6) + { // If yes, continue and process the data + for (int i=0;i<300;i++) + { + if (linea[i]==','){ // check for the position of the "," separator + indices[cont]=i; + cont++; + } + if (linea[i]=='*') + { // ... and the "*" + indices[12]=i; + cont++; + } + } + Serial.println(""); // ... and write to the serial port + Serial.println(""); + Serial.println("---------------"); + for (int i=0;i<12;i++) + { + switch(i){ + case 0 : + Serial.print("Time in UTC (HhMmSs): "); + break; + case 1 : + Serial.print("Status (A=OK,V=KO): "); + break; + case 2 : + Serial.print("Latitude: "); + break; + case 3 : + Serial.print("Direction (N/S): "); + break; + case 4 : + Serial.print("Longitude: "); + break; + case 5 : + Serial.print("Direction (E/W): "); + break; + case 6 : + Serial.print("Velocity in knots: "); + break; + case 7 : + Serial.print("Heading in degrees: "); + break; + case 8 : + Serial.print("Date UTC (DdMmAa): "); + break; + case 9 : + Serial.print("Magnetic degrees: "); + break; + case 10 : + Serial.print("(E/W): "); + break; + case 11 : + Serial.print("Mode: "); + break; + case 12 : + Serial.print("Checksum: "); + break; + } + for (int j=indices[i];j<(indices[i+1]-1);j++) + { + Serial.print(linea[j+1]); + } + Serial.println(""); + } + } + conta=0; // Reset the buffer + for (int i=0;i<300;i++) + { + linea[i]=' '; + } + } + } +} + + diff --git a/arduino/all the sketchs of my life/GPS/GPS_Simples/GPS_Simples.pde b/arduino/all the sketchs of my life/GPS/GPS_Simples/GPS_Simples.pde new file mode 100644 index 0000000..1d39542 --- /dev/null +++ b/arduino/all the sketchs of my life/GPS/GPS_Simples/GPS_Simples.pde @@ -0,0 +1,41 @@ +#include +#include + +SoftwareSerial GPS = SoftwareSerial(2, 3); +LiquidCrystal lcd(4, 9, 17, 16, 15, 14); + +byte GPSByte; + +void setup() +{ + GPS.begin(4800); + Serial.begin(9600); + //initLCD(); +} +int x=0,y=0; +void loop() +{ + // Get the GPS data + GPSByte = GPS.read(); + // Print GPS data + lcd.setCursor(x,y); + lcd.print(GPSByte); + x++; + if(x==16 && y==0) { + x=0; y=1; + } + else if(x==16 && y==1) { + x=0; y=0; + } + Serial.print(GPSByte); +} + +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Master I2C On"); + lcd.setCursor(0, 1); + lcd.print("Waiting command."); +} + diff --git a/arduino/all the sketchs of my life/GPS/GPS_Simples_OK/GPS_Simples_OK.pde b/arduino/all the sketchs of my life/GPS/GPS_Simples_OK/GPS_Simples_OK.pde new file mode 100644 index 0000000..e9628c1 --- /dev/null +++ b/arduino/all the sketchs of my life/GPS/GPS_Simples_OK/GPS_Simples_OK.pde @@ -0,0 +1,47 @@ +#include + +//LiquidCrystal lcd(4, 9, 17, 16, 15, 14); +LiquidCrystal lcd(4, 9, 57, 56, 55, 54); + + +void setup() +{ + Serial1.begin(4800); + Serial.begin(9600); + initLCD(); +} + + +int x=0,y=0; +byte GPSByte; + +void loop() +{ + while(Serial1.available()>0) { + GPSByte = Serial1.read(); + Serial.print(GPSByte); + lcd.setCursor(x,y); + lcd.print(GPSByte); + x++; + if(x==16 && y==0) { + x=0; + y=1; + } + else if(x==16 && y==1) { + x=0; + y=0; + } + + } +} + +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Master I2C On"); + lcd.setCursor(0, 1); + lcd.print("Waiting command."); +} + + diff --git a/arduino/all the sketchs of my life/GoHorse_v1/Acelerometro.pde b/arduino/all the sketchs of my life/GoHorse_v1/Acelerometro.pde new file mode 100644 index 0000000..0ec5a49 --- /dev/null +++ b/arduino/all the sketchs of my life/GoHorse_v1/Acelerometro.pde @@ -0,0 +1,96 @@ +//SOBRE O EIXO X - vertical +// frente ele vai de 255 at 190 e depois 190 ate 255 +// tras ele vai de 0 a 64 + +//SOBRE O EIXO Y - horizontal +// plano 233, inclinando para esquerda 172 +// plano 233, inclinando para direita 255, 0, 46 + +//SOBRE O EIXO Z - +#include + +#define ACCELEROMETER 0x1D //Address for Accelerometer + +//REGISTERS +#define MODE_CONTROL 0x16 //Mode control register +#define PULSE_DET 0x1B //Pulse detection threshold limit value +#define X_OUT 0x06 //8 bit register containing value for X +#define Y_OUT 0x07 //8 bit register containing value for Y +#define Z_OUT 0x08 //8 bit register containing value for Z +#define DETECTION 0x0A //Detection source register + +//VALUES +#define Z_PULSE 0x40 //Pulse detected on Z-axis +#define SENSEVALUE 0x25 //Default sensitivity level + +void setupAcelerometro() { + Wire.begin(); + accWrite(MODE_CONTROL, SENSEVALUE); + +} + +//function to write byte data into a register +void accWrite(byte address, byte data) { + Wire.beginTransmission(ACCELEROMETER); + Wire.send(address); + Wire.send(data); + Wire.endTransmission(); +} + +//function to read byte data from a register +byte accRead(byte address){ + byte val = 0x00; + Wire.beginTransmission(ACCELEROMETER); + Wire.send(address); + Wire.endTransmission(); + Wire.requestFrom(ACCELEROMETER, 1); + if(Wire.available() > 0) { + val = Wire.receive(); + } + Wire.endTransmission(); + return val; +} + +void debugAcelerometro() { + Serial.print("X:"); + Serial.println((unsigned int)accRead(X_OUT)); + Serial.print("Y:"); + Serial.println((unsigned int)accRead(Y_OUT)); + Serial.print("Z:"); + Serial.println((unsigned int)accRead(Z_OUT)); + delay(100); +} +byte eixoXparaAngulo(int valor) { + if(valor>=190 && valor<=255) { + return map(valor,255,192,0,90); + } + else if(valor>=0 && valor<=64) { + return map(valor,0,64,1,90)*-1; + } + else { + return 0; + } +} + +int lerEixoX() { + return (int)accRead(X_OUT); +} +byte eixoYparaAngulo(int valor) { + if(valor>=172 && valor<=233) { + return map(valor,172,233,90,0); + } + else if((valor>=0 && valor<=46) || valor>233 && valor<=255 ) { + valor = valor > 233 ? valor = 256-valor : 23+valor; + + return map(valor,0,69,1,90)*-1; + } + else { + return 0; + } +} +int lerEixoZ() { + return (int)accRead(Z_OUT); +} +int lerEixoY() { + return (int)accRead(Y_OUT); +} diff --git a/arduino/all the sketchs of my life/GoHorse_v1/GoHorse_v1.pde b/arduino/all the sketchs of my life/GoHorse_v1/GoHorse_v1.pde new file mode 100644 index 0000000..ef473d9 --- /dev/null +++ b/arduino/all the sketchs of my life/GoHorse_v1/GoHorse_v1.pde @@ -0,0 +1,104 @@ +#include + +// SD chip select pin +const uint8_t chipSelect = SS_PIN; +#define LED_ERROR 4 +#define LED_OK 7 +// file system object +// store error strings in flash to save RAM +#define error(s) sd.errorHalt_P(PSTR(s)) + +SdFat sd; +volatile int mode=0; + +long lastDebounce=0; +long debounceDelay=50; + +void setup() { + Serial.begin(9600); + attachInterrupt(0, changeMode, LOW); //PORTA 21, quando estiver subindo + + pinMode(4, OUTPUT); + pinMode(7, OUTPUT); + setupAcelerometro(); + digitalWrite(LED_OK, HIGH); + delay(100); + digitalWrite(LED_OK, LOW); +} + +//2805020000 +void loop() { + if(mode==1) coletar(); + else if(mode==0) idle(); + + //Serial.print('x'); + //Serial.print(eixoXparaAngulo(lerEixoX())); + //cout << endl << "Done" << endl; + + //debugAcelerometro(); + //delay(100); +} + +void changeMode() { + if(millis()-lastDebounce>debounceDelay) { + mode = mode== 1 ? 0 : 1; + lastDebounce=millis(); + } +} +void idle() { + digitalWrite(LED_OK, HIGH); + delay(2000); + digitalWrite(LED_OK, LOW); + delay(2000); +} + +void coletar() { + if(mode!=1) return; + char name[] = "APPEND.TXT"; + + // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with + // breadboards. use SPI_FULL_SPEED for better performance. + if (!sd.init(SPI_HALF_SPEED, chipSelect)) sd.initErrorHalt(); + + ofstream sdout(name, ios::out | ios::app); + if (!sdout) { + //error("open failed"); + digitalWrite(LED_ERROR, HIGH); + delay(500); + digitalWrite(LED_ERROR, LOW); + delay(500); + } + // use int() so byte will print as decimal number + sdout << "x: " << lerEixoX(); + sdout << " millis = " << millis() << endl; + digitalWrite(LED_OK, HIGH); + delay(20); + digitalWrite(LED_OK, LOW); + delay(20); + // close the stream + sdout.close(); + /*if (!sdout) { + digitalWrite(LED_ERROR, HIGH); + delay(500); + digitalWrite(LED_ERROR, LOW); + delay(500); + //error("append data failed"); + } + else { + digitalWrite(LED_ERROR, HIGH); + digitalWrite(LED_OK, HIGH); + delay(500); + digitalWrite(LED_ERROR, LOW); + digitalWrite(LED_OK, LOW); + delay(500); + }*/ + + + +} + + + + + + diff --git a/arduino/all the sketchs of my life/GoHorse_v1/Polar.pde b/arduino/all the sketchs of my life/GoHorse_v1/Polar.pde new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/GoHorse_v1/SDCard.pde b/arduino/all the sketchs of my life/GoHorse_v1/SDCard.pde new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/arduino/all the sketchs of my life/GoHorse_v1/SDCard.pde @@ -0,0 +1 @@ + diff --git a/arduino/all the sketchs of my life/GoHorse_v1/Visual/Visual.pde b/arduino/all the sketchs of my life/GoHorse_v1/Visual/Visual.pde new file mode 100644 index 0000000..cddd7d2 --- /dev/null +++ b/arduino/all the sketchs of my life/GoHorse_v1/Visual/Visual.pde @@ -0,0 +1,50 @@ +/** + * Simple Read + * + * Read data from the serial port and change the color of a rectangle + * when a switch connected to a Wiring or Arduino board is pressed and released. + * This example works with the Wiring / Arduino program that follows below. + */ + + +import processing.serial.*; + +Serial myPort; // Create object from Serial class +int val; // Data received from the serial port + +void setup() +{ + size(200,200,P3D); + String portName = Serial.list()[0]; + myPort = new Serial(this, portName, 9600); +} + +int valCorrigido = 0; +void draw() +{ + if ( myPort.available() > 0) { + val = myPort.read(); + if(val=='x') { + val = myPort.read(); + + if(val>0 && val<=90) valCorrigido=val; + else valCorrigido = val-256; + } + + } + + float t = map(valCorrigido,-90.0,+90.0, 0.0, 200.0); + + background(255); + stroke(0); + fill(175); + translate(width/2, height/2); + rotateX(PI*t/height); + System.out.println(t); + rectMode(CENTER); + rect(0,0,100,100); +} + + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/nbactions.xml b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/nbactions.xml new file mode 100644 index 0000000..2dfca28 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/nbactions.xml @@ -0,0 +1,47 @@ + + + + run + + package + org.codehaus.mojo:exec-maven-plugin:1.1.1:exec + + + -Dfelix.system.properties=file:"${project.build.directory}/run.properties" -cp "${project.build.directory}/felix.jar" org.apache.felix.main.Main + java + + + run-on-felix + + + + debug + + package + org.codehaus.mojo:exec-maven-plugin:1.1.1:exec + + + -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Dfelix.system.properties=file:"${project.build.directory}/run.properties" -cp "${project.build.directory}/felix.jar" org.apache.felix.main.Main + java + true + + + run-on-felix + + + + profile + + package + org.codehaus.mojo:exec-maven-plugin:1.1.1:exec + + + ${profiler.args} -Dfelix.system.properties=file:"${project.build.directory}/run.properties" -cp "${project.build.directory}/felix.jar" org.apache.felix.main.Main + ${profiler.java} + profile + + + run-on-felix + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/pom.xml b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/pom.xml new file mode 100644 index 0000000..699056f --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/pom.xml @@ -0,0 +1,135 @@ + + + + 4.0.0 + br.com.eletronlivre.arduino + ArduinoModule + 1.0-SNAPSHOT + bundle + ArduinoServiceImpl OSGi Bundle + + + org.apache.felix + org.osgi.core + 1.4.0 + + + br.com.eletronlivre.arduino + ArduinoService + 1.0-SNAPSHOT + + + + + + + org.apache.felix + maven-bundle-plugin + 2.0.1 + true + + + br.com.eletronlivre.arduino.osgi.ArduinoActivator + + + + + + + + + + run-on-felix + + + org.apache.felix + org.apache.felix.main + 2.0.2 + provided + + + org.apache.felix.gogo + org.apache.felix.gogo.commands + 0.2.2 + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.3 + + + compile + compile + + run + + + + + + + + + + + + + + + + + + + + + + + + + + felix.auto.install=${urls} + felix.auto.start=${main.bundle.url} + org.osgi.framework.storage=${project.build.url}/felix-cache + org.osgi.framework.bootdelegation=* + + + + felix.auto.install="${bundles}" + felix.auto.start=file:modules/${project.artifactId}-${project.version}.jar + + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2-beta-5 + + + create-executable-jar + package + + single + + + + ${basedir}/src/main/assembly/felix.xml + + ${project.artifactId}-${project.version} + + + + + + + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/src/main/assembly/felix.xml b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/src/main/assembly/felix.xml new file mode 100644 index 0000000..956d093 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/src/main/assembly/felix.xml @@ -0,0 +1,37 @@ + + + all + + zip + + + + false + modules + + org.apache.felix:org.apache.felix.main + + + + false + + + org.apache.felix:org.apache.felix.main + + + + + + ${project.build.directory}/${project.artifactId}-${project.version}.jar + modules + + + ${project.build.directory}/felix.jar + bin + + + ${project.build.directory}/config.properties + conf + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/src/main/java/br/com/eletronlivre/arduino/osgi/ArduinoActivator.java b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/src/main/java/br/com/eletronlivre/arduino/osgi/ArduinoActivator.java new file mode 100644 index 0000000..325ba0b --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/src/main/java/br/com/eletronlivre/arduino/osgi/ArduinoActivator.java @@ -0,0 +1,23 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.eletronlivre.arduino.osgi; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +/** + * + * @author vsenger + */ +public class ArduinoActivator implements BundleActivator { + + public void start(BundleContext context) throws Exception { + //TODO add activation code here + } + + public void stop(BundleContext context) throws Exception { + //TODO add deactivation code here + } +} diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/src/main/java/br/com/eletronlivre/arduino/osgi/ArduinoImpl.java b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/src/main/java/br/com/eletronlivre/arduino/osgi/ArduinoImpl.java new file mode 100644 index 0000000..8f99fe9 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/src/main/java/br/com/eletronlivre/arduino/osgi/ArduinoImpl.java @@ -0,0 +1,18 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package br.com.eletronlivre.arduino.osgi; + +/** + * + * @author vsenger + */ +public class ArduinoImpl implements Arduino { + + public void send(byte[] b) { + System.out.println("UIA!"); + } + +} diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/ArduinoModule-1.0-SNAPSHOT-all.zip b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/ArduinoModule-1.0-SNAPSHOT-all.zip new file mode 100644 index 0000000..a67e40e Binary files /dev/null and b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/ArduinoModule-1.0-SNAPSHOT-all.zip differ diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/classes/META-INF/MANIFEST.MF b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000..ffc48c2 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/classes/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Export-Package: br.com.eletronlivre.arduino.osgi;uses:="org.osgi.frame + work" +Built-By: vsenger +Tool: Bnd-0.0.357 +Bundle-Name: ArduinoServiceImpl OSGi Bundle +Created-By: Apache Maven Bundle Plugin +Bundle-Version: 1.0.0.SNAPSHOT +Build-Jdk: 1.6.0_18 +Bnd-LastModified: 1305319842063 +Bundle-ManifestVersion: 2 +Bundle-Activator: br.com.eletronlivre.arduino.osgi.ArduinoActivator +Import-Package: br.com.eletronlivre.arduino.osgi,org.osgi.framework;ve + rsion="1.5" +Bundle-SymbolicName: br.com.eletronlivre.arduino.ArduinoModule + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/config.properties b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/config.properties new file mode 100644 index 0000000..4153dd7 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/config.properties @@ -0,0 +1,2 @@ +felix.auto.install="file:modules/classes file:modules/org.osgi.core-1.4.0.jar file:modules/org.apache.felix.gogo.commands-0.2.2.jar file:modules/org.apache.felix.gogo.runtime-0.2.2.jar" + felix.auto.start=file:modules/ArduinoModule-1.0-SNAPSHOT.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle0/bundle.id b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle0/bundle.id new file mode 100644 index 0000000..7813681 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle0/bundle.id @@ -0,0 +1 @@ +5 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.id b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.id new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.id @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.lastmodified b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.lastmodified new file mode 100644 index 0000000..8a8ceef --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.lastmodified @@ -0,0 +1 @@ +1305317235983 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.location b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.location new file mode 100644 index 0000000..846636b --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.location @@ -0,0 +1 @@ +file:/home/vsenger/.m2/repository/org/apache/felix/org.osgi.core/1.4.0/org.osgi.core-1.4.0.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.startlevel b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.startlevel new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/bundle.startlevel @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/version0.0/revision.location b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/version0.0/revision.location new file mode 100644 index 0000000..846636b --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle1/version0.0/revision.location @@ -0,0 +1 @@ +file:/home/vsenger/.m2/repository/org/apache/felix/org.osgi.core/1.4.0/org.osgi.core-1.4.0.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.id b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.id new file mode 100644 index 0000000..d8263ee --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.id @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.lastmodified b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.lastmodified new file mode 100644 index 0000000..d2a75ad --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.lastmodified @@ -0,0 +1 @@ +1305317236005 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.location b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.location new file mode 100644 index 0000000..558bbb7 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.location @@ -0,0 +1 @@ +file:/home/vsenger/.m2/repository/org/apache/felix/gogo/org.apache.felix.gogo.commands/0.2.2/org.apache.felix.gogo.commands-0.2.2.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.startlevel b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.startlevel new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/bundle.startlevel @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/version0.0/revision.location b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/version0.0/revision.location new file mode 100644 index 0000000..558bbb7 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle2/version0.0/revision.location @@ -0,0 +1 @@ +file:/home/vsenger/.m2/repository/org/apache/felix/gogo/org.apache.felix.gogo.commands/0.2.2/org.apache.felix.gogo.commands-0.2.2.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.id b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.id new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.id @@ -0,0 +1 @@ +3 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.lastmodified b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.lastmodified new file mode 100644 index 0000000..86190a8 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.lastmodified @@ -0,0 +1 @@ +1305317236026 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.location b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.location new file mode 100644 index 0000000..82c2f56 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.location @@ -0,0 +1 @@ +file:/home/vsenger/.m2/repository/org/apache/felix/gogo/org.apache.felix.gogo.runtime/0.2.2/org.apache.felix.gogo.runtime-0.2.2.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.startlevel b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.startlevel new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/bundle.startlevel @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/version0.0/revision.location b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/version0.0/revision.location new file mode 100644 index 0000000..82c2f56 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle3/version0.0/revision.location @@ -0,0 +1 @@ +file:/home/vsenger/.m2/repository/org/apache/felix/gogo/org.apache.felix.gogo.runtime/0.2.2/org.apache.felix.gogo.runtime-0.2.2.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.id b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.id new file mode 100644 index 0000000..bf0d87a --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.id @@ -0,0 +1 @@ +4 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.lastmodified b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.lastmodified new file mode 100644 index 0000000..4bfc08e --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.lastmodified @@ -0,0 +1 @@ +1305317236041 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.location b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.location new file mode 100644 index 0000000..72ba808 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.location @@ -0,0 +1 @@ +file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/JavaEEArduino/ArduinoModule/target/ArduinoModule-1.0-SNAPSHOT.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.startlevel b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.startlevel new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.startlevel @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.state b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.state new file mode 100644 index 0000000..6811ae8 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/bundle.state @@ -0,0 +1 @@ +active \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/version0.0/revision.location b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/version0.0/revision.location new file mode 100644 index 0000000..72ba808 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/felix-cache/bundle4/version0.0/revision.location @@ -0,0 +1 @@ +file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/JavaEEArduino/ArduinoModule/target/ArduinoModule-1.0-SNAPSHOT.jar \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/run.properties b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/run.properties new file mode 100644 index 0000000..aedd4fb --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoModule/target/run.properties @@ -0,0 +1,4 @@ +felix.auto.install=file:/home/vsenger/.m2/repository/org/apache/felix/org.osgi.core/1.4.0/org.osgi.core-1.4.0.jar file:/home/vsenger/.m2/repository/org/apache/felix/gogo/org.apache.felix.gogo.commands/0.2.2/org.apache.felix.gogo.commands-0.2.2.jar file:/home/vsenger/.m2/repository/org/apache/felix/gogo/org.apache.felix.gogo.runtime/0.2.2/org.apache.felix.gogo.runtime-0.2.2.jar + felix.auto.start=file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/JavaEEArduino/ArduinoModule/target/ArduinoModule-1.0-SNAPSHOT.jar + org.osgi.framework.storage=/media/Vinicius/EletronLivre/Program-ME/Arduino Sketches/JavaEEArduino/ArduinoModule/target/felix-cache + org.osgi.framework.bootdelegation=* \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/pom.xml b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/pom.xml new file mode 100644 index 0000000..4ee2a5d --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + br.com.eletronlivre.arduino + ArduinoService + bundle + 1.0-SNAPSHOT + ArduinoService + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/src/main/java/br/com/eletronlivre/arduino/osgi/Arduino.java b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/src/main/java/br/com/eletronlivre/arduino/osgi/Arduino.java new file mode 100644 index 0000000..f217406 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/src/main/java/br/com/eletronlivre/arduino/osgi/Arduino.java @@ -0,0 +1,14 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package br.com.eletronlivre.arduino.osgi; + +/** + * + * @author vsenger + */ +public interface Arduino { + public void send(byte[] b); +} diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/src/test/java/br/com/eletronlivre/arduino/arduinoservice/AppTest.java b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/src/test/java/br/com/eletronlivre/arduino/arduinoservice/AppTest.java new file mode 100644 index 0000000..58b590b --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/src/test/java/br/com/eletronlivre/arduino/arduinoservice/AppTest.java @@ -0,0 +1,38 @@ +package br.com.eletronlivre.arduino.arduinoservice; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/target/maven-archiver/pom.properties b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/target/maven-archiver/pom.properties new file mode 100644 index 0000000..ec693b8 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Fri May 13 17:26:35 BRT 2011 +version=1.0-SNAPSHOT +groupId=br.com.eletronlivre.arduino +artifactId=ArduinoService diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/target/surefire-reports/TEST-br.com.eletronlivre.arduino.arduinoservice.AppTest.xml b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/target/surefire-reports/TEST-br.com.eletronlivre.arduino.arduinoservice.AppTest.xml new file mode 100644 index 0000000..cc51b36 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/target/surefire-reports/TEST-br.com.eletronlivre.arduino.arduinoservice.AppTest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/target/surefire-reports/br.com.eletronlivre.arduino.arduinoservice.AppTest.txt b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/target/surefire-reports/br.com.eletronlivre.arduino.arduinoservice.AppTest.txt new file mode 100644 index 0000000..a63dfda --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ArduinoService/target/surefire-reports/br.com.eletronlivre.arduino.arduinoservice.AppTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: br.com.eletronlivre.arduino.arduinoservice.AppTest +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.083 sec diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build.xml b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build.xml new file mode 100644 index 0000000..3bd178d --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build.xml @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project exemplo. + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/classes/exemplo/Bundle.properties b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/classes/exemplo/Bundle.properties new file mode 100644 index 0000000..00d1841 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/classes/exemplo/Bundle.properties @@ -0,0 +1 @@ +OpenIDE-Module-Name=Exemplo diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/cluster/.lastModified b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/cluster/.lastModified new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/cluster/config/Modules/exemplo.xml b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/cluster/config/Modules/exemplo.xml new file mode 100644 index 0000000..3d09a05 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/cluster/config/Modules/exemplo.xml @@ -0,0 +1,10 @@ + + + + false + false + true + modules/exemplo.jar + false + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/cluster/update_tracking/exemplo.xml b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/cluster/update_tracking/exemplo.xml new file mode 100644 index 0000000..d868237 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/cluster/update_tracking/exemplo.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/no-license.txt b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/no-license.txt new file mode 100644 index 0000000..201dea1 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/build/no-license.txt @@ -0,0 +1 @@ +[NO LICENSE SPECIFIED] \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/manifest.mf b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/manifest.mf new file mode 100644 index 0000000..8f4f19a --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/manifest.mf @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Bundle-Localization: exemplo/Bundle +Bundle-Name: %OpenIDE-Module-Name +Bundle-SymbolicName: exemplo +Bundle-Version: 1.0 + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/build-impl.xml b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/build-impl.xml new file mode 100644 index 0000000..80852e5 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/build-impl.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/genfiles.properties b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/genfiles.properties new file mode 100644 index 0000000..1a350dd --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=ae010660 +build.xml.script.CRC32=22fcf54e +build.xml.stylesheet.CRC32=a56c6a5b@1.42.2 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=ae010660 +nbproject/build-impl.xml.script.CRC32=bf763f61 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.42.2 diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/platform.properties b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/platform.properties new file mode 100644 index 0000000..8705226 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/platform.properties @@ -0,0 +1,20 @@ +cluster.path=\ + ${nbplatform.active.dir}/javafx:\ + ${nbplatform.active.dir}/dlight:\ + ${nbplatform.active.dir}/ruby:\ + ${nbplatform.active.dir}/enterprise:\ + ${nbplatform.active.dir}/groovy:\ + ${nbplatform.active.dir}/java:\ + ${nbplatform.active.dir}/ergonomics:\ + ${nbplatform.active.dir}/ide:\ + ${nbplatform.active.dir}/identity:\ + ${nbplatform.active.dir}/apisupport:\ + ${nbplatform.active.dir}/cnd:\ + ${nbplatform.active.dir}/profiler:\ + ${nbplatform.active.dir}/platform:\ + ${nbplatform.active.dir}/harness:\ + ${nbplatform.active.dir}/mobility:\ + ${nbplatform.active.dir}/websvccommon:\ + ${nbplatform.active.dir}/php:\ + ${nbplatform.active.dir}/nb +nbplatform.active=default diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/private/platform-private.properties b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/private/platform-private.properties new file mode 100644 index 0000000..29920de --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/private/platform-private.properties @@ -0,0 +1 @@ +user.properties.file=/home/vsenger/.netbeans/6.9/build.properties diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/private/private.xml b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/private/private.xml new file mode 100644 index 0000000..528803d --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/private/private.xml @@ -0,0 +1,6 @@ + + + + file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/JavaEEArduino/Exemplo/build/classes/exemplo/Bundle.properties + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/project.properties b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/project.properties new file mode 100644 index 0000000..17255ba --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/project.properties @@ -0,0 +1,2 @@ +javac.source=1.6 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/project.xml b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/project.xml new file mode 100644 index 0000000..a4fac88 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/nbproject/project.xml @@ -0,0 +1,18 @@ + + + org.netbeans.modules.apisupport.project + + + exemplo + + + + org.netbeans.libs.osgi + + + + + + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/src/exemplo/Bundle.properties b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/src/exemplo/Bundle.properties new file mode 100644 index 0000000..00d1841 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/Exemplo/src/exemplo/Bundle.properties @@ -0,0 +1 @@ +OpenIDE-Module-Name=Exemplo diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/build.xml b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/build.xml new file mode 100644 index 0000000..a0ee456 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/build.xml @@ -0,0 +1,69 @@ + + + + + + Builds, tests, and runs the project ScalaApplication1. + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/manifest.mf b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/build-impl.xml b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/build-impl.xml new file mode 100644 index 0000000..a7a2b44 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/build-impl.xml @@ -0,0 +1,710 @@ + + + + + + + + + + + + + + + + + + + You must set SCALA_HOME or environment property and append "-J-Dscala.home=scalahomepath" + property to the end of "netbeans_default_options" in NetBeansInstallationPath/etc/netbeans.conf to point to + Scala installation directory. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/genfiles.properties b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/genfiles.properties new file mode 100644 index 0000000..463d13c --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=eeb8aeb7 +build.xml.script.CRC32=83c78a1c +build.xml.stylesheet.CRC32=ca9d572e@1.5 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=eeb8aeb7 +nbproject/build-impl.xml.script.CRC32=63812ea2 +nbproject/build-impl.xml.stylesheet.CRC32=5220179f@1.5 diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/private/private.properties b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/private/private.properties new file mode 100644 index 0000000..121c208 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/private/private.properties @@ -0,0 +1 @@ +user.properties.file=/home/vsenger/.netbeans/7.0/build.properties diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/project.properties b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/project.properties new file mode 100644 index 0000000..85f477f --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/project.properties @@ -0,0 +1,64 @@ +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form,**/*.scala +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ScalaApplication1.jar +dist.javadoc.dir=${dist.dir}/scaladoc +excludes= +includes=** +jar.compress=false +java.platform.active=java_default_platform +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=scalaapplication1.Main +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +# Space-separated list of extra scalac options +scalac.compilerargs= +scalac.deprecation=no +scalac.unchecked=no +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/project.xml b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/project.xml new file mode 100644 index 0000000..c136834 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/nbproject/project.xml @@ -0,0 +1,16 @@ + + + org.netbeans.modules.scala.project + + + ScalaApplication1 + 1.6.5 + + + + + + + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/src/scalaapplication1/Main.scala b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/src/scalaapplication1/Main.scala new file mode 100644 index 0000000..460f4d5 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/ScalaApplication1/src/scalaapplication1/Main.scala @@ -0,0 +1,17 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package scalaapplication1 + +object Main { + + /** + * @param args the command line arguments + */ + def main(args: Array[String]): Unit = { + println("Hello, world!") + } + +} diff --git a/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/pom.xml b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/pom.xml new file mode 100644 index 0000000..f3d90f9 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/pom.xml @@ -0,0 +1,101 @@ + + + 4.0.0 + br.com.eletronlivre.webscheduler + WebScheduler + war + 1.0-SNAPSHOT + WebScheduler Java EE 6 Webapp + http://maven.apache.org + + + java.net2 + Repository hosting the jee6 artifacts + http://download.java.net/maven/2 + + + + + javax + javaee-web-api + 6.0 + provided + + + + junit + junit + 3.8.2 + test + + + br.com.eletronlivre.arduino + ArduinoService + 1.0-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.6 + 1.6 + + + + org.apache.maven.plugins + maven-war-plugin + 2.1-beta-1 + + false + + + + WebScheduler + + + + endorsed + + + sun.boot.class.path + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + + + ${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar${path.separator}${sun.boot.class.path} + + + + + javax + javaee-endorsed-api + 6.0 + + + + + + + + + gfv3ee6 + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/profiles.xml b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/profiles.xml new file mode 100644 index 0000000..895de51 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/profiles.xml @@ -0,0 +1,18 @@ + + + + + netbeans-private + + + netbeans.execution + true + + + + [/java/glassfish3.1-final/glassfish]deployer:gfv3ee6:localhost:4848 + + + + \ No newline at end of file diff --git a/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/src/main/java/br/com/eletronlivre/webscheduler/TesteOSGi.java b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/src/main/java/br/com/eletronlivre/webscheduler/TesteOSGi.java new file mode 100644 index 0000000..eec4e4a --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/src/main/java/br/com/eletronlivre/webscheduler/TesteOSGi.java @@ -0,0 +1,84 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.eletronlivre.webscheduler; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author vsenger + */ +@WebServlet(name = "TesteOSGi", urlPatterns = {"/TesteOSGi"}) +public class TesteOSGi extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST methods. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + PrintWriter out = response.getWriter(); + try { + /* TODO output your page here + out.println(""); + out.println(""); + out.println("Servlet TesteOSGi"); + out.println(""); + out.println(""); + out.println("

Servlet TesteOSGi at " + request.getContextPath () + "

"); + out.println(""); + out.println(""); + */ + } finally { + out.close(); + } + } + + // + /** + * Handles the HTTP GET method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/src/main/webapp/WEB-INF/sun-web.xml b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/src/main/webapp/WEB-INF/sun-web.xml new file mode 100644 index 0000000..7ea918d --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/src/main/webapp/WEB-INF/sun-web.xml @@ -0,0 +1,11 @@ + + + + /WebScheduler + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/src/main/webapp/index.jsp b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/src/main/webapp/index.jsp new file mode 100644 index 0000000..ab292c3 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/src/main/webapp/index.jsp @@ -0,0 +1,13 @@ +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + JSP Page + + +

Hello World!

+ + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/target/WebScheduler/WEB-INF/sun-web.xml b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/target/WebScheduler/WEB-INF/sun-web.xml new file mode 100644 index 0000000..7ea918d --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/target/WebScheduler/WEB-INF/sun-web.xml @@ -0,0 +1,11 @@ + + + + /WebScheduler + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/target/WebScheduler/index.jsp b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/target/WebScheduler/index.jsp new file mode 100644 index 0000000..ab292c3 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/target/WebScheduler/index.jsp @@ -0,0 +1,13 @@ +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + JSP Page + + +

Hello World!

+ + diff --git a/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/target/maven-archiver/pom.properties b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/target/maven-archiver/pom.properties new file mode 100644 index 0000000..5854004 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Fri May 13 17:51:54 BRT 2011 +version=1.0-SNAPSHOT +groupId=br.com.eletronlivre.webscheduler +artifactId=WebScheduler diff --git a/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/target/war/work/webapp-cache.xml b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/target/war/work/webapp-cache.xml new file mode 100644 index 0000000..e928c35 --- /dev/null +++ b/arduino/all the sketchs of my life/JavaEEArduino/WebScheduler/target/war/work/webapp-cache.xml @@ -0,0 +1,51 @@ + + + + currentBuild + + + index.jsp + WEB-INF/sun-web.xml + WEB-INF/classes/br/com/eletronlivre/webscheduler/TesteOSGi.class + WEB-INF/lib/ArduinoService-1.0-SNAPSHOT.jar + + + + + + + + javax + javaee-web-api + 6.0 + jar + provided + + false + + + + + junit + junit + 3.8.2 + jar + test + + false + + + + + br.com.eletronlivre.arduino + ArduinoService + 1.0-SNAPSHOT + jar + compile + + false + + ArduinoService-1.0-SNAPSHOT.jar + + + \ No newline at end of file diff --git a/arduino/all the sketchs of my life/MMA7455/MMA7455.pde b/arduino/all the sketchs of my life/MMA7455/MMA7455.pde new file mode 100644 index 0000000..3a0bab1 --- /dev/null +++ b/arduino/all the sketchs of my life/MMA7455/MMA7455.pde @@ -0,0 +1,89 @@ +/* + Accelerometer + + A Program which takes input from an accelerometer and outputs the + data to the serial port + + Hardware: Parallax MMA7455 + Concept Usage: Games controller + */ + +#include + +#define ACCELEROMETER 0x1D //Address for Accelerometer + +//REGISTERS +#define MODE_CONTROL 0x16 //Mode control register +#define PULSE_DET 0x1B //Pulse detection threshold limit value +#define X_OUT 0x06 //8 bit register containing value for X +#define Y_OUT 0x07 //8 bit register containing value for Y +#define Z_OUT 0x08 //8 bit register containing value for Z +#define DETECTION 0x0A //Detection source register + +//VALUES +#define Z_PULSE 0x40 //Pulse detected on Z-axis +#define SENSEVALUE 0x25 //Default sensitivity level + +//required setup function +void setup() { + Wire.begin(); + Serial.begin(9600); + accWrite(MODE_CONTROL, SENSEVALUE); +} + +void loop() { + int eixoX = (int)accRead(X_OUT); + Serial.print("X:"); + Serial.println(eixoX); + Serial.print("Angulo X:"); + Serial.println(eixoXparaAngulo); + + //Serial.print("Y:"); + //Serial.println((unsigned int)accRead(Y_OUT)); + //Serial.print("Z:"); + //Serial.println((unsigned int)accRead(Z_OUT)); + delay(100); +} + +//function to write byte data into a register +void accWrite(byte address, byte data) { + Wire.beginTransmission(ACCELEROMETER); + Wire.send(address); + Wire.send(data); + Wire.endTransmission(); +} + +//function to read byte data from a register +byte accRead(byte address){ + byte val = 0x00; + Wire.beginTransmission(ACCELEROMETER); + Wire.send(address); + Wire.endTransmission(); + Wire.requestFrom(ACCELEROMETER, 1); + if(Wire.available() > 0) { + val = Wire.receive(); + } + Wire.endTransmission(); + return val; +} + +byte eixoXparaAngulo(int valor) { + if(valor>=190 && valor<=255) { + return map(valor,255,190,0,90); + } + else if(valor>=0 && valor<=64) { + return map(valor,0,64,0,-90); + } +} + +//SOBRE O EIXO X - vertical +// frente ele vai de 255 at 190 e depois 190 ate 255 +// tras ele vai de 0 a 64 + +//SOBRE O EIXO X - horizontal +// plano 233, inclinando para esquerda 172 +// plano 233, inclinando para direita 255, 0, 46 + +//SOBRE O EIXO Z - + + diff --git a/arduino/all the sketchs of my life/Motores/MotorPassoBipolar/MotorPassoBipolar.pde b/arduino/all the sketchs of my life/Motores/MotorPassoBipolar/MotorPassoBipolar.pde new file mode 100644 index 0000000..8d4e3df --- /dev/null +++ b/arduino/all the sketchs of my life/Motores/MotorPassoBipolar/MotorPassoBipolar.pde @@ -0,0 +1,66 @@ +#define MOTOR1_P 3 +#define MOTOR1_N 4 +#define MOTOR1_PWM 5 + +#define MOTOR2_P 7 +#define MOTOR2_N 8 +#define MOTOR2_PWM 6 + +void setup() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + + digitalWrite(MOTOR1_PWM, HIGH); + + digitalWrite(MOTOR2_PWM, HIGH); +} + +void loop() { + step1(); + + delay(2); + + step2(); + + delay(2); + + step3(); + + delay(2); + + step4(); + + delay(2); + + +} +void step1() { + digitalWrite(MOTOR1_P, HIGH); + digitalWrite(MOTOR2_P, HIGH); + digitalWrite(MOTOR1_N, LOW); + digitalWrite(MOTOR2_N, LOW); +} + +void step2() { + digitalWrite(MOTOR1_P, LOW); + digitalWrite(MOTOR2_P, HIGH); + digitalWrite(MOTOR1_N, HIGH); + digitalWrite(MOTOR2_N, LOW); +} + +void step3() { + digitalWrite(MOTOR1_P, LOW); + digitalWrite(MOTOR2_P, LOW); + digitalWrite(MOTOR1_N, HIGH); + digitalWrite(MOTOR2_N, HIGH); +} +void step4() { + digitalWrite(MOTOR1_P, HIGH); + digitalWrite(MOTOR2_P, LOW); + digitalWrite(MOTOR1_N, LOW); + digitalWrite(MOTOR2_N, HIGH); +} diff --git a/arduino/all the sketchs of my life/Motores/MotorPassoUnipolarWaveDrive/MotorPassoUnipolarWaveDrive.pde b/arduino/all the sketchs of my life/Motores/MotorPassoUnipolarWaveDrive/MotorPassoUnipolarWaveDrive.pde new file mode 100644 index 0000000..e47e49b --- /dev/null +++ b/arduino/all the sketchs of my life/Motores/MotorPassoUnipolarWaveDrive/MotorPassoUnipolarWaveDrive.pde @@ -0,0 +1,71 @@ +#define Q2 9 +#define Q3 6 +#define Q4 18 +#define Q5 17 +#define NUM_PASSOS 4 + +void setup() { + Serial.begin(9600); + pinMode(Q2, OUTPUT); + pinMode(Q3, OUTPUT); + pinMode(Q4, OUTPUT); + pinMode(Q5, OUTPUT); + escreve_motor(false,false,false,false); +} + +void loop(){ + Serial.println("passo 0"); + seleciona_passo(0); + delay(50); + + Serial.println("passo 1"); + seleciona_passo(1); + delay(50); + Serial.println("passo 2"); + seleciona_passo(2); + delay(50); + Serial.println("passo 3"); + seleciona_passo(3); + delay(50); + + +} +void escreve_motor (boolean b_q2, boolean b_q3, boolean b_q4, boolean b_q5) { + digitalWrite(Q2, b_q2); + digitalWrite(Q3, b_q3); + digitalWrite(Q4, b_q4); + digitalWrite(Q5, b_q5); +} +void seleciona_passo (int passo){ + boolean b_q2, b_q3, b_q4, b_q5; + switch (passo) { + case 0: + b_q2 = true; + b_q3 = false; + b_q4 = false; + b_q5 = false; + break; + case 1: + b_q2 = false; + b_q3 = true; + b_q4 = false; + b_q5 = false; + break; + case 2: + b_q2 = false; + b_q3 = false; + b_q4 = true; + b_q5 = false; + break; + case 3: + b_q2 = false; + b_q3 = false; + b_q4 = false; + b_q5 = true; + break; + } + escreve_motor (b_q2, b_q3, b_q4, b_q5); +} + + + diff --git a/arduino/all the sketchs of my life/Motores/MotorPassoUnipolar_FullDrive/MotorPassoUnipolar_FullDrive.pde b/arduino/all the sketchs of my life/Motores/MotorPassoUnipolar_FullDrive/MotorPassoUnipolar_FullDrive.pde new file mode 100644 index 0000000..b184db7 --- /dev/null +++ b/arduino/all the sketchs of my life/Motores/MotorPassoUnipolar_FullDrive/MotorPassoUnipolar_FullDrive.pde @@ -0,0 +1,71 @@ +#define Q2 9 +#define Q3 6 +#define Q4 18 +#define Q5 17 +#define NUM_PASSOS 4 + +void setup() { + Serial.begin(9600); + pinMode(Q2, OUTPUT); + pinMode(Q3, OUTPUT); + pinMode(Q4, OUTPUT); + pinMode(Q5, OUTPUT); + escreve_motor(false,false,false,false); +} + +void loop(){ + Serial.println("passo 0"); + seleciona_passo(0); + delay(5); + + Serial.println("passo 1"); + seleciona_passo(1); + delay(5); + Serial.println("passo 2"); + seleciona_passo(2); + delay(5); + Serial.println("passo 3"); + seleciona_passo(3); + delay(5); + + +} +void escreve_motor (boolean b_q2, boolean b_q3, boolean b_q4, boolean b_q5) { + digitalWrite(Q2, b_q2); + digitalWrite(Q3, b_q3); + digitalWrite(Q4, b_q4); + digitalWrite(Q5, b_q5); +} +void seleciona_passo (int passo){ + boolean b_q2, b_q3, b_q4, b_q5; + switch (passo) { + case 0: + b_q2 = true; + b_q3 = false; + b_q4 = false; + b_q5 = true; + break; + case 1: + b_q2 = true; + b_q3 = false; + b_q4 = true; + b_q5 = false; + break; + case 2: + b_q2 = false; + b_q3 = true; + b_q4 = true; + b_q5 = false; + break; + case 3: + b_q2 = false; + b_q3 = true; + b_q4 = false; + b_q5 = true; + break; + } + escreve_motor (b_q2, b_q3, b_q4, b_q5); +} + + + diff --git a/arduino/all the sketchs of my life/Motores/StepperMotorUnipolar/StepperMotorUnipolar.pde b/arduino/all the sketchs of my life/Motores/StepperMotorUnipolar/StepperMotorUnipolar.pde new file mode 100644 index 0000000..3f0112e --- /dev/null +++ b/arduino/all the sketchs of my life/Motores/StepperMotorUnipolar/StepperMotorUnipolar.pde @@ -0,0 +1,71 @@ +#define Q2 9 +#define Q3 6 +#define Q4 18 +#define Q5 17 +#define NUM_PASSOS 4 + +void setup() { + Serial.begin(9600); + pinMode(Q2, OUTPUT); + pinMode(Q3, OUTPUT); + pinMode(Q4, OUTPUT); + pinMode(Q5, OUTPUT); + escreve_motor(false,false,false,false); +} + +void loop(){ + Serial.println("passo 0"); + seleciona_passo(0); + delay(10); + + Serial.println("passo 1"); + seleciona_passo(1); + delay(10); + Serial.println("passo 2"); + seleciona_passo(2); + delay(10); + Serial.println("passo 3"); + seleciona_passo(3); + delay(10); + + +} +void escreve_motor (boolean b_q2, boolean b_q3, boolean b_q4, boolean b_q5) { + digitalWrite(Q2, b_q2); + digitalWrite(Q3, b_q3); + digitalWrite(Q4, b_q4); + digitalWrite(Q5, b_q5); +} +void seleciona_passo (int passo){ + boolean b_q2, b_q3, b_q4, b_q5; + switch (passo) { + case 0: + b_q2 = true; + b_q3 = false; + b_q4 = false; + b_q5 = true; + break; + case 1: + b_q2 = true; + b_q3 = false; + b_q4 = true; + b_q5 = false; + break; + case 2: + b_q2 = false; + b_q3 = true; + b_q4 = true; + b_q5 = false; + break; + case 3: + b_q2 = false; + b_q3 = true; + b_q4 = false; + b_q5 = true; + break; + } + escreve_motor (b_q2, b_q3, b_q4, b_q5); +} + + + diff --git a/arduino/all the sketchs of my life/Multimodonamao/Multimodonamao.pde b/arduino/all the sketchs of my life/Multimodonamao/Multimodonamao.pde new file mode 100644 index 0000000..6625bb0 --- /dev/null +++ b/arduino/all the sketchs of my life/Multimodonamao/Multimodonamao.pde @@ -0,0 +1,31 @@ +#include + +void setup() +{ + Kernel.setup(); + Kernel.registerMode("blink"); + Kernel.registerTask(blinkLeds); + Kernel.registerMode("readSensor"); + Kernel.registerTask(blinkLeds); + Kernel.registerMode("playMusic"); + Kernel.registerTask(blinkLeds); + +} + +void loop() +{ + Kernel.loop; +} + +void blinkLeds() { + //... +} + +void readSensor() { + //... +} + +void playMusic() { + //... +} + diff --git a/arduino/all the sketchs of my life/PingParallax/PingParallax.ino b/arduino/all the sketchs of my life/PingParallax/PingParallax.ino new file mode 100644 index 0000000..a8c34ed --- /dev/null +++ b/arduino/all the sketchs of my life/PingParallax/PingParallax.ino @@ -0,0 +1,41 @@ +#define PING_PIN 14 +long duration, inches, cm; + +void setup() { + Serial.begin(9600); +} + +void loop() { + readPing(); + delay(500); +} +void readPing() +{ + + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + diff --git a/arduino/all the sketchs of my life/Pololu_Seguidor_Linha_Debug/Pololu_Seguidor_Linha_Debug.pde b/arduino/all the sketchs of my life/Pololu_Seguidor_Linha_Debug/Pololu_Seguidor_Linha_Debug.pde new file mode 100644 index 0000000..bf7778c --- /dev/null +++ b/arduino/all the sketchs of my life/Pololu_Seguidor_Linha_Debug/Pololu_Seguidor_Linha_Debug.pde @@ -0,0 +1,31 @@ +#include +#include + +#define NUM_SENSORS 3 // number of sensors used +#define TIMEOUT 2500 // waits for 2500 us for sensor outputs to go low +#define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2 + +unsigned int last_proportional = 0; +long integral = 0; + +// sensores 1 a 5 estao conectados nas portas digitais 5, 9, 2, 3 e 4, respectivamente +PololuQTRSensorsRC qtrrc((unsigned char[]) {2, 3, 4}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); +unsigned int sensorValues[NUM_SENSORS]; + +boolean calibrado = false; + +void setup(){ + Serial.begin(115200); + Serial.println("Heelooo"); + delay(20); +} + +void loop(){ + seguirLinha(); + delay(100); + + +} + + + diff --git a/arduino/all the sketchs of my life/Pololu_Seguidor_Linha_Debug/SeguidorLinha.pde b/arduino/all the sketchs of my life/Pololu_Seguidor_Linha_Debug/SeguidorLinha.pde new file mode 100644 index 0000000..469f443 --- /dev/null +++ b/arduino/all the sketchs of my life/Pololu_Seguidor_Linha_Debug/SeguidorLinha.pde @@ -0,0 +1,94 @@ +void calibrarSensorDeLinha() { + int i; + // Auto-calibration: turn right and left while calibrating the sensors. + for (i = 0; i < 155; i++) { // make the calibration take about 10 seconds + if (i < 40 || i > 110); + //setSpeeds(60, -60); + else; + //setSpeeds(-60, 60); + qtrrc.calibrate(); // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call) + } + //setSpeeds(0, 0); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMinimumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMaximumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + //Serial.println(); + calibrado=true; +} + +void seguirLinha() { + if(!calibrado) calibrarSensorDeLinha(); + unsigned int position = qtrrc.readLine(sensorValues); // Get the position of the line. + int proportional = (int)position - 2000;// The "proportional" term should be 0 when we are on the line. + //Serial.print("proportional: "); + //Serial.println(proportional); + int derivative = proportional - last_proportional; // Compute the derivative (change) of the position. + //Serial.print("derivative: "); + //Serial.println(derivative); + integral += proportional; // Compute the integral (sum) of the position. + //Serial.print("integral: "); + //Serial.println(integral); + last_proportional = proportional; // Remember the last position. + + // Compute the difference between the two motor power settings, + // m1 - m2. If this is a positive number the robot will turn + // to the right. If it is a negative number, the robot will + // turn to the left, and the magnitude of the number determines + // the sharpness of the turn. You can adjust the constants by which + // the proportional, integral, and derivative terms are multiplied to + // improve performance. + int power_difference = proportional/20 + integral/10000 + derivative*3/2; + + // Compute the actual motor settings. We never set either motor + // to a negative value. + const int maximum = 120; + if (power_difference > maximum) + power_difference = maximum; + if (power_difference < -maximum) + power_difference = -maximum; + // Serial.print("power diference: "); + // Serial.println(power_difference); + //setSpeeds(70,70); + if (power_difference < 0){ + //setSpeeds(maximum + power_difference, maximum); + // Serial.print("motores: "); + // Serial.println(maximum + power_difference); + // Serial.print(" : "); + // Serial.println(maximum); + } + else{ + //setSpeeds(maximum, maximum - power_difference); + // Serial.print("motores: "); + // Serial.print(maximum); + // Serial.print(" : "); + // Serial.println(maximum - power_difference); + // Serial.println(" "); + } + //Ler sensor distancia + //Se tiver objeto na frente, parar + //Andar um pouco pra traz + //Programacao do desvio de pista + + //delay(1000); + Serial.print("position: "); + Serial.println(position); + Serial.println("sensor values: "); + for(int x=0;x40) { + Serial.println("longe"); + } + else { + Serial.println("perto"); + digitalWrite(4, HIGH); + delay(100); + digitalWrite(4, LOW); + + } + delay(500); +} + + + diff --git a/arduino/all the sketchs of my life/ProgramMEV2/AvoidanceModo/AvoidanceModo.pde b/arduino/all the sketchs of my life/ProgramMEV2/AvoidanceModo/AvoidanceModo.pde new file mode 100644 index 0000000..af7b0ce --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2/AvoidanceModo/AvoidanceModo.pde @@ -0,0 +1,82 @@ +#include + +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +Servo servoV; +Servo servoH; +long distancia; +long distanciaEsquerda; +long distanciaDireita; + +void setup(){ + setupMotor(); + servoH.attach(5); + servoV.attach(6); + +} + +void loop() { + lerPing(); + + while(distancia>25) { + andarFrente(200,3); + lerPing(); + } + while(distancia>15 && distancia<25) { + parar(); + delay(200); + lerPingFull(); + if(distanciaEsquerda>distancia && distanciaEsquerda>distanciaDireita) { + girarNoEixo(300,2,1); + } + if(distanciaDireita>distancia && distanciaDireita>distanciaEsquerda) { + girarNoEixo(300,2,0); + } + lerPing(); + } + while(distancia>5 && distancia<15) { + parar(); + andarTraz(500,2); + girarNoEixo(500,2, random(10)%2==0); + lerPing(); + } + +} + + + + diff --git a/arduino/all the sketchs of my life/ProgramMEV2/AvoidanceModo/LibMotor.pde b/arduino/all the sketchs of my life/ProgramMEV2/AvoidanceModo/LibMotor.pde new file mode 100644 index 0000000..6720533 --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2/AvoidanceModo/LibMotor.pde @@ -0,0 +1,92 @@ +int sentido=0; + +void setupMotor() { + pinMode(MOTOR1_A, OUTPUT); + pinMode(MOTOR1_B, OUTPUT); + pinMode(MOTOR2_A, OUTPUT); + pinMode(MOTOR2_B, OUTPUT); +} + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido1); + digitalWrite(MOTOR1_B,!sentido1); + digitalWrite(MOTOR2_A,!sentido1); + digitalWrite(MOTOR2_B,sentido1); + delay(tempo); +} + + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); + digitalWrite(MOTOR1_A,0); + digitalWrite(MOTOR1_B,0); + digitalWrite(MOTOR2_A,0); + digitalWrite(MOTOR2_B,0); + +} +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_A,!sentido); + digitalWrite(MOTOR1_B,sentido); + digitalWrite(MOTOR2_A,!sentido); + digitalWrite(MOTOR2_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,!sentido); + digitalWrite(MOTOR1_B,sentido); + digitalWrite(MOTOR2_A,!sentido); + digitalWrite(MOTOR2_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/ProgramMEV2/AvoidanceModo/LibPing.pde b/arduino/all the sketchs of my life/ProgramMEV2/AvoidanceModo/LibPing.pde new file mode 100644 index 0000000..1d89b8b --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2/AvoidanceModo/LibPing.pde @@ -0,0 +1,28 @@ + +int lerPingComMedia() { + int d1,d2,d3; + d1 = analogRead(1); + delay(5); + d2 = analogRead(1); + delay(5); + d3 = analogRead(1); + delay(5); + return (d1 + d2 + d3)/3; +} + +void lerPing() { + distancia = lerPingComMedia(); +} +void lerPingFull() { + servoH.write(30); + delay(200); + distanciaEsquerda = lerPingComMedia(); + servoH.write(100); + delay(200); + distancia = lerPingComMedia(); + servoH.write(150); + delay(200); + distanciaDireita = lerPingComMedia(); + servoH.write(85); +} + diff --git a/arduino/all the sketchs of my life/ProgramMEV2/DemoDefault/DemoDefault.pde b/arduino/all the sketchs of my life/ProgramMEV2/DemoDefault/DemoDefault.pde new file mode 100644 index 0000000..9bcf736 --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2/DemoDefault/DemoDefault.pde @@ -0,0 +1,69 @@ +#include + + + +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +int leds[] = { + 13, 12, 8, 7, 4}; + +void setup() { + Serial.begin(9600); + for(int x=0;x<5;x++) { + pinMode(leds[x], OUTPUT); + } +} + + +void loop() { + + Serial.println("Sensor: "); + Serial.println(analogRead(SENSOR_LUZ)); + int numeroLedsALigar = map(analogRead(SENSOR_LUZ), 300, 900, 0, 4); + Serial.println(numeroLedsALigar); + for(int x=0;x<=numeroLedsALigar;x++) { + digitalWrite(leds[x], HIGH); + delay(100); + } + for(int x=numeroLedsALigar;x>-1;x--) { + digitalWrite(leds[x], LOW); + delay(100); + } +} + + + diff --git a/arduino/all the sketchs of my life/ProgramMEV2/DemoDefault_Kernel/DemoDefault_Kernel.pde b/arduino/all the sketchs of my life/ProgramMEV2/DemoDefault_Kernel/DemoDefault_Kernel.pde new file mode 100644 index 0000000..633d904 --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2/DemoDefault_Kernel/DemoDefault_Kernel.pde @@ -0,0 +1,104 @@ +#include + +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +int leds[] = { + 13, 12, 8, 7, 4}; + +void setup() { + Serial.begin(9600); + Kernel.setup(INTERRUPTION); + + Kernel.registerChangeModeListener(beep); + Kernel.registerMode("Modo 1", modo1_setup); + Kernel.registerTask(modo1_loop); + Kernel.registerMode("Modo 2", modo1_setup); + Kernel.registerTask(modo2_loop); + +} + +void beep() { + Serial.println("Mudou modo"); + pinMode(4, OUTPUT); + digitalWrite(4, HIGH); + delay(5); + digitalWrite(4, LOW); +} + +void modo1_setup() { + for(int x=0;x<5;x++) { + pinMode(leds[x], OUTPUT); + } +} + +void modo1_loop(){ + Serial.println("Sensor modo1 : "); + Serial.println(analogRead(SENSOR_LUZ)); + int numeroLedsALigar = map(analogRead(SENSOR_LUZ), 300, 900, 0, 4); + Serial.println(numeroLedsALigar); + + for(int x=0;x<=numeroLedsALigar;x++) { + digitalWrite(leds[x], HIGH); + Kernel.wait(100); + } + for(int x=numeroLedsALigar;x>-1;x--) { + digitalWrite(leds[x], LOW); + Kernel.wait(100); + } +} + +void modo2_loop(){ + Serial.println("Sensor modo 2: "); + Serial.println(analogRead(SENSOR_LUZ)); + int numeroLedsALigar = map(analogRead(SENSOR_LUZ), 300, 900, 0, 4); + Serial.println(numeroLedsALigar); + for(int x=numeroLedsALigar;x>=-1;x--) { + digitalWrite(leds[x], HIGH); + delay(100); + } + for(int x=0;x<=numeroLedsALigar;x++) { + digitalWrite(leds[x], LOW); + delay(100); + } +} + +void loop() { + Kernel.loop(); +} + + + diff --git a/arduino/all the sketchs of my life/ProgramMEV2/ExemploServo/ExemploServo.pde b/arduino/all the sketchs of my life/ProgramMEV2/ExemploServo/ExemploServo.pde new file mode 100644 index 0000000..44f5baa --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2/ExemploServo/ExemploServo.pde @@ -0,0 +1,22 @@ +#include + +Servo myservo1; // create servo object to control a servo + +void setup() +{ + myservo1.attach(5); // attaches the servo on pin 9 to the servo object + Serial.begin(9600); +} + +void loop() +{ + int distancia = analogRead(1); + Serial.println(distancia); + int posicaoServo = map(distancia, 10, 30, 1, 170); + myservo1.write(posicaoServo); + + + +} + + diff --git a/arduino/all the sketchs of my life/ProgramMEV2/LCD_I2C/LCD_I2C.pde b/arduino/all the sketchs of my life/ProgramMEV2/LCD_I2C/LCD_I2C.pde new file mode 100644 index 0000000..0173589 --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2/LCD_I2C/LCD_I2C.pde @@ -0,0 +1,16 @@ +#include +#include +LiquidCrystal_I2C lcd(0x27,16,2); + +void setup() { + lcd.init(); + lcd.backlight(); + lcd.setCursor(0, 1); + lcd.print("Program-ME v2"); + +} + + +void loop() {} + + diff --git a/arduino/all the sketchs of my life/ProgramMEV2/MotorComPonteH/LibMotor.ino b/arduino/all the sketchs of my life/ProgramMEV2/MotorComPonteH/LibMotor.ino new file mode 100644 index 0000000..6720533 --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2/MotorComPonteH/LibMotor.ino @@ -0,0 +1,92 @@ +int sentido=0; + +void setupMotor() { + pinMode(MOTOR1_A, OUTPUT); + pinMode(MOTOR1_B, OUTPUT); + pinMode(MOTOR2_A, OUTPUT); + pinMode(MOTOR2_B, OUTPUT); +} + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido1); + digitalWrite(MOTOR1_B,!sentido1); + digitalWrite(MOTOR2_A,!sentido1); + digitalWrite(MOTOR2_B,sentido1); + delay(tempo); +} + + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); + digitalWrite(MOTOR1_A,0); + digitalWrite(MOTOR1_B,0); + digitalWrite(MOTOR2_A,0); + digitalWrite(MOTOR2_B,0); + +} +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,sentido); + digitalWrite(MOTOR1_B,!sentido); + digitalWrite(MOTOR2_A,sentido); + digitalWrite(MOTOR2_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_A,!sentido); + digitalWrite(MOTOR1_B,sentido); + digitalWrite(MOTOR2_A,!sentido); + digitalWrite(MOTOR2_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_A,!sentido); + digitalWrite(MOTOR1_B,sentido); + digitalWrite(MOTOR2_A,!sentido); + digitalWrite(MOTOR2_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/ProgramMEV2/MotorComPonteH/MotorComPonteH.ino b/arduino/all the sketchs of my life/ProgramMEV2/MotorComPonteH/MotorComPonteH.ino new file mode 100644 index 0000000..e6e33c8 --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2/MotorComPonteH/MotorComPonteH.ino @@ -0,0 +1,61 @@ +#include + +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +Servo servoV; +Servo servoH; + +void setup(){ + setupMotor(); + servoH.attach(5); + servoV.attach(6); + +} + +void loop() { + andarFrente(1000,2); + parar(); + andarTraz(1000,2); + parar(); + girarNoEixo(1000,2,0); + parar(); + girarNoEixo(1000,2,1); + parar(); + return; +} + + diff --git a/arduino/all the sketchs of my life/ProgramMEV2/MotoresPWM/MotoresPWM.pde b/arduino/all the sketchs of my life/ProgramMEV2/MotoresPWM/MotoresPWM.pde new file mode 100644 index 0000000..9031897 --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2/MotoresPWM/MotoresPWM.pde @@ -0,0 +1,56 @@ +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +int leds[] = { + 13, 12, 8, 7, 4}; + +void setup() { + Serial.begin(9600); + for(int x=0;x<5;x++) { + pinMode(leds[x], OUTPUT); + } +} + + +void loop() { + int luz = analogRead(SENSOR_LUZ); + int val = map(luz, 700,1023,255, 0); + analogWrite(9, val); + +} + + + diff --git a/arduino/all the sketchs of my life/ProgramMEV2/PiscaLeds/PiscaLeds.pde b/arduino/all the sketchs of my life/ProgramMEV2/PiscaLeds/PiscaLeds.pde new file mode 100644 index 0000000..1afb3aa --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2/PiscaLeds/PiscaLeds.pde @@ -0,0 +1,18 @@ +int leds[] = { + 13, 12, 8, 7, 4}; + +void setup() { + Serial.begin(9600); + for(int x=0;x<5;x++) { + pinMode(leds[x], OUTPUT); + } +} + +void loop() { + for(int x=0;x<=4;x++) { + digitalWrite(leds[x], HIGH); + delay(100); + digitalWrite(leds[x], LOW); + delay(100); + } +} diff --git a/arduino/all the sketchs of my life/ProgramMEV2/Servo_LDR/Servo_LDR.pde b/arduino/all the sketchs of my life/ProgramMEV2/Servo_LDR/Servo_LDR.pde new file mode 100644 index 0000000..aa8991d --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2/Servo_LDR/Servo_LDR.pde @@ -0,0 +1,22 @@ +// Controlling a servo position using a potentiometer (variable resistor) +// by Michal Rinott + +#include + +Servo myservo; // create servo object to control a servo + +int potpin = 0; // analog pin used to connect the potentiometer +int val; // variable to read the value from the analog pin + +void setup() +{ + myservo.attach(5); // attaches the servo on pin 9 to the servo object +} + +void loop() +{ + val = analogRead(3); // reads the value of the potentiometer (value between 0 and 1023) + val = map(val, 700, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) + myservo.write(val); // sets the servo position according to the scaled value + delay(100); // waits for the servo to get there +} diff --git a/arduino/all the sketchs of my life/ProgramMEV2_Luz/ProgramMEV2_Luz.pde b/arduino/all the sketchs of my life/ProgramMEV2_Luz/ProgramMEV2_Luz.pde new file mode 100644 index 0000000..66a1b9d --- /dev/null +++ b/arduino/all the sketchs of my life/ProgramMEV2_Luz/ProgramMEV2_Luz.pde @@ -0,0 +1,65 @@ +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +int leds[] = { + 13, 12, 8, 7, 4}; + +void setup() { + Serial.begin(9600); + for(int x=0;x<5;x++) { + pinMode(leds[x], OUTPUT); + } +} + + +void loop() { + + Serial.println("Sensor: "); + Serial.println(analogRead(SENSOR_LUZ)); + int numeroLedsALigar = map(analogRead(SENSOR_LUZ), 300, 900, 0, 4); + Serial.println(numeroLedsALigar); + for(int x=0;x<=numeroLedsALigar;x++) { + digitalWrite(leds[x], HIGH); + delay(100); + } + for(int x=numeroLedsALigar;x>-1;x--) { + digitalWrite(leds[x], LOW); + delay(100); + } +} + + + diff --git a/arduino/all the sketchs of my life/Projetos/AHD_Serial1/AHD_Serial1.pde b/arduino/all the sketchs of my life/Projetos/AHD_Serial1/AHD_Serial1.pde new file mode 100644 index 0000000..60140d3 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/AHD_Serial1/AHD_Serial1.pde @@ -0,0 +1,32 @@ +int leds[] = {14,1,2,3,4,5,8,6,13}; +int ledsStatus[9]; + +void setup() { + Serial.begin(9600); + for(int x=0;x<10;x++){ + ledsStatus[x]=0; + pinMode(leds[x], OUTPUT); + + } + +} + +void loop() { + if(Serial.available()>0) + { + lerSerial(); + } +} + +void lerSerial() { + while(Serial.available()>0) { + byte incoming = Serial.read(); + delay(20); + ledsStatus[incoming] = !ledsStatus[incoming]; + digitalWrite(leds[incoming], ledsStatus[incoming]); + + } +} + + + diff --git a/arduino/all the sketchs of my life/Projetos/ALM/ALM.pde b/arduino/all the sketchs of my life/Projetos/ALM/ALM.pde new file mode 100644 index 0000000..03e7715 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ALM/ALM.pde @@ -0,0 +1,16 @@ +void setup() { + Serial.begin(9600); + pinMode(7, OUTPUT); +} + +void loop() { + if(Serial.available() >0) { + byte incoming=Serial.read(); + if(incoming==65) { + digitalWrite(7, HIGH); + delay(5000); + digitalWrite(7, LOW); + } + } +} + diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/ArduinoSunSpotV2.pde b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/ArduinoSunSpotV2.pde new file mode 100644 index 0000000..cf12436 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/ArduinoSunSpotV2.pde @@ -0,0 +1,73 @@ +#include + +#define MOTOR1_P 4 +#define MOTOR1_N 5 +#define MOTOR1_PWM 11 + +#define MOTOR2_P 6 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 9 +#define SERVO_H 10 +#define SERVO_V 11 + +#define MODE_BUTTON 19 //5 anal�gica lida como digital... + +#define MODE_DEMO 2 +#define MODE_WALK 3 +#define MODE_SUNSPOT 1 +#define MODE_STOP 0 +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=0; +Servo servoHorizontal; // create servo object to control a servo +Servo servoVertical; // create servo object to control a servo + + +void setup() { + setupEngines(); + setupSunSpot(); + servoHorizontal.attach(SERVO_H); + //servoVertical.attach(SERVO_V); + Serial.begin(9600); +} + + +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + +} + +void loop(){ + + if(digitalRead(MODE_BUTTON)==0) { + while(digitalRead(MODE_BUTTON)==0); + mode++; + if(mode==4) mode=0; + } + if(mode==MODE_DEMO) { + Demo(); + } + else if(mode==MODE_WALK) { + Walk(); + } + else if(mode==MODE_SUNSPOT) { + SunSpot(); + } + +} + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/Demo.pde b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/Demo.pde new file mode 100644 index 0000000..3da8371 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/Demo.pde @@ -0,0 +1,195 @@ +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); +3145-2230 + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/SunSpot.pde b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/SunSpot.pde new file mode 100644 index 0000000..9623884 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/SunSpot.pde @@ -0,0 +1,118 @@ +#define SUN_SPOT 8 +#define SUN_SPOT_ACK 12 +#define SUN_SPOT_INTERRUPT 0 //PORTA digital 2 + +volatile int data; +volatile boolean bit_array[16]; +volatile int contador; +int x; +int y; + +void SunSpot() { + if(x==0 && y==0) { + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + } + if(x==100 && y==100) { + digitalWrite(9, HIGH); + delay(500); + digitalWrite(9, LOW); + delay(200); + return; + } + if(x==101) { + changeServo(y); + delay(200); + return; + } + + if(y>0) sentido = 0; //Para FRENTE + else if(y<0) sentido = 1;// Para Traz + //Configurando o sentido do trem.. quero dizer do robot + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + if(y!=0 && x!=0) { //Curva frente ou traz... + int coeficientePotencia = map(x<0 ? x*-1 : x,0,30,0,255); + analogWrite(MOTOR1_PWM, x< 0 ? coeficientePotencia : coeficientePotencia/2); + analogWrite(MOTOR2_PWM, x< 0 ? coeficientePotencia/2 : coeficientePotencia); + } + else { //reto + analogWrite(MOTOR1_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + analogWrite(MOTOR2_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + } + //Girando no eixo + if(y==0 && x!=0) { + sentido = x<0; + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_N,sentido); + if(x>0) { + Serial.print("Girando x>0"); + Serial.println(map(x,0,30,40,255)); + analogWrite(MOTOR1_PWM, map(x,0,30,40,255) ); + analogWrite(MOTOR2_PWM , map(x,0,30,40,255) ); + } + else { + Serial.print("Girando <0"); + Serial.println(map(x>0 ? x : x*-1,0,30,40,255)); + + analogWrite(MOTOR2_PWM, map(x*-1,0,30,40,255) ); + analogWrite(MOTOR1_PWM, map(x*-1,0,30,40,255) ); + } + } + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + delay(200); +} +void setupSunSpot() { + attachInterrupt(0, receiveSunSpot, RISING); + pinMode(SUN_SPOT,INPUT); + pinMode(SUN_SPOT_ACK,OUTPUT); +} + +void receiveSunSpot() { + digitalWrite(SUN_SPOT_ACK,LOW); + bit_array[contador++]=digitalRead(SUN_SPOT); + digitalWrite(SUN_SPOT_ACK,HIGH); + if(contador==16) { + Serial.println("Chegou Novos 2 bytes"); + contador=0; + x = BtoI(0,7,bit_array); + + y = BtoI(8,15,bit_array); + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + for(int clean=0;clean<16;clean++) bit_array[clean]=false; + + } +} + +int BtoI(int start,int end, volatile boolean bits[]){ + boolean negative=bits[start]; + start++; + unsigned long integer=0; + unsigned long mask=1; + int r; + for (int i = end; i >= start; i--) { + if(negative) { + if (!bits[i]) integer |= mask; + } + else { + if (bits[i]) integer |= mask; + } + mask = mask << 1; + } + r = (int) integer; + if(negative) r= ~r; + return r; +} diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/Walk.pde b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/Walk.pde new file mode 100644 index 0000000..b141bbe --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/Walk.pde @@ -0,0 +1,277 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServo(int servoPos) { + servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.cpp b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.cpp new file mode 100644 index 0000000..8c6a8f5 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.cpp @@ -0,0 +1,648 @@ +#include + +#define MOTOR1_P 4 +#define MOTOR1_N 5 +#define MOTOR1_PWM 11 + +#define MOTOR2_P 6 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 13 +#define SERVO_1 10 +#define MODE_BUTTON 19 //5 anal\u00f3gica lida como digital... + +#define MODE_DEMO 3 +#define MODE_WALK 2 +#define MODE_SUNSPOT 1 +#define MODE_STOP 0 +#include "WProgram.h" +void setup(); +void setupEngines(); +void loop(); +void Demo(); +void SunSpot(); +void setupSunSpot(); +void receiveSunSpot(); +int BtoI(int start,int end, volatile boolean bits[]); +void changeServo(int servoPos); +void fullScan(); +byte getLongestPosition(); +void partialScan(); +void Walk(); +void processPing(); +void girarNoEixo(int tempo, int intensidade, int sentido1); +void readPress(); +void parar(); +void andarFrente(int tempo, int intensidade); +void andarTraz(int tempo,int intensidade); +void virarEsquerda(int tempo,int intensidade); +void virarDireita(int tempo,int intensidade); +void readPing(); +long microsecondsToInches(long microseconds); +long microsecondsToCentimeters(long microseconds); +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=0; +Servo myservo10; // create servo object to control a servo + + +void setup() { + setupEngines(); + setupSunSpot(); + myservo10.attach(10); // attaches the servo on pin 10 to the servo object + Serial.begin(9600); +} +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void loop(){ + if(digitalRead(MODE_BUTTON)==0) { + while(digitalRead(MODE_BUTTON)==0); + mode++; + if(mode==4) mode=0; + } + if(mode==MODE_DEMO) { + Demo(); + } + else if(mode==MODE_WALK) { + Walk(); + } + else if(mode==MODE_SUNSPOT) { + SunSpot(); + } + +} + + + +/* + if(y>0) { + sentido = 1; + analogWrite(MOTOR1_PWM,(y == 10 ? 85 : y==20 ? 170 : 255)); + analogWrite(MOTOR2_PWM,(y == 10 ? 85 : y==20 ? 170 : 255)); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + } + else if(y<0){ //para traz + sentido = 0; + analogWrite(MOTOR1_PWM,(y == -10 ? 85 : y==-20 ? 170 : 255)); + analogWrite(MOTOR2_PWM,(y == -10 ? 85 : y==-20 ? 170 : 255)); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + } + */ + +/* + + + */ + + + +/* +1.5' 3.2' + C E Am + Fa\u00e7o c\u00f3digo como c\u00e3o;Maldito bug, que n\u00e3o encontro n\u00e3o; + 5.5' 8' com breque + Vem o prazo e o chef\u00e3o, o redeploy n\u00e3o da certo n\u00c3o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc\u00ea come\u00e7a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J\u00e1 estou penando aqui + 38' 41' + C E Am + Fa\u00e7o o download de um jar grand\u00e3o, mas tamb\u00e9m n\u00e3o 42' + funciona n\u00e3o + 43' 45' 48' + Chamo o arquiteto bacan\u00e3o, mas no fundo \u00e9 um man\u00e9z\u00e3o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N\u00e3o me sinto up-to-date, eu estou \u00e9 \u201cdeprecate\u201d + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa\u00e7o c\u00f3digo como c\u00e3o;Maldito bug, que n\u00e3o encontro n\u00e3o; + 5.5' 8' com breque + Vem o prazo e o chef\u00e3o, o redeploy n\u00e3o da certo n\u00c3o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc\u00ea come\u00e7a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb\u00e9m n\u00e3o funciona n\u00e3o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo \u00e9 um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + + +#define SUN_SPOT 8 +#define SUN_SPOT_ACK 12 +#define SUN_SPOT_INTERRUPT 0 //PORTA digital 2 + +volatile int data; +volatile boolean bit_array[16]; +volatile int contador; +int x; +int y; + +void SunSpot() { + if(x==0 && y==0) { + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + } + if(y>0) sentido = 0; //Para FRENTE + else if(y<0) sentido = 1;// Para Traz + //Configurando o sentido do trem.. quero dizer do robot + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + if(y!=0 && x!=0) { //Curva frente ou traz... + int coeficientePotencia = map(x<0 ? x*-1 : x,0,30,0,255); + analogWrite(MOTOR1_PWM, x< 0 ? coeficientePotencia : coeficientePotencia/2); + analogWrite(MOTOR2_PWM, x< 0 ? coeficientePotencia/2 : coeficientePotencia); + } + else { //reto + analogWrite(MOTOR1_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + analogWrite(MOTOR2_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + } + //Girando no eixo + if(y==0 && x!=0) { + sentido = x<0; + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_N,sentido); + if(x>0) { + Serial.print("Girando x>0"); + Serial.println(map(x,0,30,40,255)); + analogWrite(MOTOR1_PWM, map(x,0,30,40,255) ); + analogWrite(MOTOR2_PWM , map(x,0,30,40,255) ); + } + else { + Serial.print("Girando <0"); + Serial.println(map(x>0 ? x : x*-1,0,30,40,255)); + + analogWrite(MOTOR2_PWM, map(x*-1,0,30,40,255) ); + analogWrite(MOTOR1_PWM, map(x*-1,0,30,40,255) ); + } + } + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + delay(200); +} +void setupSunSpot() { + attachInterrupt(0, receiveSunSpot, RISING); + pinMode(SUN_SPOT,INPUT); + pinMode(SUN_SPOT_ACK,OUTPUT); +} + +void receiveSunSpot() { + digitalWrite(SUN_SPOT_ACK,LOW); + bit_array[contador++]=digitalRead(SUN_SPOT); + digitalWrite(SUN_SPOT_ACK,HIGH); + if(contador==16) { + Serial.println("Chegou Novos 2 bytes"); + contador=0; + x = BtoI(0,7,bit_array); + + y = BtoI(8,15,bit_array); + + for(int clean=0;clean<16;clean++) bit_array[clean]=false; + + } +} + +int BtoI(int start,int end, volatile boolean bits[]){ + boolean negative=bits[start]; + start++; + unsigned long integer=0; + unsigned long mask=1; + int r; + for (int i = end; i >= start; i--) { + if(negative) { + if (!bits[i]) integer |= mask; + } + else { + if (bits[i]) integer |= mask; + } + mask = mask << 1; + } + r = (int) integer; + if(negative) r= ~r; + return r; +} + +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int move_count = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + readPing(); + processPing(); + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,50*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.cpp.o b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.cpp.o new file mode 100644 index 0000000..1b1deed Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.cpp.o differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.eep b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.elf b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.elf new file mode 100644 index 0000000..ce28498 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.elf differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.hex b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.hex new file mode 100644 index 0000000..8d91bec --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.hex @@ -0,0 +1,560 @@ +:100000000C9463000C942C0D0C94590D0C948B00E3 +:100010000C948B000C948B000C948B000C948B0034 +:100020000C948B000C948B000C948B000C948B0024 +:100030000C948B000C948B000C948B000C948B0014 +:100040000C94860D0C948B000C94050B0C948B0077 +:100050000C948B000C948B000C948B000C948B00F4 +:100060000C948B000C948B000000000024002700EF +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000E901BE0B11241FBECFEFD4E0DEBF5C +:1000D000CDBF11E0A0E0B1E0E2E9F2E202C005909C +:1000E0000D92AC34B107D9F712E0ACE4B1E001C035 +:1000F0001D92A032B107E1F710E0C6ECD0E004C0D9 +:100100002297FE010E940C11C23CD107C9F70E9440 +:10011000FE0A0C9447110C940000A0E0B0E0E3E963 +:10012000F0E00C941811EC01A880B980CA80DB8043 +:10013000A114B104C104D10441F484E2A82E89EDD4 +:10014000B82E8BE5C82E87E0D82EC601B5012DE16B +:1001500033EF41E050E00E94DB1027EA31E440E059 +:1001600050E00E9487107B018C01C601B5012DE192 +:1001700033EF41E050E00E94DB10CA01B9012CEEE0 +:1001800034EF4FEF5FEF0E9487106E0D7F1D801FD1 +:10019000911F97FF04C06150704080409048688371 +:1001A00079838A839B839B01AC015F77B901CA0184 +:1001B000CDB7DEB7EAE00C9434110E948D000895AB +:1001C00081E491E00E948D00089560934101709355 +:1001D000420180934301909344010895FC011082F1 +:1001E0008FEF81830895EF92FF920F931F93CF9328 +:1001F000DF93EC019B0177FF03C020E030E005C0F6 +:10020000653B710514F024EB30E02983EA806B81B3 +:1002100070E06E197109882777FD8095982F982FC7 +:10022000872F762F662730E040E050E00E9487104D +:1002300024EB30E040E050E00E94DB10FF2400E0BF +:1002400010E0102F0F2DFE2CEE24E20EF31E041FE3 +:10025000151FC801B70128E030E040E050E00E94DF +:10026000DB108881893029F430938900209388003D +:1002700006C08A3021F430938B0020938A00DF91EE +:10028000CF911F910F91FF90EF900895CF93DF933F +:10029000EC01FB01CB010997029710F080E054C0FC +:1002A000CA0160E170E00E94A6106A83C90160E1A2 +:1002B00070E00E94A6106B83E8838FEF89838E2FF6 +:1002C00060E00E94E10E888161E00E94C10E809191 +:1002D0004C01882311F580914D018823F1F42FB74B +:1002E000F89482E0809380008AE18093810088EB1B +:1002F0009BE0909389008093880090938B0080937B +:100300008A0080E49CE99093870080938600809126 +:100310006F00887F80936F002FBF8881893041F400 +:1003200081E080934C01809180008F73806809C0C8 +:100330008A3049F481E080934D01809180008F7C68 +:1003400080628093800081E0DF91CF91089540E248 +:1003500052E020E639E00E9446010895EF92FF92B4 +:100360000F931F93CF93DF93EC01FA01E80FF91F6E +:10037000E081DA01A60FB71F20E030E040E050E056 +:1003800091E0E92EF12C012D112D14C0EE2321F066 +:100390008C91882341F403C08C91882321F02E296D +:1003A0003F29402B512BEE0CFF1C001F111F6150E9 +:1003B00070401197C617D7074CF3EE2311F0209524 +:1003C0003095C901DF91CF911F910F91FF90EF9070 +:1003D00008958EE591E00E94EE00089584E061E0CA +:1003E0000E94C10E85E061E00E94C10E86E061E0DE +:1003F0000E94C10E87E061E00E94C10E8BE061E0C7 +:100400000E94C10E83E061E00E94C10E0895EF9248 +:10041000FF920F931F938DE061E00E94C10E8DE06B +:1004200060E00E94E10E82E090E00E94200E8DE0EC +:1004300061E00E94E10E85E090E00E94200E8DE0D8 +:1004400060E00E94E10E8DE060E00E94C10E8DE050 +:1004500061E020E432E44FE050E00E947D0F162F6F +:10046000072FF82EE92E609350017093510180936D +:1004700052019093530124E930E040E050E00E94A3 +:10048000DB10209354013093550140935601509353 +:100490005701612F702F8F2D9E2D2AE330E040E011 +:1004A00050E00E94DB10BA012093580130935901AB +:1004B00040935A0170935B018EEF91E0A9010E9475 +:1004C000EE0C1F910F91FF90EF9008958BE060E08C +:1004D00070E00E94680E83E060E070E00E94680EA9 +:1004E00008950F931F93CF93DF93EC018B01660F59 +:1004F000771FC80123E0880F991F2A95E1F7680F3D +:10050000791F8BE00E94680E82E390E0089FB001A3 +:10051000099F700D189F700D112483E00E94680ED2 +:1005200084E060914E010E94E10E60E080914E01F6 +:1005300090914F01892B09F461E085E00E94E10E62 +:1005400086E060914E010E94E10E60E080914E01D4 +:1005500090914F01892B09F461E087E00E94E10E40 +:10056000BE01882777FD8095982F0E94F60DDF91B8 +:10057000CF911F910F9108950F931F93CF93DF9306 +:10058000EC0182E390E0689F8001699F100D789FE5 +:10059000100D11248BE0B8010E94680E83E0B801B1 +:1005A0000E94680E84E060914E010E94E10E60E0BE +:1005B00080914E0190914F01892B09F461E085E013 +:1005C0000E94E10E86E060914E010E94E10E60E023 +:1005D00080914E0190914F01892B09F461E087E0F1 +:1005E0000E94E10EBE01882777FD8095982F0E941A +:1005F000F60DDF91CF911F910F9108950F931F93E7 +:10060000CF93DF93EC0181E090E090934F018093D2 +:100610004E0182E390E0689F8001699F100D789FF2 +:10062000100D11248BE0B8010E94680E83E0B80120 +:100630000E94680E84E060914E010E94E10E60E02D +:1006400080914E0190914F01892B09F461E085E082 +:100650000E94E10E86E060914E010E94E10E60E092 +:1006600080914E0190914F01892B09F461E087E060 +:100670000E94E10EBE01882777FD8095982F0E9489 +:10068000F60DDF91CF911F910F9108950F931F9356 +:10069000CF93DF93EC0110924F0110924E0182E351 +:1006A00090E0689F8001699F100D789F100D1124C4 +:1006B0008BE0B8010E94680E83E0B8010E94680ECA +:1006C00084E060914E010E94E10E60E080914E0155 +:1006D00090914F01892B09F461E085E00E94E10EC1 +:1006E00086E060914E010E94E10E60E080914E0133 +:1006F00090914F01892B09F461E087E00E94E10E9F +:10070000BE01882777FD8095982F0E94F60DDF9116 +:10071000CF911F910F910895EF92FF920F931F9326 +:10072000CF93DF93EC017A0182E390E0689F800130 +:10073000699F100D789F100D11248BE0B8010E9465 +:10074000680E83E0B8010E94680E1E2D84E06E2DB5 +:100750000E94E10E00E0EF2809F401E085E0602F3F +:100760000E94E10E86E0602F0E94E10E87E0612F7B +:100770000E94E10EBE01882777FD8095982F0E9488 +:10078000F60DDF91CF911F910F91FF90EF9008959B +:10079000EF92FF920F931F93CF93DF932091580115 +:1007A0003091590140915A0150915B01243131053A +:1007B000410551050CF099C0109279011092780111 +:1007C0000E946602C0E0D0E08091580190915901EA +:1007D000A0915A01B0915B014497A105B1050CF0BD +:1007E00064C1CA30D10511F1219668EC70E080E057 +:1007F00090E024EF31E040E050E00E9469107B017E +:100800008C0160E070E080E090E021E030E040E0CA +:1008100050E00E9469109B01AC01C70163E070E0E9 +:10082000A9010E948C030E940702CECF81E090E0D4 +:1008300063E070E00E94FE0260E070E080E090E023 +:1008400021E030E040E050E00E9469106115710540 +:100850008105910529F168EC70E080E090E020E9E5 +:1008600031E040E050E00E9469109B01AC0164EF70 +:1008700071E080E090E00E9469107B018C0162E0F1 +:1008800070E080E090E024E030E040E050E00E9442 +:1008900069109B01AC01C701B9010E94710205C139 +:1008A00068EC70E080E090E020E931E040E050E06A +:1008B0000E9469109B01AC0164EF71E080E090E060 +:1008C0000E9469107B018C0162E070E080E090E0A2 +:1008D00024E030E040E050E00E9469109B01AC0150 +:1008E000C701B9010E94BC02E0C0DA01C901459705 +:1008F000A109B1094897A105B10508F0B3C060E0AE +:1009000070E080E090E021E030E040E050E00E94C4 +:100910006910611571058105910509F454C062E300 +:1009200070E080E090E028E730E040E050E00E9496 +:1009300069107B018C0162E070E080E090E024E0CF +:1009400030E040E050E00E9469109B01AC01C7011B +:10095000B9010E947102C0915801D09159010E94C1 +:1009600007029E01442737FD4095542F809158017E +:1009700090915901A0915A01B0915B012817390754 +:100980004A075B076CF091C082E390E062E070E0A0 +:100990000E947102C0915801D09159010E94070232 +:1009A0009E01442737FD4095542F80915801909126 +:1009B0005901A0915A01B0915B01281739074A07E4 +:1009C0005B0714F372C062E370E080E090E028E718 +:1009D00030E040E050E00E9469107B018C0162E051 +:1009E00070E080E090E024E030E040E050E00E94E1 +:1009F00069109B01AC01C701B9010E94BC022091A2 +:100A000058013091590140915A0150915B01E9011F +:100A1000C901AA2797FDA095BA2F82179307A407AB +:100A2000B5076CF042C082E390E062E070E00E94A3 +:100A3000BC02C0915801D09159010E9407029E0149 +:100A4000442737FD4095542F8091580190915901CA +:100A5000A0915A01B0915B01281739074A075B073B +:100A600014F323C0809178019091790101969093BD +:100A700079018093780124363105410551051CF434 +:100A800062E070E00EC025563040404050402133B7 +:100A900031054105510518F064E070E002C063E0E3 +:100AA00070E082E390E00E9446038091780190918B +:100AB00079014F970CF46CC0109279011092780173 +:100AC00066E970E080E090E022EC31E040E050E048 +:100AD0000E946910DC01CB0163E070E00E94FE021D +:100AE00060E070E080E090E021E030E040E050E045 +:100AF0000E946910611571058105910529F168EC65 +:100B000070E080E090E020E931E040E050E00E94B9 +:100B100069109B01AC0166E970E080E090E00E9402 +:100B200069107B018C0162E070E080E090E024E0DD +:100B300030E040E050E00E9469109B01AC01C70129 +:100B4000B9010E94710224C068EC70E080E090E07E +:100B500020E931E040E050E00E9469109B01AC01C7 +:100B600066E970E080E090E00E9469107B018C01F2 +:100B700062E070E080E090E024E030E040E050E0AF +:100B80000E9469109B01AC01C701B9010E94BC021F +:100B9000DF91CF911F910F91FF90EF9008950E94E8 +:100BA00007020E94C8030895BC018EE591E00E94EF +:100BB000F3006FE070E080E090E00E94F60D089591 +:100BC0006CED75E080E090E00E94F60D84EA96E01E +:100BD00064E070E00E9446038CEF98E064E070E00F +:100BE0000E94FE0280ED97E063E070E041E050E09B +:100BF0000E948C038CED95E064E070E00E94FE02A0 +:100C00000E9466026CED75E080E090E00E94F60DB7 +:100C100084EB90E00E94D40568EE73E080E090E001 +:100C20000E94F60D8AE590E00E94D40568EE73E01C +:100C300080E090E00E94F60D80E090E00E94D405F4 +:100C400068EE73E080E090E00E94F60D8AE590E0A7 +:100C50000E94D40580ED97E064E070E00E944603B6 +:100C60000E94660284EB90E00E94D40568EE73E077 +:100C700080E090E00E94F60D80E090E00E94D405B4 +:100C800068EE73E080E090E00E94F60D8AE590E067 +:100C90000E94D40568EE73E080E090E00E94F60DBB +:100CA00088EB9BE063E070E041E050E00E948C0341 +:100CB0000E94660288EB9BE063E070E040E050E059 +:100CC0000E948C030E94660284EB90E00E94D4058F +:100CD00068EE73E080E090E00E94F60D8AE590E017 +:100CE0000E94D40568EE73E080E090E00E94F60D6B +:100CF00080E090E00E94D4058AE590E00E94D4054F +:100D000088EB9BE063E070E041E050E00E948C03E0 +:100D10000E94660288EB9BE063E070E040E050E0F8 +:100D20000E948C030E94660284EB90E00E94D4052E +:100D300064EF71E080E090E00E94F60D8AE590E0BB +:100D40000E94D40564EF71E080E090E00E94F60D0F +:100D500080E090E00E94D40568EE73E080E090E0CF +:100D60000E94F60D80ED97E063E070E00E9446037C +:100D70000E94660284EB90E00E94D40564EF71E06B +:100D800080E090E00E94F60D8AE590E00E94D40594 +:100D900064EF71E080E090E00E94F60D80E090E06A +:100DA0000E94D4056CED75E080E090E00E94F60DA5 +:100DB00084EA96E064E070E00E9446038CEF98E0DD +:100DC00064E070E00E94FE0280ED97E063E070E076 +:100DD00041E050E00E948C0380ED97E064E070E019 +:100DE0000E94FE020E94660260ED77E080E090E0E3 +:100DF0000E94F60D80ED97E063E070E040E050E087 +:100E00000E948C0384EB90E00E94D40568EE73E0AE +:100E100080E090E00E94F60D8AE590E00E94D40503 +:100E200068EE73E080E090E00E94F60D80E090E0D4 +:100E30000E94D40568EE73E080E090E00E94F60D19 +:100E40008AE590E00E94D40580ED97E063E070E0D1 +:100E500041E050E00E948C0384EB90E00E94D405B6 +:100E600064EF71E080E090E00E94F60D80E090E099 +:100E70000E94D40564EF71E080E090E00E94F60DDE +:100E80008AE590E00E94D40568EE73E080E090E08F +:100E90000E94F60D88EB9BE063E070E041E050E0DB +:100EA0000E948C030E94660288EB9BE063E070E086 +:100EB00040E050E00E948C030E94660284EB90E0C8 +:100EC0000E94D40568EE73E080E090E00E94F60D89 +:100ED0008AE590E00E94D40568EE73E080E090E03F +:100EE0000E94F60D80E090E00E94D4058AE590E033 +:100EF0000E94D40588EB9BE063E070E041E050E0A5 +:100F00000E948C030E94660288EB9BE063E070E025 +:100F100040E050E00E948C030E94660284EB90E067 +:100F20000E94D40564EF71E080E090E00E94F60D2D +:100F30008AE590E00E94D40564EF71E080E090E0E3 +:100F40000E94F60D80E090E00E94D40568EE73E008 +:100F500080E090E00E94F60D80ED97E063E070E0A5 +:100F60000E9446030E94660280ED97E063E070E015 +:100F70000E94FE020E94660284EB90E00E94D4056B +:100F800064EF71E080E090E00E94F60D8AE590E069 +:100F90000E94D40564EF71E080E090E00E94F60DBD +:100FA00080E090E00E94D40564EF71E080E090E082 +:100FB0000E94F60D8AE590E00E94D40560E072EC94 +:100FC0008BEE9BE00E94F60D08950F931F938CE02B +:100FD00060E00E94E10E009172011091730188E0BF +:100FE0000E942E0FF801EE59FE4F80830F5F1F4FB6 +:100FF00010937301009372018CE061E00E94E10E96 +:101000008091720190917301409761F58EEF91E0AC +:101010006BE071E00E94240C109273011092720137 +:1010200080E090E067E070E042E651E00E94AE01AF +:10103000909375018093740188E090E06FE070E018 +:1010400042E651E00E94AE019093770180937601D1 +:1010500080E090E0FC01EE59FE4F10820196803155 +:101060009105C1F71F910F91089580E065EE77E03B +:1010700043E050E00E94090D88E060E00E94C10E4C +:101080008CE061E00E94C10E08956F927F928F9272 +:101090009F92AF92BF92CF92DF92EF92FF920F9307 +:1010A0001F938091740190917501892B81F4809137 +:1010B000760190917701892B51F48BE060E070E02C +:1010C0000E94680E83E060E070E00E94680E8091EC +:1010D000760190917701181619062CF410924F01A1 +:1010E00010924E0108C0892B31F081E090E090937E +:1010F0004F0180934E0184E060914E010E94E10E09 +:1011000060E080914E0190914F01892B09F461E0DC +:1011100085E00E94E10E86E060914E010E94E10EA2 +:1011200060E080914E0190914F01892B09F461E0BC +:1011300087E00E94E10E80917601909177010097FF +:1011400009F454C0609174017091750161157105C5 +:1011500009F44CC000D000D0EDB7FEB731969B012A +:1011600077FF03C0309521953F4FB901882777FD60 +:101170008095982F2FEF30E040E050E020833183BE +:101180004283538320E030E040E050E0AEE1EA2EBD +:10119000F12C012D112DAA24BB2465010E94FE0F04 +:1011A000162F072F0F900F900F900F9080917401C2 +:1011B0009091750199232CF0CB0162E070E00E94C0 +:1011C000A6108BE00E94680E8091740190917501C9 +:1011D00097FF08C0812F902F62E070E00E94A61058 +:1011E000162F072F83E0612F702F61C000D000D031 +:1011F000EDB7FEB731969C0197FF03C0309521955E +:101200003F4FB901882777FD8095982F2FEF30E069 +:1012100040E050E0208331834283538320E030E07C +:1012200040E050E0FEE1EF2EF12C012D112DAA241B +:10123000BB2465010E94FE0F9B01AC010F900F9033 +:101240000F900F908BE0B9010E94680E00D000D083 +:10125000EDB7FEB73196209176013091770137FFD7 +:1012600003C0309521953F4FB901882777FD8095C0 +:10127000982F2FEF30E040E050E02083318342830D +:10128000538320E030E040E050E0EEE1EE2EF12C20 +:10129000012D112DAA24BB2465010E94FE0F9B0184 +:1012A000AC010F900F900F900F9083E0B9010E9456 +:1012B000680E8091760190917701892B09F02EC1FB +:1012C0008091740190917501009709F427C1692FED +:1012D000772767FD70956627770F661F77277093CE +:1012E0004F0160934E0184E00E94E10E60E0809126 +:1012F0004E0190914F01892B09F461E086E00E9434 +:10130000E10E60E080914E0190914F01892B09F42C +:1013100061E085E00E94E10E87E060914E010E944D +:10132000E10E8091740190917501181619060CF068 +:1013300073C08EEF91E060E271E00E94F50B00D087 +:1013400000D06091740170917501882777FD8095B8 +:10135000982F0FEF602E712C812C912CEDB7FEB7DA +:10136000618272828382948220E030E040E050E02B +:101370001EE1E12EF12C012D112DB8E2AB2EB12C86 +:10138000C12CD12C0E94FE0FAB01BC010F900F901D +:101390000F900F908EEF91E00E94EE0C00D000D0E5 +:1013A0006091740170917501882777FD8095982F61 +:1013B000EDB7FEB7618272828382948220E030E0D2 +:1013C00040E050E00E94FE0F9B01AC010F900F9097 +:1013D0000F900F908BE0B9010E94680E00D000D0F2 +:1013E0006091740170917501882777FD8095982F21 +:1013F000EDB7FEB7618272828382948220E030E092 +:1014000040E050E00E94FE0F9B01AC010F900F9056 +:101410000F900F9083E07FC08EEF91E06CE271E05F +:101420000E94F50B00D000D0EDB7FEB731962091A9 +:1014300074013091750137FF03C0309521953F4FFE +:10144000B901882777FD8095982FAFEF6A2E712C10 +:10145000812C912C608271828282938220E030E024 +:1014600040E050E0FEE1EF2EF12C012D112DE8E2DD +:10147000AE2EB12CC12CD12C0E94FE0FAB01BC01B1 +:101480000F900F900F900F908EEF91E00E94EE0C56 +:1014900000D000D0609174017091750170956195D4 +:1014A0007F4F882777FD8095982FEDB7FEB7618233 +:1014B00072828382948220E030E040E050E00E941B +:1014C000FE0F9B01AC010F900F900F900F9083E0E7 +:1014D000B9010E94680E00D000D060917401709133 +:1014E0007501709561957F4F882777FD8095982FBE +:1014F000EDB7FEB7618272828382948220E030E091 +:1015000040E050E00E94FE0F9B01AC010F900F9055 +:101510000F900F908BE0B9010E94680E8EEF91E062 +:1015200067E371E00E94F50B6091740170917501A1 +:101530008EEF91E00E94F90C8EEF91E06CE371E088 +:101540000E94F50B60917601709177018EEF91E02A +:101550000E94F90C68EC70E080E090E00E94F60DCB +:101560001F910F91FF90EF90DF90CF90BF90AF90C1 +:101570009F908F907F906F90089583E10E942E0F2F +:10158000892BA1F483E10E942E0F892BD9F380913E +:101590005C0190915D01019690935D0180935C01E7 +:1015A000049721F410925D0110925C0180915C011E +:1015B00090915D018330910519F40E94E005089532 +:1015C0008230910519F40E94CF050895019711F416 +:1015D0000E94450808950E94EE010E9435088EE59C +:1015E00091E06AE070E00E94A7018EEF91E040E890 +:1015F00055E260E070E00E94420B08950E942E0EBA +:101600000E94EB0A0E94BD0AFDCF1F920F920FB6F7 +:101610000F9211242F933F934F935F936F937F9378 +:101620008F939F93AF93BF93EF93FF934091C60027 +:10163000E091FA01F091FB01CF01019660E870E0C2 +:101640000E94A6109C018091FC019091FD01281739 +:10165000390739F0E658FE4F40833093FB01209361 +:10166000FA01FF91EF91BF91AF919F918F917F917F +:101670006F915F914F913F912F910F900FBE0F90FF +:101680001F901895AF92BF92CF92DF92EF92FF9288 +:101690000F931F93CF93DF936C017A018B01DC01D1 +:1016A0001496AD90BC901597CB01BA0122E030E0C2 +:1016B00040E050E00E94DB10205C3D4B404F5F4F0C +:1016C000CA01B901A80197010E94DB10C901DA0122 +:1016D0000197A109B109292F3A2F4B2F552747FD13 +:1016E0005A950196A11DB11DE5012883E601EE8101 +:1016F000FF8181508083EA85FB85208141E050E0B5 +:10170000CA010E8402C0880F991F0A94E2F7282BA1 +:101710002083EA85FB852081CA010F8402C0880FDF +:10172000991F0A94E2F7282B2083EA85FB858081A4 +:10173000088802C0440F551F0A94E2F7842B808367 +:10174000DF91CF911F910F91FF90EF90DF90CF909D +:10175000BF90AF900895FC01A085B18521898C913F +:1017600090E0022E02C0959587950A94E2F780FFDB +:10177000F6CF0484F585E02D6083089589E491E037 +:101780009093FF018093FE018AE791E0909301021C +:101790008093000285EC90E0909303028093020214 +:1017A00084EC90E0909305028093040280EC90E03A +:1017B000909307028093060281EC90E090930902D7 +:1017C0008093080286EC90E090930B0280930A02CB +:1017D00084E080930C0283E080930D0287E0809385 +:1017E0000E0285E080930F0208950F931F93CF930D +:1017F000DF938C01EB0109C02196D801ED91FC919A +:101800000190F081E02DC801099568816623A1F758 +:10181000DF91CF911F910F9108950F931F938C012A +:10182000DC01ED91FC910190F081E02D6DE00995D6 +:10183000D801ED91FC910190F081E02DC8016AE0A2 +:1018400009951F910F9108950F931F938C010E948A +:10185000F50BC8010E940D0C1F910F9108952F9256 +:101860003F924F925F926F927F928F929F92AF9230 +:10187000BF92CF92DF92EF92FF920F931F93DF936D +:10188000CF93CDB7DEB7A0970FB6F894DEBF0FBEEB +:10189000CDBF1C016A017B01411551056105710530 +:1018A00049F4DC01ED91FC910190F081E02D60E3C1 +:1018B000099554C0882499245401422E5524662445 +:1018C000772401E010E00C0F1D1F080D191DC70142 +:1018D000B601A30192010E94B910F8016083089437 +:1018E000811C911CA11CB11CC701B601A30192016E +:1018F0000E94B910C901DA016C017D01C114D10443 +:10190000E104F104F1F681E0E82EF12CEC0EFD1E6D +:10191000E80CF91C3E010894611C711CD501C4013E +:101920000197A109B1096C01C818D90814C0F601C2 +:10193000EE0DFF1D60816A3010F4605D01C0695CCE +:10194000D101ED91FC910190F081E02DC10109954B +:101950000894E108F1086E147F0449F7A0960FB6C9 +:10196000F894DEBF0FBECDBFCF91DF911F910F91D5 +:10197000FF90EF90DF90CF90BF90AF909F908F90AF +:101980007F906F905F904F903F902F900895EF92CF +:10199000FF920F931F93CF93DF93EC017A018B019A +:1019A00077FF0FC0E881F9810190F081E02D6DE2B1 +:1019B000099510950095F094E094E11CF11C011D2F +:1019C000111DCE01B801A7012AE00E942F0CDF9162 +:1019D000CF911F910F91FF90EF9008950F931F9358 +:1019E0008C010E94C70CC8010E940D0C1F910F9121 +:1019F00008950F931F938C01AB01662757FD6095E7 +:101A0000762F0E94C70CC8010E940D0C1F910F91E8 +:101A10000895823000F5E82FF0E0EE0FFF1FE05F41 +:101A2000FD4F71836083882319F08130A1F408C0D1 +:101A3000809169008C7F842B80936900E89A0895D7 +:101A400080916900440F551F440F551F837F842BDD +:101A500080936900E99A08951F920F920FB60F9232 +:101A600011242F933F934F935F936F937F938F93A3 +:101A70009F93AF93BF93EF93FF9380911002909148 +:101A80001102892B29F0E0911002F09111020995C1 +:101A9000FF91EF91BF91AF919F918F917F916F9146 +:101AA0005F914F913F912F910F900FBE0F901F901C +:101AB00018951F920F920FB60F9211242F933F93F8 +:101AC0004F935F936F937F938F939F93AF93BF9346 +:101AD000EF93FF938091120290911302892B29F0CA +:101AE000E0911202F09113020995FF91EF91BF91DD +:101AF000AF919F918F917F916F915F914F913F91A6 +:101B00002F910F900FBE0F901F9018951F920F925C +:101B10000FB60F9211242F938F939F93AF93BF9380 +:101B20008091140290911502A0911602B0911702B3 +:101B30000196A11DB11D8093140290931502A093EC +:101B40001602B09317028091180290911902A09189 +:101B50001A02B0911B028050904CAF4FBF4F809340 +:101B6000180290931902A0931A02B0931B0227C087 +:101B70008091180290911902A0911A02B0911B0253 +:101B800080589E43A040B040809318029093190261 +:101B9000A0931A02B0931B0280911C0290911D0227 +:101BA000A0911E02B0911F020196A11DB11D80934C +:101BB0001C0290931D02A0931E02B0931F028091FD +:101BC000180290911902A0911A02B0911B0281583B +:101BD0009E43A040B04060F6BF91AF919F918F911E +:101BE0002F910F900FBE0F901F901895EF92FF92BC +:101BF0000F931F937B018C018FB7F89440911C02C7 +:101C000050911D0260911E0270911F028FBF2FB76D +:101C1000F89480911C0290911D02A0911E02B09137 +:101C20001F022FBF841B950BA60BB70BE816F906F6 +:101C30000A071B0760F71F910F91FF90EF9008951F +:101C4000019759F0FC01EE0FFF1FEE0FFF1F3297B7 +:101C50008FB7F8943197F1F78FBF0895789484B5D2 +:101C6000826084BD84B5816084BD85B5826085BD98 +:101C700085B5816085BDEEE6F0E08081816080837E +:101C8000E1E8F0E0808182608083808181608083F0 +:101C9000E0E8F0E0808181608083E1EBF0E080812A +:101CA00084608083E0EBF0E0808181608083EAE7FC +:101CB000F0E0808184608083808182608083808185 +:101CC000816080838081806880831092C100089544 +:101CD0001F93CF93DF93182FEB0161E00E94C10E99 +:101CE000E12FF0E0E255FF4F8491833051F4809171 +:101CF0008000806880938000D0938900C093880022 +:101D00003CC0843051F480918000806280938000D8 +:101D1000D0938B00C0938A0030C0813039F4209773 +:101D200029F184B5806884BDC7BD27C0823039F4ED +:101D30002097E1F084B5806284BDC8BD1EC08630A6 +:101D400041F48091B00080688093B000C093B300EC +:101D500014C0873041F48091B00080628093B0005D +:101D6000C093B4000AC0C038D1051CF4812F60E0D4 +:101D700002C0812F61E00E94E10EDF91CF911F919F +:101D80000895282F30E0C90186569F4FFC01949199 +:101D90002A573F4FF9018491882391F0E82FF0E012 +:101DA000EE0FFF1FE859FF4FA591B491662329F468 +:101DB0008C91909589238C9308958C91892B8C9389 +:101DC0000895482F50E0CA0182559F4FFC0124918D +:101DD000CA0186569F4FFC0194914A575F4FFA0102 +:101DE00034913323D1F1222331F1233021F4809136 +:101DF00080008F7705C0243031F4809180008F7D82 +:101E00008093800018C0213019F484B58F7704C006 +:101E1000223021F484B58F7D84BD0DC0263021F49D +:101E20008091B0008F7705C0273029F48091B000F1 +:101E30008F7D8093B000E32FF0E0EE0FFF1FEE5890 +:101E4000FF4FA591B491662329F48C919095892335 +:101E50008C9308958C91892B8C930895682F70E052 +:101E6000CB0182559F4FFC012491CB0186569F4F99 +:101E7000FC0144916A577F4FFB019491992319F417 +:101E800020E030E038C0222331F1233021F480916A +:101E900080008F7705C0243031F4809180008F7DE1 +:101EA0008093800018C0213019F484B58F7704C066 +:101EB000223021F484B58F7D84BD0DC0263021F4FD +:101EC0008091B0008F7705C0273029F48091B00051 +:101ED0008F7D8093B000892F90E0880F991F8458E0 +:101EE0009F4FFC01A591B4918C9120E030E08423B8 +:101EF00011F021E030E0C9010895DF92EF92FF92E6 +:101F00000F931F93A82FB0E0CD0186569F4FFC0181 +:101F1000D490AA57BF4FFD018491662311F490E03D +:101F200001C09D2D6FEFE62E6FEFF62E6FEF062F9F +:101F30006FE0162FE222F32204231523682F70E0AE +:101F4000660F771F64587F4F20E030E040E050E09C +:101F5000FB01A591B4910AC02E153F05400751071A +:101F600009F440C02F5F3F4F4F4F5F4F8C918D2141 +:101F7000891791F30AC02E153F054007510791F1CB +:101F80002F5F3F4F4F4F5F4F03C0FB01A591B491AF +:101F90008C918D21891779F720E030E040E050E006 +:101FA000FB01A591B49104C02F5F3F4F4F4F5F4F8E +:101FB0008C918D218917C1F3CA01B9012AE030E063 +:101FC00040E050E00E9487109B01AC01205F3F4F32 +:101FD0004F4F5F4F84E056954795379527958A95E3 +:101FE000D1F704C020E030E040E050E0B901CA0180 +:101FF0001F910F91FF90EF90DF9008952F923F92E5 +:102000004F925F926F927F928F929F92AF92BF9208 +:10201000CF92DF92EF92FF920F931F93DF93CF93B4 +:10202000CDB7DEB73B014C0119012A016D897E89CC +:102030008F89988D6A197B098C099D09621A730A28 +:10204000840A950AA40193010E948710E218F308FC +:1020500004091509A80197010E94DB102A0D3B1DF8 +:102060004C1D5D1DB901CA01CF91DF911F910F91E8 +:10207000FF90EF90DF90CF90BF90AF909F908F90A8 +:102080007F906F905F904F903F902F900895EF92C8 +:10209000FF920F931F937B018C01611571058105E0 +:1020A000910529F420E030E040E050E00BC00E94B0 +:1020B000E000A80197010E94DB10AC01CB01DA011E +:1020C0009C01AD01B901CA011F910F91FF90EF90E2 +:1020D0000895EF92FF920F931F937B018C0162177B +:1020E00073078407950764F4261B370B480B590BBD +:1020F000CA01B9010E944710E60EF71E081F191FFA +:10210000B701C8011F910F91FF90EF900895629F52 +:10211000D001739FF001829FE00DF11D649FE00DDF +:10212000F11D929FF00D839FF00D749FF00D659F40 +:10213000F00D9927729FB00DE11DF91F639FB00D3F +:10214000E11DF91FBD01CF011124089597FB092E50 +:1021500007260AD077FD04D049D006D000201AF413 +:10216000709561957F4F0895F6F7909581959F4FF3 +:102170000895A1E21A2EAA1BBB1BFD010DC0AA1FC8 +:10218000BB1FEE1FFF1FA217B307E407F50720F0E0 +:10219000A21BB30BE40BF50B661F771F881F991F5B +:1021A0001A9469F760957095809590959B01AC01A4 +:1021B000BD01CF01089597FB092E05260ED057FDCE +:1021C00004D0D7DF0AD0001C38F4509540953095E4 +:1021D00021953F4F4F4F5F4F0895F6F790958095AB +:1021E000709561957F4F8F4F9F4F0895AA1BBB1B22 +:1021F00051E107C0AA1FBB1FA617B70710F0A61B07 +:10220000B70B881F991F5A95A9F780959095BC0127 +:10221000CD010895EE0FFF1F0590F491E02D099474 +:102220002F923F924F925F926F927F928F929F92E6 +:10223000AF92BF92CF92DF92EF92FF920F931F93D4 +:10224000CF93DF93CDB7DEB7CA1BDB0B0FB6F89485 +:10225000DEBF0FBECDBF09942A88398848885F84C5 +:102260006E847D848C849B84AA84B984C884DF8036 +:10227000EE80FD800C811B81AA81B981CE0FD11D1A +:102280000FB6F894DEBF0FBECDBFED010895F894F0 +:02229000FFCF7E +:10229200536572766F20706F733A00436865676F9B +:1022A20075204E6F766F73203220627974657300E9 +:1022B200476972616E646F20783E300047697261CF +:1022C2006E646F203C300078203D200079203D2054 +:0C22D200000100000000000000AB0B0049 +:00000001FF diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.pde b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.pde new file mode 100644 index 0000000..7b5af92 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/ArduinoSunSpotV2.pde @@ -0,0 +1,89 @@ +#include + +#define MOTOR1_P 4 +#define MOTOR1_N 5 +#define MOTOR1_PWM 11 + +#define MOTOR2_P 6 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 13 +#define SERVO_1 10 +#define MODE_BUTTON 19 //5 analógica lida como digital... + +#define MODE_DEMO 3 +#define MODE_WALK 2 +#define MODE_SUNSPOT 1 +#define MODE_STOP 0 +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=0; +Servo myservo10; // create servo object to control a servo + + +void setup() { + setupEngines(); + setupSunSpot(); + myservo10.attach(10); // attaches the servo on pin 10 to the servo object + Serial.begin(9600); +} +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void loop(){ + if(digitalRead(MODE_BUTTON)==0) { + while(digitalRead(MODE_BUTTON)==0); + mode++; + if(mode==4) mode=0; + } + if(mode==MODE_DEMO) { + Demo(); + } + else if(mode==MODE_WALK) { + Walk(); + } + else if(mode==MODE_SUNSPOT) { + SunSpot(); + } + +} + + + +/* + if(y>0) { + sentido = 1; + analogWrite(MOTOR1_PWM,(y == 10 ? 85 : y==20 ? 170 : 255)); + analogWrite(MOTOR2_PWM,(y == 10 ? 85 : y==20 ? 170 : 255)); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + } + else if(y<0){ //para traz + sentido = 0; + analogWrite(MOTOR1_PWM,(y == -10 ? 85 : y==-20 ? 170 : 255)); + analogWrite(MOTOR2_PWM,(y == -10 ? 85 : y==-20 ? 170 : 255)); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + } + */ + +/* + + + */ + + diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/Demo.pde b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/Demo.pde new file mode 100644 index 0000000..6ed3a69 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/Demo.pde @@ -0,0 +1,194 @@ +/* +1.5' 3.2' + C E Am + Faço código como cão;Maldito bug, que não encontro não; + 5.5' 8' com breque + Vem o prazo e o chefão, o redeploy não da certo nÃo; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se você começa de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + Já estou penando aqui + 38' 41' + C E Am + Faço o download de um jar grandão, mas também não 42' + funciona não + 43' 45' 48' + Chamo o arquiteto bacanão, mas no fundo é um manézão + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + Não me sinto up-to-date, eu estou é “deprecate” + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Faço código como cão;Maldito bug, que não encontro não; + 5.5' 8' com breque + Vem o prazo e o chefão, o redeploy não da certo nÃo; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se você começa de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas também não funciona não */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo é um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..dc28a59 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/Print.cpp.o b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/Print.cpp.o new file mode 100644 index 0000000..6205c51 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/SunSpot.pde b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/SunSpot.pde new file mode 100644 index 0000000..edcd38d --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/SunSpot.pde @@ -0,0 +1,101 @@ +#define SUN_SPOT 8 +#define SUN_SPOT_ACK 12 +#define SUN_SPOT_INTERRUPT 0 //PORTA digital 2 + +volatile int data; +volatile boolean bit_array[16]; +volatile int contador; +int x; +int y; + +void SunSpot() { + if(x==0 && y==0) { + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + } + if(y>0) sentido = 0; //Para FRENTE + else if(y<0) sentido = 1;// Para Traz + //Configurando o sentido do trem.. quero dizer do robot + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + if(y!=0 && x!=0) { //Curva frente ou traz... + int coeficientePotencia = map(x<0 ? x*-1 : x,0,30,0,255); + analogWrite(MOTOR1_PWM, x< 0 ? coeficientePotencia : coeficientePotencia/2); + analogWrite(MOTOR2_PWM, x< 0 ? coeficientePotencia/2 : coeficientePotencia); + } + else { //reto + analogWrite(MOTOR1_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + analogWrite(MOTOR2_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + } + //Girando no eixo + if(y==0 && x!=0) { + sentido = x<0; + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_N,sentido); + if(x>0) { + Serial.print("Girando x>0"); + Serial.println(map(x,0,30,40,255)); + analogWrite(MOTOR1_PWM, map(x,0,30,40,255) ); + analogWrite(MOTOR2_PWM , map(x,0,30,40,255) ); + } + else { + Serial.print("Girando <0"); + Serial.println(map(x>0 ? x : x*-1,0,30,40,255)); + + analogWrite(MOTOR2_PWM, map(x*-1,0,30,40,255) ); + analogWrite(MOTOR1_PWM, map(x*-1,0,30,40,255) ); + } + } + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + delay(200); +} +void setupSunSpot() { + attachInterrupt(0, receiveSunSpot, RISING); + pinMode(SUN_SPOT,INPUT); + pinMode(SUN_SPOT_ACK,OUTPUT); +} + +void receiveSunSpot() { + digitalWrite(SUN_SPOT_ACK,LOW); + bit_array[contador++]=digitalRead(SUN_SPOT); + digitalWrite(SUN_SPOT_ACK,HIGH); + if(contador==16) { + Serial.println("Chegou Novos 2 bytes"); + contador=0; + x = BtoI(0,7,bit_array); + + y = BtoI(8,15,bit_array); + + for(int clean=0;clean<16;clean++) bit_array[clean]=false; + + } +} + +int BtoI(int start,int end, volatile boolean bits[]){ + boolean negative=bits[start]; + start++; + unsigned long integer=0; + unsigned long mask=1; + int r; + for (int i = end; i >= start; i--) { + if(negative) { + if (!bits[i]) integer |= mask; + } + else { + if (bits[i]) integer |= mask; + } + mask = mask << 1; + } + r = (int) integer; + if(negative) r= ~r; + return r; +} diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/WInterrupts.c.o new file mode 100644 index 0000000..b74dfbb Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/WMath.cpp.o new file mode 100644 index 0000000..4e4cf44 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/Walk.pde b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/Walk.pde new file mode 100644 index 0000000..0306154 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/Walk.pde @@ -0,0 +1,223 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int move_count = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + readPing(); + processPing(); + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,50*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/core.a b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/core.a new file mode 100644 index 0000000..9917612 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/pins_arduino.c.o new file mode 100644 index 0000000..c450af7 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring.c.o b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring.c.o new file mode 100644 index 0000000..acbd542 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_analog.c.o new file mode 100644 index 0000000..b56797d Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_digital.c.o new file mode 100644 index 0000000..3928ccd Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_pulse.c.o new file mode 100644 index 0000000..525eda2 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_serial.c.o b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_serial.c.o new file mode 100644 index 0000000..b8d4c17 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_serial.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_shift.c.o new file mode 100644 index 0000000..8e0db5b Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/ArduinoSunSpotV2/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Dimmer_D2/Dimmer_D2.pde b/arduino/all the sketchs of my life/Projetos/Dimmer_D2/Dimmer_D2.pde new file mode 100644 index 0000000..969461a --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/Dimmer_D2/Dimmer_D2.pde @@ -0,0 +1,194 @@ +/* + AC Light Control + + Ryan McLaughlin + + Thanks to http://www.andrewkilpatrick.org/blog/?page_id=445 + and http://www.hoelscher-hi.de/hendrik/english/dimmer.htm + + */ +#include + +#include +#include + +#define PING_PIN 4 + +#define INIT_TIMER_COUNT 6 +#define RESET_TIMER2 TCNT2 = INIT_TIMER_COUNT + +#define CW HIGH +#define CCW LOW + +// One and two phases +// 60000ms / 48steps = 1250ms/step +#define TRACK 1250 + +// Half steps +// 60000ms / 96steps = 625 +//#define TRACK 625 + + + + +int led13 = HIGH; +long counter = 0; +int stepStack = 0; + + +int AC_pin = 7; // Output to Opto Triac +int olddim; +long dim = 120; // Dimming level (0-128) 0 = on, 128 = 0ff +long duration, inches, cm, oldCm; +long MAX_DISTANCE = 50; +volatile boolean wasInt = false; +unsigned long time, timeWaiting, DEFAULT_CONFIG_PERIOD=2000; + +void setup() // run once, when the sketch starts +{ + pinMode(AC_pin, OUTPUT); // Set the light control pin as output + Serial.begin(9600); + attachInterrupt(0, light, RISING); // Attach an Interupt to pin2 (interupt 0) for Zero Cross Detection + Wire.begin(66); + Wire.onReceive(receiveEvent); + readPing(true); + MAX_DISTANCE=cm; + + //Timer2 Settings: Timer Prescaler /64, + TCCR2A |= (1< 30 ? 30 : cm; + dim = map(cmn,1,30,10,125); + //Wire.send(dim); + delay(20); + readPing(true); + + } + } + } + delay(150); + + +} +void readPing(boolean disableInt) +{ + wasInt=false; + + if(disableInt) noInterrupts(); + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + if(wasInt) return; + delayMicroseconds(2); + if(wasInt) return; + digitalWrite(PING_PIN, HIGH); + if(wasInt) return; + delayMicroseconds(5); + if(wasInt) return; + digitalWrite(PING_PIN, LOW); + pinMode(PING_PIN, INPUT); + if(wasInt) return; + duration = pulseIn(PING_PIN, HIGH); + if(wasInt) return; + interrupts(); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + + +// Aruino runs at 16 Mhz, so we have 1000 Overflows per second... +// 1/ ((16000000 / 64) / 256) = 1 / 1000 +ISR(TIMER2_OVF_vect) { + RESET_TIMER2; + counter++; + if(!(counter%TRACK)) + { + // enqueue step message + } +}; + + + + diff --git a/arduino/all the sketchs of my life/Projetos/Dimmer_JavaFX/Dimmer_JavaFX.pde b/arduino/all the sketchs of my life/Projetos/Dimmer_JavaFX/Dimmer_JavaFX.pde new file mode 100644 index 0000000..ef8e6c5 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/Dimmer_JavaFX/Dimmer_JavaFX.pde @@ -0,0 +1,51 @@ +#include + +int AC_pin = 3; // Output to Opto Triac +volatile long dim = 60; // Dimming level (0-128) 0 = on, 128 = 0ff + + +void setup() +{ + // start serial port at 9600 bps: + pinMode(AC_pin, OUTPUT); // Set the light control pin as output + Serial.begin(9600); + attachInterrupt(0, light, RISING); // Attach an Interupt to pin2 (interupt 0) for Zero Cross Detection + Wire.begin(4); // join i2c bus with address #4 + Wire.onReceive(receiveEvent); // register event + +} +void receiveEvent(int howMany) +{ + Serial.println("Evento"); + Serial.println(howMany); +// dim = howMany; + +} + +void light() // function to be fired at the zero crossing to dim the light +{ + //Serial.println("AA"); + + if(dim<125) { + long dimtime = (60*dim); // eval the proper pause to fire the triac + delayMicroseconds(dimtime); // delay the dim time + digitalWrite(AC_pin, HIGH); // fire the Triac + delayMicroseconds(1); // pause briefly to ensure the triac turned on + digitalWrite(AC_pin, LOW); // turn off the Triac gate (triac will not turn off until next zero cross) + } + else { + digitalWrite(AC_pin, LOW); // turn off the Triac gate (triac will not turn off until next zero cross) + } +} + +void loop() +{ + if (Serial.available() > 0) { + byte inByte = Serial.read(); + dim = inByte; + + } +} + + + diff --git a/arduino/all the sketchs of my life/Projetos/DojoBSB/Demo.pde b/arduino/all the sketchs of my life/Projetos/DojoBSB/Demo.pde new file mode 100644 index 0000000..290c156 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/DojoBSB/Demo.pde @@ -0,0 +1,195 @@ +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/Projetos/DojoBSB/DojoBSB.pde b/arduino/all the sketchs of my life/Projetos/DojoBSB/DojoBSB.pde new file mode 100644 index 0000000..cf12436 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/DojoBSB/DojoBSB.pde @@ -0,0 +1,73 @@ +#include + +#define MOTOR1_P 4 +#define MOTOR1_N 5 +#define MOTOR1_PWM 11 + +#define MOTOR2_P 6 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 9 +#define SERVO_H 10 +#define SERVO_V 11 + +#define MODE_BUTTON 19 //5 anal�gica lida como digital... + +#define MODE_DEMO 2 +#define MODE_WALK 3 +#define MODE_SUNSPOT 1 +#define MODE_STOP 0 +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=0; +Servo servoHorizontal; // create servo object to control a servo +Servo servoVertical; // create servo object to control a servo + + +void setup() { + setupEngines(); + setupSunSpot(); + servoHorizontal.attach(SERVO_H); + //servoVertical.attach(SERVO_V); + Serial.begin(9600); +} + + +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + +} + +void loop(){ + + if(digitalRead(MODE_BUTTON)==0) { + while(digitalRead(MODE_BUTTON)==0); + mode++; + if(mode==4) mode=0; + } + if(mode==MODE_DEMO) { + Demo(); + } + else if(mode==MODE_WALK) { + Walk(); + } + else if(mode==MODE_SUNSPOT) { + SunSpot(); + } + +} + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/DojoBSB/SunSpot.pde b/arduino/all the sketchs of my life/Projetos/DojoBSB/SunSpot.pde new file mode 100644 index 0000000..9623884 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/DojoBSB/SunSpot.pde @@ -0,0 +1,118 @@ +#define SUN_SPOT 8 +#define SUN_SPOT_ACK 12 +#define SUN_SPOT_INTERRUPT 0 //PORTA digital 2 + +volatile int data; +volatile boolean bit_array[16]; +volatile int contador; +int x; +int y; + +void SunSpot() { + if(x==0 && y==0) { + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + } + if(x==100 && y==100) { + digitalWrite(9, HIGH); + delay(500); + digitalWrite(9, LOW); + delay(200); + return; + } + if(x==101) { + changeServo(y); + delay(200); + return; + } + + if(y>0) sentido = 0; //Para FRENTE + else if(y<0) sentido = 1;// Para Traz + //Configurando o sentido do trem.. quero dizer do robot + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + if(y!=0 && x!=0) { //Curva frente ou traz... + int coeficientePotencia = map(x<0 ? x*-1 : x,0,30,0,255); + analogWrite(MOTOR1_PWM, x< 0 ? coeficientePotencia : coeficientePotencia/2); + analogWrite(MOTOR2_PWM, x< 0 ? coeficientePotencia/2 : coeficientePotencia); + } + else { //reto + analogWrite(MOTOR1_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + analogWrite(MOTOR2_PWM,map(y<0 ? y*-1 : y,0,30,0,255)); + } + //Girando no eixo + if(y==0 && x!=0) { + sentido = x<0; + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_N,sentido); + if(x>0) { + Serial.print("Girando x>0"); + Serial.println(map(x,0,30,40,255)); + analogWrite(MOTOR1_PWM, map(x,0,30,40,255) ); + analogWrite(MOTOR2_PWM , map(x,0,30,40,255) ); + } + else { + Serial.print("Girando <0"); + Serial.println(map(x>0 ? x : x*-1,0,30,40,255)); + + analogWrite(MOTOR2_PWM, map(x*-1,0,30,40,255) ); + analogWrite(MOTOR1_PWM, map(x*-1,0,30,40,255) ); + } + } + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + delay(200); +} +void setupSunSpot() { + attachInterrupt(0, receiveSunSpot, RISING); + pinMode(SUN_SPOT,INPUT); + pinMode(SUN_SPOT_ACK,OUTPUT); +} + +void receiveSunSpot() { + digitalWrite(SUN_SPOT_ACK,LOW); + bit_array[contador++]=digitalRead(SUN_SPOT); + digitalWrite(SUN_SPOT_ACK,HIGH); + if(contador==16) { + Serial.println("Chegou Novos 2 bytes"); + contador=0; + x = BtoI(0,7,bit_array); + + y = BtoI(8,15,bit_array); + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + for(int clean=0;clean<16;clean++) bit_array[clean]=false; + + } +} + +int BtoI(int start,int end, volatile boolean bits[]){ + boolean negative=bits[start]; + start++; + unsigned long integer=0; + unsigned long mask=1; + int r; + for (int i = end; i >= start; i--) { + if(negative) { + if (!bits[i]) integer |= mask; + } + else { + if (bits[i]) integer |= mask; + } + mask = mask << 1; + } + r = (int) integer; + if(negative) r= ~r; + return r; +} diff --git a/arduino/all the sketchs of my life/Projetos/DojoBSB/Walk.pde b/arduino/all the sketchs of my life/Projetos/DojoBSB/Walk.pde new file mode 100644 index 0000000..d46bc8f --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/DojoBSB/Walk.pde @@ -0,0 +1,286 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServo(int servoPos) { + servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + andarFrente(300,3); + + readPing(); + while(cm > 35) { + andarFrente(300,3); + readPing(); +} + parar(); + fullScan(); + + if(getLongestPosition() < 9){ + virarEsquerdaRe(500,3); + }else { + virarDireitaRe(500,3); + } + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + + if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + + andarFrente(300,3); + moveCount++; + + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + diff --git a/arduino/all the sketchs of my life/Projetos/I2C_Master/I2C_Master.pde b/arduino/all the sketchs of my life/Projetos/I2C_Master/I2C_Master.pde new file mode 100644 index 0000000..53c4fbd --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/I2C_Master/I2C_Master.pde @@ -0,0 +1,40 @@ +#include + + +char comando[16]; +int luz= 0; + + +void setup() +{ + Wire.begin(); + Serial.begin(9600); +} + +void loop () +{ + executarComando(); + delay(1000); + +} + +void executarComando() { + Serial.println("Enviando"); + Wire.beginTransmission(65); // transmit to device #4 + Wire.send(luz++); // sends six bytes + Wire.endTransmission(); // stop transmitting + +} +void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } +} + + + + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/I2C_Slave/I2C_Slave.pde b/arduino/all the sketchs of my life/Projetos/I2C_Slave/I2C_Slave.pde new file mode 100644 index 0000000..784d5eb --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/I2C_Slave/I2C_Slave.pde @@ -0,0 +1,34 @@ +#include + + +void setup() +{ + Serial.begin(9600); + Wire.begin(65); // join i2c bus with address #4 + Wire.onReceive(receiveEvent); // register event + +} +void receiveEvent(int howMany) +{ + while(1 < Wire.available()) // loop through all but the last + { + char c = Wire.receive(); // receive byte as a character + Serial.print(c); // print the character + } + int x = Wire.receive(); // receive byte as an integer + Serial.println(x); // print the integer + + Serial.println("Evento"); + Serial.println(howMany); + +} + +void loop() +{ + Serial.println("esperando..."); + delay(1000); + +} + + + diff --git a/arduino/all the sketchs of my life/Projetos/I2C_Slave_Dimmer/I2C_Slave_Dimmer.pde b/arduino/all the sketchs of my life/Projetos/I2C_Slave_Dimmer/I2C_Slave_Dimmer.pde new file mode 100644 index 0000000..dd8a966 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/I2C_Slave_Dimmer/I2C_Slave_Dimmer.pde @@ -0,0 +1,62 @@ +#include + +int AC_pin = 7; +volatile long dim = 100; + + +void setup() +{ + pinMode(AC_pin, OUTPUT); + Serial.begin(9600); + attachInterrupt(0, light, RISING); + Wire.begin(66); + Wire.onReceive(receiveEvent); + +} +void receiveEvent(int howMany) +{ + char comando[16]; + int counter=0; + while(1 < Wire.available()) + { + char c = Wire.receive(); + comando[counter++]=c; + Serial.print(c); + } + int x = Wire.receive(); + Serial.println(x); + + Serial.println("Evento"); + Serial.println(howMany); + //value, fromLow, fromHigh, toLow, toHigh) + dim = map(comando[1], 48,57,10,120); + +} + +void light() +{ + Serial.println("int"); + + if(dim<125) { + long dimtime = (60*dim); // eval the proper pause to fire the triac + Serial.println(dimtime); + delayMicroseconds(dimtime); // delay the dim time + digitalWrite(AC_pin, HIGH); // fire the Triac + delayMicroseconds(1); // pause briefly to ensure the triac turned on + digitalWrite(AC_pin, LOW); // turn off the Triac gate (triac will not turn off until next zero cross) + } + else { + digitalWrite(AC_pin, LOW); // turn off the Triac gate (triac will not turn off until next zero cross) + } +} + +void loop() +{ + if (Serial.available() > 0) { + byte inByte = Serial.read(); + dim = inByte; + } +} + + + diff --git a/arduino/all the sketchs of my life/Projetos/InnovationAward/InnovationAward.pde b/arduino/all the sketchs of my life/Projetos/InnovationAward/InnovationAward.pde new file mode 100644 index 0000000..5b3f610 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/InnovationAward/InnovationAward.pde @@ -0,0 +1,164 @@ +#define RELAY1 7 +#define RELAY2 8 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo + +#define BLUE 9 +#define GREEN 6 +#define RED 5 + +#define TEMPERATURE 2 +#define LIGHT 3 +#define PING_PIN 3 + +#define LED 13 + +long duration, inches, cm; +boolean connected = false; + +void setup() +{ + Serial.begin(115200); + pinMode(LED, OUTPUT); + pinMode(RELAY1, OUTPUT); + pinMode(RELAY2, OUTPUT); + +} + +void loop() +{ + if(Serial.available()) receiveCommand(); +} + +void handShake() { + //Serial.print("ID 0|bluetooth prototype device|6|A|relay|B|dimmer|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.print("ID 0|USB prototype device|6|A|lamp|B|wallsocket|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + if(comando[0]=='A') relayCommand(comando[1], comando[2]); + if(comando[0]=='B') dimmer(comando); + if(comando[0]=='C') RGB(comando); + if(comando[0]=='D') readLight(); + if(comando[0]=='E') readTemperature(); + if(comando[0]=='F') readDistance(); + if(comando[0]=='S') readAllSensors(); + if(comando[0]=='X') shutdown(); + +} + +void relayCommand(char operation, char relay) { + if(operation=='+') { + digitalWrite(relay=='A' ? RELAY1 : RELAY2, HIGH); + if(relay=='C') digitalWrite(relay=='A' ? RELAY1 : RELAY2, HIGH); + } + else if(operation=='-') { + digitalWrite(relay=='A' ? RELAY1 : RELAY2, LOW); + if(relay=='C') digitalWrite(relay=='A' ? RELAY1 : RELAY2 , LOW); + } +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void dimmer(char* comando) { +} + +void readLight() { + String toSend = String(analogRead(LIGHT)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(TEMPERATURE)); + sendToPC(toSend); +} + +void readAllSensors() { + Serial.print(analogRead(LIGHT)); + Serial.print("|"); + Serial.print(analogRead(2)); + Serial.print("|"); + //String toSend3 = String(cm); + Serial.print(cm); + Serial.flush(); +} + + +void readDistance() { + readPing(); + sendToPC(cm); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/Innovation_Relay/Innovation_Relay.pde b/arduino/all the sketchs of my life/Projetos/Innovation_Relay/Innovation_Relay.pde new file mode 100644 index 0000000..82db7d5 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/Innovation_Relay/Innovation_Relay.pde @@ -0,0 +1,70 @@ +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define BLUE 9 +#define GREEN 6 +#define RED 5 + +void setup() +{ + pinMode(11, OUTPUT); + pinMode(12, OUTPUT); + Serial.begin(115200); + analogWrite(RED,255); + delay(250); + analogWrite(RED,0); + delay(250); + analogWrite(GREEN,255); + delay(250); + analogWrite(GREEN,0); + delay(250); + analogWrite(BLUE,255); + delay(250); + analogWrite(BLUE,0); + delay(250); + +} + +void loop() +{ + if(Serial.available()) receiveCommand(); +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='A') relayCommand(comando[1], comando[2]); + if(comando[0]=='B') dimmer(comando); + if(comando[0]=='C') RGB(comando); +} + +void relayCommand(char operation, char relay) { + if(operation=='+') { + digitalWrite(relay=='A' ? 11 : 12, HIGH); + if(relay=='C') digitalWrite(relay=='A' ? 12 : 11, HIGH); + } + else if(operation=='-') { + digitalWrite(relay=='A' ? 11 : 12, LOW); + if(relay=='C') digitalWrite(relay=='A' ? 12 : 11, LOW); + } +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void dimmer(char* comando) {} + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaFX_Mirror/JavaFX_Mirror.pde b/arduino/all the sketchs of my life/Projetos/JavaFX_Mirror/JavaFX_Mirror.pde new file mode 100644 index 0000000..7cb0891 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaFX_Mirror/JavaFX_Mirror.pde @@ -0,0 +1,1188 @@ +/* + Serial Call and Response + Language: Wiring/Arduino + + This program sends an ASCII A (byte of value 65) on startup + and repeats that until it gets some data in. + Then it waits for a byte in the serial port, and + sends three sensor values whenever it gets a byte in. + + Thanks to Greg Shakar and Scott Fitzgerald for the improvements + + The circuit: + * potentiometers attached to analog inputs 0 and 1 + * pushbutton attached to digital I/O 2 + + + http://www.arduino.cc/en/Tutorial/SerialCallResponse + + Created 26 Sept. 2005 + by Tom Igoe + Modified 14 April 2009 + by Tom Igoe and Scott Fitzgerald + */ + +int firstSensor = 0; // first analog sensor +int secondSensor = 0; // second analog sensor +int thirdSensor = 0; // digital sensor +int inByte = 0; // incoming serial byte + +void setup() +{ + // start serial port at 9600 bps: + Serial.begin(9600); + pinMode(2, INPUT); // digital sensor is on digital pin 2 + establishContact(); // send a byte to establish contact until receiver responds +} + +void loop() +{ + // if we get a valid byte, read analog ins: + if (Serial.available() > 0) { + // get incoming byte: + inByte = Serial.read(); + // read first analog input, divide by 4 to make the range 0-255: + pinMode(inByte, OUTPUT); + digitalWrite(inByte, HIGH); + delay(1000); + digitalWrite(inByte, LOW + ); + + } +} + +void establishContact() { + while (Serial.available() <= 0) { + Serial.print('A', BYTE); // send a capital A + delay(300); + } +} + +/* +Processing sketch to run with this example: + +import processing.serial.*; + +int bgcolor; // Background color +int fgcolor; // Fill color +Serial myPort; // The serial port +int[] serialInArray = new int[3]; // Where we'll put what we receive +int serialCount = 0; // A count of how many bytes we receive +int xpos, ypos; // Starting position of the ball +boolean firstContact = false; // Whether we've heard from the microcontroller + +void setup() { + size(256, 256); // Stage size + noStroke(); // No border on the next thing drawn + + // Set the starting position of the ball (middle of the stage) + xpos = width/2; + ypos = height/2; + + // Print a list of the serial ports, for debugging purposes: + println(Serial.list()); + + // I know that the first port in the serial list on my mac + // is always my FTDI adaptor, so I open Serial.list()[0]. + // On Windows machines, this generally opens COM1. + // Open whatever port is the one you're using. + String portName = Serial.list()[0]; + myPort = new Serial(this, portName, 9600); +} + +void draw() { + background(bgcolor); + fill(fgcolor); + // Draw the shape + ellipse(xpos, ypos, 20, 20); +} + +void serialEvent(Serial myPort) { + // read a byte from the serial port: + int inByte = myPort.read(); + // if this is the first byte received, and it's an A, + // clear the serial buffer and note that you've + // had first contact from the microcontroller. + // Otherwise, add the incoming byte to the array: + if (firstContact == false) { + if (inByte == 'A') { + myPort.clear(); // clear the serial port buffer + firstContact = true; // you've had first contact from the microcontroller + myPort.write('A'); // ask for more + } + } + else { + // Add the latest byte from the serial port to array: + serialInArray[serialCount] = inByte; + serialCount++; + + // If we have 3 bytes: + if (serialCount > 2 ) { + xpos = serialInArray[0]; + ypos = serialInArray[1]; + fgcolor = serialInArray[2]; + + // print the values (for debugging purposes only): + println(xpos + "\t" + ypos + "\t" + fgcolor); + + // Send a capital A to request new sensor readings: + myPort.write('A'); + // Reset serialCount: + serialCount = 0; + } + } +} +*/ + +/* +Max/MSP version 5 patch to run with this example: + +{ + "boxes" : [ { + "box" : { + "maxclass" : "message", + "text" : "65", + "patching_rect" : [ 339.0, 466.0, 32.5, 18.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-9", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "sel 1", + "patching_rect" : [ 339.0, 437.0, 36.0, 20.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "bang", "" ], + "id" : "obj-6", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "Serial Call-Response \n\nSends a byte out the serial port, and reads 3 bytes in. Sets foregound color, xpos, and ypos of a circle using the values returned from the serial port. \n\nNote: This patch assumes that the device on the other end of the serial port is going to send a single byte of value 65 (ASCII A) on startup. The sketch waits for that byte, then sends an ASCII A whenever it wants more data. \n\ncreated 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe", + "linecount" : 11, + "patching_rect" : [ 404.0, 52.0, 464.0, 158.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-5", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "trigger (or [t]) forces right-left conventions. All the drawing and processing will happen before Max requests new values. When this trigger fires, it sends an ASCII A to ask Arduino for new values.", + "linecount" : 3, + "patching_rect" : [ 239.0, 505.0, 425.0, 48.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-65", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "reinitializes the gates when turned on and off", + "linecount" : 2, + "patching_rect" : [ 170.0, 370.0, 135.0, 34.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-64", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "checks for the ascii value of \"A\" to begin cominucation. After initial communication is made, this block shuts down.", + "linecount" : 3, + "patching_rect" : [ 460.0, 355.0, 233.0, 48.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-63", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "p \"draw the circle\"", + "patching_rect" : [ 217.0, 645.0, 269.0, 19.0 ], + "numoutlets" : 1, + "fontsize" : 10.0, + "outlettype" : [ "" ], + "id" : "obj-62", + "fontname" : "Verdana", + "numinlets" : 3, + "patcher" : { + "fileversion" : 1, + "rect" : [ 54.0, 94.0, 640.0, 480.0 ], + "bglocked" : 0, + "defrect" : [ 54.0, 94.0, 640.0, 480.0 ], + "openrect" : [ 0.0, 0.0, 0.0, 0.0 ], + "openinpresentation" : 0, + "default_fontsize" : 10.0, + "default_fontface" : 0, + "default_fontname" : "Verdana", + "gridonopen" : 0, + "gridsize" : [ 25.0, 25.0 ], + "gridsnaponopen" : 0, + "toolbarvisible" : 1, + "boxanimatetime" : 200, + "imprint" : 0, + "boxes" : [ { + "box" : { + "maxclass" : "message", + "text" : "frgb 255 255 255", + "patching_rect" : [ 375.0, 150.0, 98.0, 18.0 ], + "numoutlets" : 1, + "fontsize" : 11.595187, + "outlettype" : [ "" ], + "id" : "obj-47", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "frgb 0 0 0", + "patching_rect" : [ 275.0, 125.0, 59.0, 18.0 ], + "numoutlets" : 1, + "fontsize" : 11.595187, + "outlettype" : [ "" ], + "id" : "obj-46", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "sel 255 0", + "patching_rect" : [ 300.0, 100.0, 66.0, 21.0 ], + "numoutlets" : 3, + "fontsize" : 12.0, + "outlettype" : [ "bang", "bang", "" ], + "id" : "obj-45", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "pack 0 0 0 0", + "patching_rect" : [ 50.0, 125.0, 180.0, 21.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-43", + "fontname" : "Verdana", + "numinlets" : 4 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "+ 10", + "patching_rect" : [ 200.0, 100.0, 40.0, 21.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "int" ], + "id" : "obj-42", + "fontname" : "Verdana", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "+ 10", + "patching_rect" : [ 75.0, 100.0, 40.0, 21.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "int" ], + "id" : "obj-41", + "fontname" : "Verdana", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "clear, paintoval $1 $2 $3 $4", + "patching_rect" : [ 50.0, 150.0, 152.0, 18.0 ], + "numoutlets" : 1, + "fontsize" : 11.595187, + "outlettype" : [ "" ], + "id" : "obj-40", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "inlet", + "patching_rect" : [ 57.5, 40.0, 25.0, 25.0 ], + "numoutlets" : 1, + "outlettype" : [ "int" ], + "id" : "obj-58", + "numinlets" : 0, + "comment" : "" + } + + } +, { + "box" : { + "maxclass" : "inlet", + "patching_rect" : [ 120.0, 40.0, 25.0, 25.0 ], + "numoutlets" : 1, + "outlettype" : [ "int" ], + "id" : "obj-59", + "numinlets" : 0, + "comment" : "" + } + + } +, { + "box" : { + "maxclass" : "inlet", + "patching_rect" : [ 300.0, 40.0, 25.0, 25.0 ], + "numoutlets" : 1, + "outlettype" : [ "int" ], + "id" : "obj-60", + "numinlets" : 0, + "comment" : "" + } + + } +, { + "box" : { + "maxclass" : "outlet", + "patching_rect" : [ 228.333344, 228.0, 25.0, 25.0 ], + "numoutlets" : 0, + "id" : "obj-61", + "numinlets" : 1, + "comment" : "" + } + + } + ], + "lines" : [ { + "patchline" : { + "source" : [ "obj-47", 0 ], + "destination" : [ "obj-61", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-46", 0 ], + "destination" : [ "obj-61", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-40", 0 ], + "destination" : [ "obj-61", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-60", 0 ], + "destination" : [ "obj-45", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-59", 0 ], + "destination" : [ "obj-42", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-59", 0 ], + "destination" : [ "obj-43", 1 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-58", 0 ], + "destination" : [ "obj-41", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-58", 0 ], + "destination" : [ "obj-43", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-42", 0 ], + "destination" : [ "obj-43", 3 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-41", 0 ], + "destination" : [ "obj-43", 2 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-45", 1 ], + "destination" : [ "obj-47", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-45", 0 ], + "destination" : [ "obj-46", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-43", 0 ], + "destination" : [ "obj-40", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } + ] + } +, + "saved_object_attributes" : { + "fontface" : 0, + "fontsize" : 10.0, + "default_fontface" : 0, + "default_fontname" : "Verdana", + "default_fontsize" : 10.0, + "fontname" : "Verdana", + "globalpatchername" : "" + } + + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "0", + "patching_rect" : [ 310.0, 378.0, 32.5, 20.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "int" ], + "id" : "obj-57", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "!- 1", + "patching_rect" : [ 385.0, 436.0, 32.5, 20.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "int" ], + "id" : "obj-55", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "gate 1 1", + "patching_rect" : [ 385.0, 355.0, 54.0, 20.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-54", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "toggle", + "patching_rect" : [ 385.0, 405.0, 20.0, 20.0 ], + "numoutlets" : 1, + "outlettype" : [ "int" ], + "id" : "obj-53", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "gate 1 0", + "patching_rect" : [ 194.0, 455.0, 54.0, 20.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-50", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "sel 65", + "patching_rect" : [ 385.0, 380.0, 43.0, 20.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "bang", "" ], + "id" : "obj-48", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "lcd", + "patching_rect" : [ 217.0, 695.0, 256.0, 256.0 ], + "numoutlets" : 4, + "outlettype" : [ "list", "list", "int", "" ], + "id" : "obj-39", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "t 65 l", + "patching_rect" : [ 194.0, 504.0, 42.0, 21.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "int", "" ], + "id" : "obj-35", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "val3", + "patching_rect" : [ 535.0, 604.0, 37.0, 21.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-1", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "number", + "patching_rect" : [ 467.0, 604.0, 56.0, 21.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "int", "bang" ], + "id" : "obj-3", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "val2", + "patching_rect" : [ 410.0, 605.0, 37.0, 21.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-18", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "val1", + "patching_rect" : [ 282.0, 605.0, 37.0, 21.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-20", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "number", + "patching_rect" : [ 342.0, 605.0, 56.0, 21.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "int", "bang" ], + "id" : "obj-22", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "number", + "patching_rect" : [ 217.0, 605.0, 55.0, 21.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "int", "bang" ], + "id" : "obj-23", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "unpack 0 0 0", + "patching_rect" : [ 217.0, 570.0, 269.0, 21.0 ], + "numoutlets" : 3, + "fontsize" : 12.0, + "outlettype" : [ "int", "int", "int" ], + "id" : "obj-29", + "fontname" : "Verdana", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "zl group 3", + "patching_rect" : [ 194.0, 480.0, 71.0, 21.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "", "" ], + "id" : "obj-31", + "fontname" : "Verdana", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "select 0 1", + "patching_rect" : [ 312.0, 200.0, 62.0, 20.0 ], + "numoutlets" : 3, + "fontsize" : 12.0, + "outlettype" : [ "bang", "bang", "" ], + "id" : "obj-30", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "click here to close the serial port", + "patching_rect" : [ 360.0, 291.0, 206.0, 20.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-26", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "click here to open the serial port", + "patching_rect" : [ 385.0, 265.0, 206.0, 20.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-27", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "close", + "patching_rect" : [ 312.0, 291.0, 39.0, 18.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-21", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "port a", + "patching_rect" : [ 334.0, 265.0, 41.0, 18.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-19", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "Click here to get a list of serial ports", + "patching_rect" : [ 405.0, 239.0, 207.0, 20.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-2", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "toggle", + "patching_rect" : [ 229.0, 155.0, 22.0, 22.0 ], + "numoutlets" : 1, + "outlettype" : [ "int" ], + "id" : "obj-11", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "qmetro 10", + "patching_rect" : [ 229.0, 200.0, 65.0, 20.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "bang" ], + "id" : "obj-12", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "print", + "patching_rect" : [ 354.0, 239.0, 36.0, 18.0 ], + "numoutlets" : 1, + "fontsize" : 12.0, + "outlettype" : [ "" ], + "id" : "obj-13", + "fontname" : "Arial", + "numinlets" : 2 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "serial a 9600", + "patching_rect" : [ 229.0, 315.0, 84.0, 20.0 ], + "numoutlets" : 2, + "fontsize" : 12.0, + "outlettype" : [ "int", "" ], + "id" : "obj-14", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "Read serial input buffer every 10 milliseconds", + "linecount" : 2, + "patching_rect" : [ 13.0, 192.0, 210.0, 34.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-15", + "fontname" : "Arial", + "numinlets" : 1 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "Click to start", + "patching_rect" : [ 256.0, 163.0, 117.0, 20.0 ], + "numoutlets" : 0, + "fontsize" : 12.0, + "id" : "obj-17", + "fontname" : "Arial", + "numinlets" : 1 + } + + } + ], + "lines" : [ { + "patchline" : { + "source" : [ "obj-12", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-11", 0 ], + "destination" : [ "obj-12", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-13", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ 363.5, 260.5, 238.5, 260.5 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-19", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ 343.5, 288.5, 238.5, 288.5 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-21", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ 321.5, 311.5, 238.5, 311.5 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-30", 0 ], + "destination" : [ "obj-21", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-30", 1 ], + "destination" : [ "obj-19", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-11", 0 ], + "destination" : [ "obj-30", 0 ], + "hidden" : 0, + "midpoints" : [ 238.5, 191.0, 321.5, 191.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-29", 2 ], + "destination" : [ "obj-3", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-29", 0 ], + "destination" : [ "obj-23", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-29", 1 ], + "destination" : [ "obj-22", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-14", 0 ], + "destination" : [ "obj-50", 1 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-50", 0 ], + "destination" : [ "obj-31", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-48", 0 ], + "destination" : [ "obj-53", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-53", 0 ], + "destination" : [ "obj-50", 0 ], + "hidden" : 0, + "midpoints" : [ 394.5, 426.0, 203.5, 426.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-14", 0 ], + "destination" : [ "obj-54", 1 ], + "hidden" : 0, + "midpoints" : [ 238.5, 342.0, 429.5, 342.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-54", 0 ], + "destination" : [ "obj-48", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-62", 0 ], + "destination" : [ "obj-39", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-3", 0 ], + "destination" : [ "obj-62", 2 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-22", 0 ], + "destination" : [ "obj-62", 1 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-23", 0 ], + "destination" : [ "obj-62", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-53", 0 ], + "destination" : [ "obj-55", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-55", 0 ], + "destination" : [ "obj-54", 0 ], + "hidden" : 0, + "midpoints" : [ 394.5, 459.0, 453.0, 459.0, 453.0, 351.0, 394.5, 351.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-30", 0 ], + "destination" : [ "obj-57", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-57", 0 ], + "destination" : [ "obj-53", 0 ], + "hidden" : 0, + "midpoints" : [ 319.5, 401.0, 394.5, 401.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-35", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ 203.5, 542.0, 167.0, 542.0, 167.0, 300.0, 238.5, 300.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-35", 1 ], + "destination" : [ "obj-29", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-31", 0 ], + "destination" : [ "obj-35", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-6", 0 ], + "destination" : [ "obj-9", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-53", 0 ], + "destination" : [ "obj-6", 0 ], + "hidden" : 0, + "midpoints" : [ 394.5, 431.5, 348.5, 431.5 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-9", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } + ] +} + + +*/ diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome.zip b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome.zip new file mode 100644 index 0000000..fbbc34d Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome.zip differ diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/.DS_Store b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/.DS_Store new file mode 100644 index 0000000..c877d4f Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/.DS_Store differ diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build.xml b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build.xml new file mode 100644 index 0000000..ee9af2c --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build.xml @@ -0,0 +1,83 @@ + + + + + + Builds, tests, and runs the project . + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/.timestamp b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/.timestamp new file mode 100644 index 0000000..999b584 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/.timestamp @@ -0,0 +1 @@ +ignore me \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/manifest.mf b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/manifest.mf new file mode 100644 index 0000000..d54b83d --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/manifest.mf @@ -0,0 +1,7 @@ +MIDlet-1: Arduhome,,com.netomarin.arduhome.core.ArduhomeMIDlet +MIDlet-Permissions: javax.microedition.io.Connector.bluetooth.client +MIDlet-Vendor: Globalcode - Eversource +MIDlet-Name: Arduhome +MIDlet-Version: 1.0 +MicroEdition-Configuration: CLDC-1.1 +MicroEdition-Profile: MIDP-2.0 diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/bt/BluetoothClientServer.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/bt/BluetoothClientServer.java new file mode 100644 index 0000000..0285fba --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/bt/BluetoothClientServer.java @@ -0,0 +1,200 @@ +package com.netomarin.arduhome.bt; + +import com.netomarin.arduhome.core.ArduhomeMIDlet; +import com.netomarin.arduhome.core.FlowManager; +import com.netomarin.arduhome.view.ConnectionForm; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.Vector; + +import javax.bluetooth.BluetoothStateException; +import javax.bluetooth.DeviceClass; +import javax.bluetooth.DiscoveryAgent; +import javax.bluetooth.DiscoveryListener; +import javax.bluetooth.LocalDevice; +import javax.bluetooth.RemoteDevice; +import javax.bluetooth.ServiceRecord; +import javax.bluetooth.UUID; +import javax.microedition.io.Connector; +import javax.microedition.io.StreamConnection; + +/** + * + * @author Neto Marin + */ +public class BluetoothClientServer implements DiscoveryListener { + UUID RFCOMM_UUID = new UUID(0x1101); + private StreamConnection streamConn = null; + private LocalDevice localDevice = null; + private InputStream is = null; + private InputStreamReader isr = null; + private OutputStream os = null; + private OutputStreamWriter osw = null; + private DiscoveryAgent discoveryAgent = null; + private RemoteDevice remoteDevice; + private Vector services; + private static BluetoothClientServer instance; + + private boolean connected = false; + + private BluetoothClientServer() { + } + + public static BluetoothClientServer getInstance() { + if (instance == null) { + instance = new BluetoothClientServer(); + } + + return instance; + } + + public void InitClient() { + SearchAvailDevices(); + + } + + public void SearchAvailDevices() { + try { + //First get the local device and obtain the discovery agent. + this.remoteDevice = null; + localDevice = LocalDevice.getLocalDevice(); + discoveryAgent = localDevice.getDiscoveryAgent(); + ConnectionForm.getInstance().updateGaugeStatus("Starting search..."); + discoveryAgent.startInquiry(DiscoveryAgent.GIAC, this); + } catch (BluetoothStateException ex) { + System.out.println("Problem in searching the blue tooth devices"); + ConnectionForm.getInstance().updateGaugeStatus("Error searching devics!!"); + ConnectionForm.getInstance().append(ex.getMessage()); + } + } + + public void sendMessage(byte[] messageToSend) { + try { + //osw.write(messageToSend); + //osw.flush(); + os.write(messageToSend); + os.flush(); + } catch (IOException ex) { + } + } + + public String RecieveMessages() { + byte[] data = null; + + try { + int length = is.read(); + data = new byte[length]; + length = 0; + + while (length != data.length) { + int ch = is.read(data, length, data.length - length); + + if (ch == -1) { + throw new IOException("Can't read data"); + } + length += ch; + } + } catch (IOException e) { + System.err.println(e); +// MainForm.updateConnectionStatus("Error receiving messages!"); + } + + return new String(data); + } + + /********************************************************************************************* + * below are the pure virtual methods of discoverlistern + * + * + *******************************************************************************************/ + //Called when device is found during inquiry + public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { + try { + // Get Device Info + boolean found = btDevice.getBluetoothAddress().equals(ArduhomeMIDlet.getCentralMacAddress()); + ConnectionForm.getInstance().updateGaugeStatus("Device found: " + btDevice.getBluetoothAddress() + + (found ? " - Central FOUND!" : " - not central device!")); + + if (found) { + ConnectionForm.getInstance().updateGaugeStatus("Central FOUND!"); + this.remoteDevice = btDevice; + return; + } + + } catch (Exception e) { + System.out.println("Device Discovered Error: " + e); + ConnectionForm.getInstance().updateGaugeStatus("Error on device discovered"); + ConnectionForm.getInstance().append(e.getMessage()); + } + } + + public void inquiryCompleted(int discType) { + if ( remoteDevice != null ) { + services = new Vector(); + UUID[] query = new UUID[1]; + query[0] = RFCOMM_UUID; + try { + discoveryAgent.searchServices(null, query, remoteDevice, this); + } catch (BluetoothStateException ex) { + ex.printStackTrace(); + } + } else { + ConnectionForm.getInstance().updateGaugeStatus("Central not found!"); + } + } + + + + //called when service found during service search + public void servicesDiscovered(int transID, ServiceRecord[] records) { + ConnectionForm.getInstance().updateGaugeStatus("Looking for RFCOMM channel!"); + for(int i = 0; i < records.length; i++) + this.services.addElement(records[i]); + ConnectionForm.getInstance().updateGaugeStatus("Service search completed!"); + } + + //called when service search gets complete + public void serviceSearchCompleted(int transID, int respCode) { + ConnectionForm.getInstance().updateGaugeStatus("callback serviceSearchCompleted"); + if ( remoteDevice != null) { + try { + ConnectionForm.getInstance().updateGaugeStatus("Starting connection..."); + //lets the communication start by setting the url and send client reponse + streamConn = (StreamConnection)Connector.open(((ServiceRecord)(services.elementAt(0))).getConnectionURL(0, false)); + ConnectionForm.getInstance().updateGaugeStatus("Opening communication..."); + os = streamConn.openOutputStream(); + osw = new OutputStreamWriter(os, "US-ASCII"); + is = streamConn.openInputStream(); + isr = new InputStreamReader(is, "US-ASCII"); + + this.connected = true; + + ConnectionForm.getInstance().updateGaugeStatus("Connection Stablished!"); + FlowManager.getInstance().showMainScreen(); + } catch (IOException ex) { + ConnectionForm.getInstance().updateGaugeStatus("Connection error!!"); + ConnectionForm.getInstance().append(ex.getMessage()); + } + + } else { + ConnectionForm.getInstance().updateGaugeStatus("Central not found..."); + } + } + + public void CloseAll() { + try { + if (os != null) { + os.close(); + } + + if (is != null) { + is.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/core/ArduhomeMIDlet.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/core/ArduhomeMIDlet.java new file mode 100644 index 0000000..ad7e732 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/core/ArduhomeMIDlet.java @@ -0,0 +1,44 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.core; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.view.ConnectionForm; +import javax.microedition.lcdui.Display; +import javax.microedition.midlet.*; + +/** + * @author neto + */ +public class ArduhomeMIDlet extends MIDlet { + + private static ArduhomeMIDlet instance; + private static String centralMacAddress; + + public void startApp() { + if ( instance == null ) + instance = this; + + centralMacAddress = FlowManager.loadSettings(); + Display.getDisplay(this).setCurrent(new ConnectionForm()); + BluetoothClientServer.getInstance().InitClient(); + } + + public void pauseApp() { + } + + public void destroyApp(boolean unconditional) { + this.notifyDestroyed(); + } + + public static ArduhomeMIDlet getInstance() { + return instance; + } + + public static String getCentralMacAddress() { + return centralMacAddress; + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/core/FlowManager.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/core/FlowManager.java new file mode 100644 index 0000000..d853acd --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/core/FlowManager.java @@ -0,0 +1,108 @@ +package com.netomarin.arduhome.core; + +import com.netomarin.arduhome.view.DimmerForm; +import com.netomarin.arduhome.view.MainForm; +import com.netomarin.arduhome.view.RGBForm; +import com.netomarin.arduhome.view.RelayForm; +import com.netomarin.arduhome.view.SettingsForm; +import javax.microedition.lcdui.Display; +import javax.microedition.rms.RecordStore; +import javax.microedition.rms.RecordStoreException; + +/** + * + * @author neto + */ +public class FlowManager { + + private static FlowManager instace; + private MainForm mainForm; + private RelayForm relayForm; + private DimmerForm dimmerForm; + private RGBForm rgbForm; + + private FlowManager() { + } + + public static FlowManager getInstance() { + if ( instace == null ) + instace = new FlowManager(); + + return instace; + } + + public void showMainScreen() { + if ( mainForm == null ) + mainForm = new MainForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(mainForm); + } + + public void showRelayForm() { + if ( relayForm == null ) + relayForm = new RelayForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(relayForm); + } + + public void showDimmerForm() { + if ( dimmerForm == null ) + this.dimmerForm = new DimmerForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(dimmerForm); + } + + public void showRGBForm() { + if ( rgbForm == null ) + this.rgbForm = new RGBForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(rgbForm); + } + + public void sendString(String stringToSend) { + + } + + public static String loadSettings() { + RecordStore db = null; + String macAddress = null; + + try { + db = RecordStore.openRecordStore("Settings", true); + if ( db.getNumRecords() > 0 ) { + macAddress = new String(db.getRecord(0)); + } else { + macAddress = SettingsForm.DEFAULT_MAC; + } + } catch (RecordStoreException ex) { + ex.printStackTrace(); + } finally { + try { + db.closeRecordStore(); + } catch (RecordStoreException ex) {} + } + + return macAddress; + } + + public static void saveSettings(String macAddress) { + RecordStore db = null; + + try { + db = RecordStore.openRecordStore("Settings", true); + + if ( db.getNumRecords() > 0 ) { + db.setRecord(0, macAddress.getBytes(), 0, macAddress.getBytes().length); + } else { + db.addRecord(macAddress.getBytes(), 0, macAddress.getBytes().length); + } + + } catch (RecordStoreException ex) { + ex.printStackTrace(); + } finally { + try { + db.closeRecordStore(); + } catch (RecordStoreException ex) {} + } + } +} diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/ConnectionForm.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/ConnectionForm.java new file mode 100644 index 0000000..b414697 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/ConnectionForm.java @@ -0,0 +1,62 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.core.ArduhomeMIDlet; +import java.io.IOException; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Gauge; +import javax.microedition.lcdui.Image; +import javax.microedition.lcdui.ImageItem; +import javax.microedition.lcdui.Item; + +/** + * + * @author neto + */ +public class ConnectionForm extends Form implements CommandListener { + + private Gauge gauge; + private ImageItem logoItem; + private Command exitCommand = new Command("Exit", Command.EXIT, 0); + + private static ConnectionForm instance; + + public ConnectionForm() { + super("Connecting"); + instance = this; + try { + logoItem = new ImageItem(null, Image.createImage("arduhomelogo.png"), Item.LAYOUT_VCENTER | Item.LAYOUT_CENTER, null); + this.append(logoItem); + } catch (IOException ex) { + ex.printStackTrace(); + } + + + this.gauge = new Gauge("Conectando a Central...", false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING); + this.append(gauge); + + this.addCommand(exitCommand); + this.setCommandListener(this); + } + + public static ConnectionForm getInstance() { + return instance; + } + + public void commandAction(Command cmnd, Displayable dsplbl) { + if ( cmnd.equals(exitCommand)) { + ArduhomeMIDlet.getInstance().destroyApp(true); + } + } + + public void updateGaugeStatus(String status) { + gauge.setLabel(status); + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/DimmerForm.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/DimmerForm.java new file mode 100644 index 0000000..9e27baf --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/DimmerForm.java @@ -0,0 +1,74 @@ +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.FlowManager; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Gauge; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.ItemCommandListener; +import javax.microedition.lcdui.ItemStateListener; +import javax.microedition.lcdui.StringItem; + +/** + * + * @author netomarin + */ +public class DimmerForm extends Form implements CommandListener, ItemCommandListener, ItemStateListener { + + private Gauge dimmerGauge = new Gauge("Dimmer", true, 9, 0); + + private Command sendCommand = new Command("Send", Command.OK, 0); + private Command backCommand = new Command("Back", Command.BACK, 0); + + private StringItem statusItem = new StringItem("Command sent:", null); + + public DimmerForm() { + super("Dimmer Control"); + + this.append(dimmerGauge); + this.setItemStateListener(this); + this.append(statusItem); + + this.addCommand(backCommand); + this.setCommandListener(this); + + //reseting dimmer + ByteArrayOutputStream bous = new ByteArrayOutputStream(); + bous.write((byte)'B'); + bous.write(9); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + } + + public void commandAction(Command command, Displayable displayable) { + if ( command.equals(backCommand)) { + FlowManager.getInstance().showMainScreen(); + } + } + + public void commandAction(Command cmnd, Item item) { + //throw new UnsupportedOperationException("Not supported yet."); + } + + public void itemStateChanged(Item item) { + if (item.equals(dimmerGauge)) { + try { + ByteArrayOutputStream bous = new ByteArrayOutputStream(); + bous.write((int)'B'); + int dimmerValue = dimmerGauge.getValue(); + if ( dimmerValue == 0 ) + dimmerValue = 9; + bous.write(dimmerValue); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + this.statusItem.setText("B" + dimmerGauge.getValue()); + bous.close(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + } +} diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/MainForm.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/MainForm.java new file mode 100644 index 0000000..90d9bf8 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/MainForm.java @@ -0,0 +1,57 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.ArduhomeMIDlet; +import com.netomarin.arduhome.core.FlowManager; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Display; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.List; + +/** + * + * @author neto + */ +public class MainForm extends List implements CommandListener { + + private Command exitCommand = new Command("Exit", Command.EXIT, 0); + private Command selectCommand = new Command("Select", Command.OK, 1); + private Command settingsCommand = new Command("Settings", Command.SCREEN, 2); + + public MainForm() { + super("Arduhome", List.IMPLICIT, new String[]{"Relay", "Dimmer", "RGB Leds"}, null); + + this.setSelectCommand(selectCommand); + this.addCommand(settingsCommand); + this.addCommand(exitCommand); + this.setCommandListener(this); + } + + public void commandAction(Command cmnd, Displayable dsplbl) { + if ( cmnd.equals(exitCommand) ) { + BluetoothClientServer.getInstance().CloseAll(); + ArduhomeMIDlet.getInstance().destroyApp(true); + } else if ( cmnd.equals(settingsCommand) ) { + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(new SettingsForm()); + } else if ( cmnd.equals(selectCommand) ) { + switch (this.getSelectedIndex() ) { + case 0: + FlowManager.getInstance().showRelayForm(); + break; + case 1: + FlowManager.getInstance().showDimmerForm(); + break; + case 2: + FlowManager.getInstance().showRGBForm(); + break; + } + + } + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/RGBForm.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/RGBForm.java new file mode 100644 index 0000000..e696714 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/RGBForm.java @@ -0,0 +1,76 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.FlowManager; +import java.io.ByteArrayOutputStream; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Gauge; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.ItemStateListener; +import javax.microedition.lcdui.StringItem; + +/** + * + * @author neto + */ +public class RGBForm extends Form implements CommandListener, ItemStateListener { + + private Gauge rGauge = new Gauge("Red", true, 9, 0); + private Gauge gGauge = new Gauge("Green", true, 9, 0); + private Gauge bGauge = new Gauge("Blue", true, 9, 0); + + private StringItem statusItem = new StringItem("Command sent:", null); + + private Command backCommand = new Command("Back", Command.BACK, 0); + + public RGBForm() { + super("RGB Leds"); + + this.append(rGauge); + this.append(gGauge); + this.append(bGauge); + this.setItemStateListener(this); + + this.append(statusItem); + + this.addCommand(backCommand); + this.setCommandListener(this); + } + + public void commandAction(Command command, Displayable displayable) { + if ( command.equals(backCommand)) { + FlowManager.getInstance().showMainScreen(); + } + } + + public void itemStateChanged(Item item) { + if (item instanceof Gauge) { + ByteArrayOutputStream bous = new ByteArrayOutputStream(); + bous.write((int)'C'); + bous.write((int)'R'); + bous.write((int)rGauge.getValue()); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + bous.write((int)'C'); + bous.write((int)'R'); + + bous.write((int)gGauge.getValue()); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + + bous.write((int)'C'); + bous.write((int)'R'); + bous.write((int)bGauge.getValue()); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + + this.statusItem.setText("C" + (byte)rGauge.getValue() + (byte)gGauge.getValue() + (byte)bGauge.getValue()); + } + } + +} diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/RelayForm.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/RelayForm.java new file mode 100644 index 0000000..283b5da --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/RelayForm.java @@ -0,0 +1,76 @@ +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.FlowManager; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.ItemCommandListener; +import javax.microedition.lcdui.StringItem; + +/** + * + * @author neto + */ +public class RelayForm extends Form implements CommandListener, ItemCommandListener { + + private Command backCommand = new Command("Back", Command.BACK, 0); + private Command buttonCommand = new Command("Execute", Command.OK, 0); + + private StringItem lightState = new StringItem(null, "Turn ON", Item.BUTTON); + private StringItem discoMode = new StringItem(null, "DISCO!!", Item.BUTTON); + + private boolean lightOn = false; + private boolean discoOn = false; + String msg = null; + + public RelayForm() { + super("Relay Control"); + + this.lightState.setLayout(Item.LAYOUT_NEWLINE_AFTER); + + this.append(lightState); + this.append(discoMode); + lightState.setDefaultCommand(buttonCommand); + lightState.setItemCommandListener(this); + discoMode.setDefaultCommand(buttonCommand); + discoMode.setItemCommandListener(this); + + this.addCommand(backCommand); + this.setCommandListener(this); + } + + public void commandAction(Command command, Displayable displayable) { + if ( command.equals(backCommand)) { + FlowManager.getInstance().showMainScreen(); + } + } + + public void commandAction(Command command, Item item) { + if ( item.equals(lightState)) { + if ( lightOn ) { + msg = "A+A"; + lightState.setText("Turn OFF"); + } else { + msg = "A-A"; + lightState.setText("Turn ON"); + } + + lightOn = !lightOn; + } else if ( item.equals(discoMode)) { + if ( discoOn ) { + msg = "A+C"; + lightState.setText("STOP Disco!"); + } else { + msg = "A-C"; + lightState.setText("DISCO!!"); + } + + discoOn = !discoOn; + } + + BluetoothClientServer.getInstance().sendMessage(msg.getBytes()); + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/SettingsForm.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/SettingsForm.java new file mode 100644 index 0000000..049d49f --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/build/preprocessed/com/netomarin/arduhome/view/SettingsForm.java @@ -0,0 +1,46 @@ +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.core.FlowManager; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.TextField; + +/** + * + * @author neto + */ +public class SettingsForm extends Form implements CommandListener { + + //public static final String DEFAULT_MAC = "0006660412A9"; //bluesmirf + public static final String DEFAULT_MAC = "00066604127D"; //bluesmirf + //public static final String DEFAULT_MAC = "000666041225"; //bluesmirf + + private Command backCommand = new Command("Back", Command.BACK, 0); + private Command saveCommand = new Command("Save", Command.OK, 1); + + private TextField macAddressTextField; + + public SettingsForm() { + super("Settings"); + + String macAddress = FlowManager.loadSettings(); + macAddressTextField = new TextField("Bluetooth: ", + macAddress == null ? DEFAULT_MAC : macAddress, 12, TextField.ANY); + this.append(macAddressTextField); + + this.setCommandListener(this); + this.addCommand(backCommand); + this.addCommand(saveCommand); + } + + public void commandAction(Command cmnd, Displayable dsplbl) { + if ( cmnd.equals(backCommand) ) { + FlowManager.getInstance().showMainScreen(); + } else if ( cmnd.equals(saveCommand)) { + FlowManager.saveSettings(macAddressTextField.getString()); + FlowManager.getInstance().showMainScreen(); + } + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/dist/Arduhome.jad b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/dist/Arduhome.jad new file mode 100644 index 0000000..ca37a2f --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/dist/Arduhome.jad @@ -0,0 +1,9 @@ +MIDlet-1: Arduhome,,com.netomarin.arduhome.core.ArduhomeMIDlet +MIDlet-Jar-Size: 16116 +MIDlet-Jar-URL: Arduhome.jar +MIDlet-Name: Arduhome +MIDlet-Permissions: javax.microedition.io.Connector.bluetooth.client +MIDlet-Vendor: Globalcode - Eversource +MIDlet-Version: 1.0 +MicroEdition-Configuration: CLDC-1.1 +MicroEdition-Profile: MIDP-2.0 diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/build-impl.xml b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/build-impl.xml new file mode 100644 index 0000000..7763b1b --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/build-impl.xml @@ -0,0 +1,1247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Classpath to J2ME Ant extension library (libs.j2me_ant_ext.classpath property) is not set. For example: location of mobility/modules/org-netbeans-mobility-antext.jar file in the IDE installation directory. + Platform home (platform.home property) is not set. Value of this property should be ${platform.active.description} emulator home directory location. + Platform boot classpath (platform.bootclasspath property) is not set. Value of this property should be ${platform.active.description} emulator boot classpath containing all J2ME classes provided by emulator. + Must set src.dir + Must set build.dir + Must set dist.dir + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set preprocessed.dir + + + + + + + + + + + + + + + + + + Must set build.classes.dir + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + Must set obfuscated.classes.dir + + + + Must set obfuscated.classes.dir + Must set obfuscator.srcjar + Must set obfuscator.destjar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set preverify.classes.dir + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MicroEdition-Configuration: ${platform.configuration} + + MicroEdition-Configuration: ${platform.configuration} + + + + MicroEdition-Profile: ${platform.profile} + + MicroEdition-Profile: ${platform.profile} + + + + Must set dist.jad + + + + + + + + + + + + + + + + + + + + + + + + ${manifest.midlets}${evaluated.manifest.apipermissions}${evaluated.manifest.pushregistry}${manifest.others}${manifest.jad} + ${manifest.midlets}${evaluated.manifest.apipermissions}${evaluated.manifest.pushregistry}${manifest.others}${manifest.manifest} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Starting emulator with port number ${active.debug.port} + + + + + + + + + + + + + + + + + Starting emulator with port number ${active.debug.port} + + + + + + + + + + + + + + + + + Must set dist.javadoc.dir + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${all.configurations} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property deployment.${deployment.method}.scriptfile not set. The property should point to an Ant script providing ${deployment.method} deployment. + + + + + + + + Classpath to Ant Contrib library (libs.ant-contrib.classpath property) is not set. + + + + + + + + + Active project configuration: @{cfg} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property build.root.dir is not set. By default its value should be \"build\". + Property dist.root.dir is not set. By default its value should be \"dist\". + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/genfiles.properties b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/genfiles.properties new file mode 100644 index 0000000..166b8a6 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +build.xml.data.CRC32=6394fea5 +build.xml.script.CRC32=f4991ba4 +build.xml.stylesheet.CRC32=9c6a911d +nbproject/build-impl.xml.data.CRC32=6394fea5 +nbproject/build-impl.xml.script.CRC32=97fa5ec4 +nbproject/build-impl.xml.stylesheet.CRC32=e46c2d22 diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/private/private.properties b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/private/private.properties new file mode 100644 index 0000000..480594c --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/private/private.properties @@ -0,0 +1,8 @@ +#Wed, 12 Sep 2012 11:58:51 -0300 +#Sat Aug 28 14:40:55 BRT 2010 +netbeans.user=/home/vsenger/.netbeans/7.2 +javadoc.preview=true +config.active= +deployment.counter=86 +app-version.autoincrement=true +deployment.number=0.0.85 diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/private/private.xml b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/private/private.xml new file mode 100644 index 0000000..c1f155a --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/project.properties b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/project.properties new file mode 100644 index 0000000..b2f15d1 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/project.properties @@ -0,0 +1,144 @@ +abilities=MMAPI=1.2,JSR82=1.1,JSR280=1.0,JSR226=1.0,MIDP=2.1,JSR229=1.1,SATSA=1.0,CLDC=1.1,JSR177=1.0,JSR179=1.0,J2MEWS=1.0,WMA=2.0,JSR172=1.0,JSR256=1.2,OBEX=1.0,ColorScreen,JSR238=1.0,TouchScreen,JSR211=1.0,ScreenWidth=240,JSR75=1.0,JSR184=1.1,ScreenHeight=320,ScreenColorDepth=16,JSR180=1.1.0, +all.configurations=\ +application.args= +application.description= +application.description.detail= +application.name= +application.vendor=Vendor +build.classes.dir=${build.dir}/compiled +build.classes.excludes=**/*.java,**/*.form,**/*.class,**/.nbintdb,**/*.mvd,**/*.wsclient,**/*.vmd +build.dir=build/${config.active} +build.root.dir=build +debug.level=debug +debugger.timeout= +deployment.copy.target=${file.reference.site-jme} +deployment.instance=default +deployment.jarurl=${dist.jar} +deployment.method=Copy +deployment.override.jarurl=false +dist.dir=dist/${config.active} +dist.jad=Arduhome.jad +dist.jar=Arduhome.jar +dist.javadoc.dir=${dist.dir}/doc +dist.root.dir=dist +extra.classpath= +file.reference.builtin.ks=${netbeans.user}/config/j2me/builtin.ks +file.reference.site-jme=../../../../../../../var/www/site/jme +filter.exclude.tests=false +filter.excludes= +filter.more.excludes=**/overview.html,**/package.html +filter.use.standard=true +jar.compress=true +javac.debug=true +javac.deprecation=false +javac.encoding=UTF-8 +javac.optimize=false +javac.source=1.3 +javac.target=1.3 +javadoc.author=false +javadoc.encoding= +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +libs.classpath=${libs.JMUnit4CLDC10.classpath} +main.class= +main.class.class=applet +manifest.apipermissions=MIDlet-Permissions: javax.microedition.io.Connector.bluetooth.client\n +manifest.file=manifest.mf +manifest.is.liblet=false +manifest.jad= +manifest.manifest= +manifest.midlets=MIDlet-1: Arduhome,,com.netomarin.arduhome.core.ArduhomeMIDlet\n +manifest.others=MIDlet-Vendor: Globalcode - Eversource\nMIDlet-Name: Arduhome\nMIDlet-Version: 1.0\n +manifest.pushregistry= +name=Arduhome +no.dependencies=false +nokiaS80.application.icon= +nsicom.application.monitorhost= +nsicom.application.runremote= +nsicom.application.runverbose= +nsicom.remoteapp.location=\\My Documents\\NetBeans Applications +nsicom.remotevm.location=\\Windows\\creme\\bin\\CrEme.exe +obfuscated.classes.dir=${build.dir}/obfuscated +obfuscation.custom= +obfuscation.level=0 +obfuscator.destjar=${build.dir}/obfuscated.jar +obfuscator.srcjar=${build.dir}/before-obfuscation.jar +platform.active=Sun_Java_TM__Wireless_Toolkit_2_5_2_01_for_CLDC +platform.active.description=Sun Java(TM) Wireless Toolkit 2.5.2_01 for CLDC +platform.apis=JSR238-1.0,WMA-2.0,MMAPI-1.1,JSR211-1.0,JSR179-1.0.1,OBEX-1.0,JSR177-1.0,JSR234-1.0,SATSA-APDU-1.0,JSR75-1.0,J2ME-WS-1.0,J2ME-XMLRPC-1.0,SATSA-JCRMI-1.0,SATSA-CRYPTO-1.0,JSR239-1.0,JSR184-1.1,JSR229-1.1.0,SATSA-PKI-1.0,JSR180-1.0.1,JSR226-1.0 +platform.bootclasspath=${platform.home}/lib/jsr226.jar:${platform.home}/lib/satsa-crypto.jar:${platform.home}/lib/jsr229.jar:${platform.home}/lib/jsr238.jar:${platform.home}/lib/j2me-xmlrpc.jar:${platform.home}/lib/jsr211.jar:${platform.home}/lib/satsa-jcrmi.jar:${platform.home}/lib/satsa-apdu.jar:${platform.home}/lib/jsr082.jar:${platform.home}/lib/jsr184.jar:${platform.home}/lib/jsr239.jar:${platform.home}/lib/jsr75.jar:${platform.home}/lib/jsr179.jar:${platform.home}/lib/satsa-pki.jar:${platform.home}/lib/jsr180.jar:${platform.home}/lib/mmapi.jar:${platform.home}/lib/j2me-ws.jar:${platform.home}/lib/wma20.jar:${platform.home}/lib/jsr234.jar:${platform.home}/lib/cldcapi11.jar:${platform.home}/lib/midpapi20.jar +platform.configuration=CLDC-1.1 +platform.device=QwertyDevice +platform.fat.jar=true +platform.profile=MIDP-2.0 +platform.trigger=CLDC +platform.type=UEI-1.0.1 +preprocessed.dir=${build.dir}/preprocessed +preverify.classes.dir=${build.dir}/preverified +preverify.sources.dir=${build.dir}/preverifysrc +resources.dir=resources +ricoh.application.email= +ricoh.application.fax= +ricoh.application.icon= +ricoh.application.target-jar= +ricoh.application.telephone= +ricoh.application.uid=81936294 +ricoh.application.version= +ricoh.dalp.application-desc.auto-run=false +ricoh.dalp.application-desc.energy-save= +ricoh.dalp.application-desc.exec-auth= +ricoh.dalp.application-desc.visible=true +ricoh.dalp.argument= +ricoh.dalp.codebase= +ricoh.dalp.display-mode.color=true +ricoh.dalp.display-mode.is-4line-support=false +ricoh.dalp.display-mode.is-hvga-support=true +ricoh.dalp.display-mode.is-vga-support=false +ricoh.dalp.display-mode.is-wvga-support=false +ricoh.dalp.information.abbreviation= +ricoh.dalp.information.icon.basepath= +ricoh.dalp.information.icon.location= +ricoh.dalp.information.is-icon-used=true +ricoh.dalp.install.destination=hdd +ricoh.dalp.install.mode.auto=true +ricoh.dalp.install.work-dir=hdd +ricoh.dalp.is-managed=true +ricoh.dalp.resources.dsdk.version=2.0 +ricoh.dalp.resources.jar.basepath= +ricoh.dalp.resources.jar.version= +ricoh.dalp.version= +ricoh.icon.invert=false +ricoh.platform.target.version= +run.cmd.options= +run.jvmargs= +run.method=STANDARD +run.security.domain=manufacturer +run.use.security.domain=false +savaje.application.icon= +savaje.application.icon.focused= +savaje.application.icon.small= +savaje.application.uid=TBD +savaje.bundle.base= +savaje.bundle.debug=false +savaje.bundle.debug.port= +semc.application.caps= +semc.application.icon= +semc.application.icon.count= +semc.application.icon.splash= +semc.application.icon.splash.installonly=false +semc.application.uid=E3212324 +semc.certificate.path= +semc.private.key.password= +semc.private.key.path= +sign.alias=minimal +sign.enabled=false +sign.keystore=${file.reference.builtin.ks} +src.dir=src +use.emptyapis=true +use.preprocessor=true diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/project.xml b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/project.xml new file mode 100644 index 0000000..dbd8432 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/nbproject/project.xml @@ -0,0 +1,10 @@ + + + org.netbeans.modules.kjava.j2meproject + + + Arduhome + 1.6 + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/res/.DS_Store b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/res/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/res/.DS_Store differ diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/res/arduhomeicon.png b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/res/arduhomeicon.png new file mode 100644 index 0000000..41237ed Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/res/arduhomeicon.png differ diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/res/arduhomelogo.png b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/res/arduhomelogo.png new file mode 100644 index 0000000..1a2307c Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/res/arduhomelogo.png differ diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/res/logo.gif b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/res/logo.gif new file mode 100644 index 0000000..fae584e Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/res/logo.gif differ diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/bt/BluetoothClientServer.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/bt/BluetoothClientServer.java new file mode 100644 index 0000000..c850d53 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/bt/BluetoothClientServer.java @@ -0,0 +1,201 @@ +package com.netomarin.arduhome.bt; + +import com.netomarin.arduhome.core.ArduhomeMIDlet; +import com.netomarin.arduhome.core.FlowManager; +import com.netomarin.arduhome.view.ConnectionForm; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.Vector; + +import javax.bluetooth.BluetoothStateException; +import javax.bluetooth.DeviceClass; +import javax.bluetooth.DiscoveryAgent; +import javax.bluetooth.DiscoveryListener; +import javax.bluetooth.LocalDevice; +import javax.bluetooth.RemoteDevice; +import javax.bluetooth.ServiceRecord; +import javax.bluetooth.UUID; +import javax.microedition.io.Connector; +import javax.microedition.io.StreamConnection; + +/** + * + * @author Neto Marin + */ +public class BluetoothClientServer implements DiscoveryListener { + + UUID RFCOMM_UUID = new UUID(0x1101); + private StreamConnection streamConn = null; + private LocalDevice localDevice = null; + private InputStream is = null; + private InputStreamReader isr = null; + private OutputStream os = null; + private OutputStreamWriter osw = null; + private DiscoveryAgent discoveryAgent = null; + private RemoteDevice remoteDevice; + private Vector services; + private static BluetoothClientServer instance; + private boolean connected = false; + + private BluetoothClientServer() { + } + + public static BluetoothClientServer getInstance() { + if (instance == null) { + instance = new BluetoothClientServer(); + } + + return instance; + } + + public void initClient() { + searchAvailDevices(); + + } + + public void searchAvailDevices() { + try { + //First get the local device and obtain the discovery agent. + this.remoteDevice = null; + localDevice = LocalDevice.getLocalDevice(); + discoveryAgent = localDevice.getDiscoveryAgent(); + ConnectionForm.getInstance().updateGaugeStatus("Starting search..."); + discoveryAgent.startInquiry(DiscoveryAgent.GIAC, this); + } catch (BluetoothStateException ex) { + System.out.println("Problem in searching the blue tooth devices"); + ConnectionForm.getInstance().updateGaugeStatus("Error searching devics!!"); + ConnectionForm.getInstance().append(ex.getMessage()); + } + } + + public void sendMessage(byte[] messageToSend) { + try { + //osw.write(messageToSend); + //osw.flush(); + os.write(messageToSend); + os.flush(); + } catch (IOException ex) { + } + } + + public String RecieveMessages() { + byte[] data = null; + + try { + int length = is.read(); + data = new byte[length]; + length = 0; + + while (length != data.length) { + int ch = is.read(data, length, data.length - length); + + if (ch == -1) { + throw new IOException("Can't read data"); + } + length += ch; + } + } catch (IOException e) { + System.err.println(e); +// MainForm.updateConnectionStatus("Error receiving messages!"); + } + + return new String(data); + } + + /** + * ******************************************************************************************* + * below are the pure virtual methods of discoverlistern + * + * + ****************************************************************************************** + */ + //Called when device is found during inquiry + public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { + try { + // Get Device Info + boolean found = btDevice.getBluetoothAddress().equals(ArduhomeMIDlet.getCentralMacAddress()); + ConnectionForm.getInstance().updateGaugeStatus("Device found: " + btDevice.getBluetoothAddress() + + (found ? " - Central FOUND!" : " - not central device!")); + + if (found) { + ConnectionForm.getInstance().updateGaugeStatus("Central FOUND!"); + this.remoteDevice = btDevice; + return; + } + + } catch (Exception e) { + System.out.println("Device Discovered Error: " + e); + ConnectionForm.getInstance().updateGaugeStatus("Error on device discovered"); + ConnectionForm.getInstance().append(e.getMessage()); + } + } + + public void inquiryCompleted(int discType) { + if (remoteDevice != null) { + services = new Vector(); + UUID[] query = new UUID[1]; + query[0] = RFCOMM_UUID; + try { + discoveryAgent.searchServices(null, query, remoteDevice, this); + } catch (BluetoothStateException ex) { + ex.printStackTrace(); + } + } else { + ConnectionForm.getInstance().updateGaugeStatus("Central not found!"); + } + } + + //called when service found during service search + public void servicesDiscovered(int transID, ServiceRecord[] records) { + ConnectionForm.getInstance().updateGaugeStatus("Looking for RFCOMM channel!"); + for (int i = 0; i < records.length; i++) { + this.services.addElement(records[i]); + } + ConnectionForm.getInstance().updateGaugeStatus("Service search completed!"); + } + + //called when service search gets complete + public void serviceSearchCompleted(int transID, int respCode) { + ConnectionForm.getInstance().updateGaugeStatus("callback serviceSearchCompleted"); + if (remoteDevice != null) { + try { + ConnectionForm.getInstance().updateGaugeStatus("Starting connection..."); + //lets the communication start by setting the url and send client reponse + streamConn = (StreamConnection) Connector.open(((ServiceRecord) (services.elementAt(0))).getConnectionURL(0, false)); + ConnectionForm.getInstance().updateGaugeStatus("Opening communication..."); + os = streamConn.openOutputStream(); + osw = new OutputStreamWriter(os, "US-ASCII"); + is = streamConn.openInputStream(); + isr = new InputStreamReader(is, "US-ASCII"); + + this.connected = true; + + ConnectionForm.getInstance().updateGaugeStatus("Connection Stablished!"); + FlowManager.getInstance().showMainScreen(); + } catch (IOException ex) { + ConnectionForm.getInstance().updateGaugeStatus("Connection error!!"); + ConnectionForm.getInstance().append(ex.getMessage()); + } + + } else { + ConnectionForm.getInstance().updateGaugeStatus("Central not found..."); + } + } + + public void CloseAll() { + try { + if (os != null) { + os.close(); + } + + if (is != null) { + is.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/bt/NewEmptyJMUnitTest.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/bt/NewEmptyJMUnitTest.java new file mode 100644 index 0000000..e9b2d5b --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/bt/NewEmptyJMUnitTest.java @@ -0,0 +1,23 @@ +/* + * NewEmptyJMUnitTest.java + * JMUnit based test + * + * Created on 12/09/2012, 14:37:41 + */ +package com.netomarin.arduhome.bt; + +import jmunit.framework.cldc10.*; + +/** + * @author vsenger + */ +public class NewEmptyJMUnitTest extends TestCase { + + public NewEmptyJMUnitTest() { + //The first parameter of inherited constructor is the number of test cases + super(0, "NewEmptyJMUnitTest"); + } + + public void test(int testNumber) throws Throwable { + } +} diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/core/ArduhomeMIDlet.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/core/ArduhomeMIDlet.java new file mode 100644 index 0000000..24e13b4 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/core/ArduhomeMIDlet.java @@ -0,0 +1,44 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.core; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.view.ConnectionForm; +import javax.microedition.lcdui.Display; +import javax.microedition.midlet.*; + +/** + * @author neto + */ +public class ArduhomeMIDlet extends MIDlet { + + private static ArduhomeMIDlet instance; + private static String centralMacAddress; + + public void startApp() { + if ( instance == null ) + instance = this; + + centralMacAddress = FlowManager.loadSettings(); + Display.getDisplay(this).setCurrent(new ConnectionForm()); + BluetoothClientServer.getInstance().initClient(); + } + + public void pauseApp() { + } + + public void destroyApp(boolean unconditional) { + this.notifyDestroyed(); + } + + public static ArduhomeMIDlet getInstance() { + return instance; + } + + public static String getCentralMacAddress() { + return centralMacAddress; + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/core/FlowManager.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/core/FlowManager.java new file mode 100644 index 0000000..d853acd --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/core/FlowManager.java @@ -0,0 +1,108 @@ +package com.netomarin.arduhome.core; + +import com.netomarin.arduhome.view.DimmerForm; +import com.netomarin.arduhome.view.MainForm; +import com.netomarin.arduhome.view.RGBForm; +import com.netomarin.arduhome.view.RelayForm; +import com.netomarin.arduhome.view.SettingsForm; +import javax.microedition.lcdui.Display; +import javax.microedition.rms.RecordStore; +import javax.microedition.rms.RecordStoreException; + +/** + * + * @author neto + */ +public class FlowManager { + + private static FlowManager instace; + private MainForm mainForm; + private RelayForm relayForm; + private DimmerForm dimmerForm; + private RGBForm rgbForm; + + private FlowManager() { + } + + public static FlowManager getInstance() { + if ( instace == null ) + instace = new FlowManager(); + + return instace; + } + + public void showMainScreen() { + if ( mainForm == null ) + mainForm = new MainForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(mainForm); + } + + public void showRelayForm() { + if ( relayForm == null ) + relayForm = new RelayForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(relayForm); + } + + public void showDimmerForm() { + if ( dimmerForm == null ) + this.dimmerForm = new DimmerForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(dimmerForm); + } + + public void showRGBForm() { + if ( rgbForm == null ) + this.rgbForm = new RGBForm(); + + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(rgbForm); + } + + public void sendString(String stringToSend) { + + } + + public static String loadSettings() { + RecordStore db = null; + String macAddress = null; + + try { + db = RecordStore.openRecordStore("Settings", true); + if ( db.getNumRecords() > 0 ) { + macAddress = new String(db.getRecord(0)); + } else { + macAddress = SettingsForm.DEFAULT_MAC; + } + } catch (RecordStoreException ex) { + ex.printStackTrace(); + } finally { + try { + db.closeRecordStore(); + } catch (RecordStoreException ex) {} + } + + return macAddress; + } + + public static void saveSettings(String macAddress) { + RecordStore db = null; + + try { + db = RecordStore.openRecordStore("Settings", true); + + if ( db.getNumRecords() > 0 ) { + db.setRecord(0, macAddress.getBytes(), 0, macAddress.getBytes().length); + } else { + db.addRecord(macAddress.getBytes(), 0, macAddress.getBytes().length); + } + + } catch (RecordStoreException ex) { + ex.printStackTrace(); + } finally { + try { + db.closeRecordStore(); + } catch (RecordStoreException ex) {} + } + } +} diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/ConnectionForm.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/ConnectionForm.java new file mode 100644 index 0000000..b414697 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/ConnectionForm.java @@ -0,0 +1,62 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.core.ArduhomeMIDlet; +import java.io.IOException; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Gauge; +import javax.microedition.lcdui.Image; +import javax.microedition.lcdui.ImageItem; +import javax.microedition.lcdui.Item; + +/** + * + * @author neto + */ +public class ConnectionForm extends Form implements CommandListener { + + private Gauge gauge; + private ImageItem logoItem; + private Command exitCommand = new Command("Exit", Command.EXIT, 0); + + private static ConnectionForm instance; + + public ConnectionForm() { + super("Connecting"); + instance = this; + try { + logoItem = new ImageItem(null, Image.createImage("arduhomelogo.png"), Item.LAYOUT_VCENTER | Item.LAYOUT_CENTER, null); + this.append(logoItem); + } catch (IOException ex) { + ex.printStackTrace(); + } + + + this.gauge = new Gauge("Conectando a Central...", false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING); + this.append(gauge); + + this.addCommand(exitCommand); + this.setCommandListener(this); + } + + public static ConnectionForm getInstance() { + return instance; + } + + public void commandAction(Command cmnd, Displayable dsplbl) { + if ( cmnd.equals(exitCommand)) { + ArduhomeMIDlet.getInstance().destroyApp(true); + } + } + + public void updateGaugeStatus(String status) { + gauge.setLabel(status); + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/DimmerForm.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/DimmerForm.java new file mode 100644 index 0000000..9e27baf --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/DimmerForm.java @@ -0,0 +1,74 @@ +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.FlowManager; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Gauge; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.ItemCommandListener; +import javax.microedition.lcdui.ItemStateListener; +import javax.microedition.lcdui.StringItem; + +/** + * + * @author netomarin + */ +public class DimmerForm extends Form implements CommandListener, ItemCommandListener, ItemStateListener { + + private Gauge dimmerGauge = new Gauge("Dimmer", true, 9, 0); + + private Command sendCommand = new Command("Send", Command.OK, 0); + private Command backCommand = new Command("Back", Command.BACK, 0); + + private StringItem statusItem = new StringItem("Command sent:", null); + + public DimmerForm() { + super("Dimmer Control"); + + this.append(dimmerGauge); + this.setItemStateListener(this); + this.append(statusItem); + + this.addCommand(backCommand); + this.setCommandListener(this); + + //reseting dimmer + ByteArrayOutputStream bous = new ByteArrayOutputStream(); + bous.write((byte)'B'); + bous.write(9); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + } + + public void commandAction(Command command, Displayable displayable) { + if ( command.equals(backCommand)) { + FlowManager.getInstance().showMainScreen(); + } + } + + public void commandAction(Command cmnd, Item item) { + //throw new UnsupportedOperationException("Not supported yet."); + } + + public void itemStateChanged(Item item) { + if (item.equals(dimmerGauge)) { + try { + ByteArrayOutputStream bous = new ByteArrayOutputStream(); + bous.write((int)'B'); + int dimmerValue = dimmerGauge.getValue(); + if ( dimmerValue == 0 ) + dimmerValue = 9; + bous.write(dimmerValue); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + this.statusItem.setText("B" + dimmerGauge.getValue()); + bous.close(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + } +} diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/MainForm.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/MainForm.java new file mode 100644 index 0000000..90d9bf8 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/MainForm.java @@ -0,0 +1,57 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.ArduhomeMIDlet; +import com.netomarin.arduhome.core.FlowManager; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Display; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.List; + +/** + * + * @author neto + */ +public class MainForm extends List implements CommandListener { + + private Command exitCommand = new Command("Exit", Command.EXIT, 0); + private Command selectCommand = new Command("Select", Command.OK, 1); + private Command settingsCommand = new Command("Settings", Command.SCREEN, 2); + + public MainForm() { + super("Arduhome", List.IMPLICIT, new String[]{"Relay", "Dimmer", "RGB Leds"}, null); + + this.setSelectCommand(selectCommand); + this.addCommand(settingsCommand); + this.addCommand(exitCommand); + this.setCommandListener(this); + } + + public void commandAction(Command cmnd, Displayable dsplbl) { + if ( cmnd.equals(exitCommand) ) { + BluetoothClientServer.getInstance().CloseAll(); + ArduhomeMIDlet.getInstance().destroyApp(true); + } else if ( cmnd.equals(settingsCommand) ) { + Display.getDisplay(ArduhomeMIDlet.getInstance()).setCurrent(new SettingsForm()); + } else if ( cmnd.equals(selectCommand) ) { + switch (this.getSelectedIndex() ) { + case 0: + FlowManager.getInstance().showRelayForm(); + break; + case 1: + FlowManager.getInstance().showDimmerForm(); + break; + case 2: + FlowManager.getInstance().showRGBForm(); + break; + } + + } + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/RGBForm.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/RGBForm.java new file mode 100644 index 0000000..e696714 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/RGBForm.java @@ -0,0 +1,76 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.FlowManager; +import java.io.ByteArrayOutputStream; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Gauge; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.ItemStateListener; +import javax.microedition.lcdui.StringItem; + +/** + * + * @author neto + */ +public class RGBForm extends Form implements CommandListener, ItemStateListener { + + private Gauge rGauge = new Gauge("Red", true, 9, 0); + private Gauge gGauge = new Gauge("Green", true, 9, 0); + private Gauge bGauge = new Gauge("Blue", true, 9, 0); + + private StringItem statusItem = new StringItem("Command sent:", null); + + private Command backCommand = new Command("Back", Command.BACK, 0); + + public RGBForm() { + super("RGB Leds"); + + this.append(rGauge); + this.append(gGauge); + this.append(bGauge); + this.setItemStateListener(this); + + this.append(statusItem); + + this.addCommand(backCommand); + this.setCommandListener(this); + } + + public void commandAction(Command command, Displayable displayable) { + if ( command.equals(backCommand)) { + FlowManager.getInstance().showMainScreen(); + } + } + + public void itemStateChanged(Item item) { + if (item instanceof Gauge) { + ByteArrayOutputStream bous = new ByteArrayOutputStream(); + bous.write((int)'C'); + bous.write((int)'R'); + bous.write((int)rGauge.getValue()); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + bous.write((int)'C'); + bous.write((int)'R'); + + bous.write((int)gGauge.getValue()); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + + bous.write((int)'C'); + bous.write((int)'R'); + bous.write((int)bGauge.getValue()); + BluetoothClientServer.getInstance().sendMessage(bous.toByteArray()); + + this.statusItem.setText("C" + (byte)rGauge.getValue() + (byte)gGauge.getValue() + (byte)bGauge.getValue()); + } + } + +} diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/RelayForm.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/RelayForm.java new file mode 100644 index 0000000..283b5da --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/RelayForm.java @@ -0,0 +1,76 @@ +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.bt.BluetoothClientServer; +import com.netomarin.arduhome.core.FlowManager; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.Item; +import javax.microedition.lcdui.ItemCommandListener; +import javax.microedition.lcdui.StringItem; + +/** + * + * @author neto + */ +public class RelayForm extends Form implements CommandListener, ItemCommandListener { + + private Command backCommand = new Command("Back", Command.BACK, 0); + private Command buttonCommand = new Command("Execute", Command.OK, 0); + + private StringItem lightState = new StringItem(null, "Turn ON", Item.BUTTON); + private StringItem discoMode = new StringItem(null, "DISCO!!", Item.BUTTON); + + private boolean lightOn = false; + private boolean discoOn = false; + String msg = null; + + public RelayForm() { + super("Relay Control"); + + this.lightState.setLayout(Item.LAYOUT_NEWLINE_AFTER); + + this.append(lightState); + this.append(discoMode); + lightState.setDefaultCommand(buttonCommand); + lightState.setItemCommandListener(this); + discoMode.setDefaultCommand(buttonCommand); + discoMode.setItemCommandListener(this); + + this.addCommand(backCommand); + this.setCommandListener(this); + } + + public void commandAction(Command command, Displayable displayable) { + if ( command.equals(backCommand)) { + FlowManager.getInstance().showMainScreen(); + } + } + + public void commandAction(Command command, Item item) { + if ( item.equals(lightState)) { + if ( lightOn ) { + msg = "A+A"; + lightState.setText("Turn OFF"); + } else { + msg = "A-A"; + lightState.setText("Turn ON"); + } + + lightOn = !lightOn; + } else if ( item.equals(discoMode)) { + if ( discoOn ) { + msg = "A+C"; + lightState.setText("STOP Disco!"); + } else { + msg = "A-C"; + lightState.setText("DISCO!!"); + } + + discoOn = !discoOn; + } + + BluetoothClientServer.getInstance().sendMessage(msg.getBytes()); + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/SettingsForm.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/SettingsForm.java new file mode 100644 index 0000000..049d49f --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/Arduhome/src/com/netomarin/arduhome/view/SettingsForm.java @@ -0,0 +1,46 @@ +package com.netomarin.arduhome.view; + +import com.netomarin.arduhome.core.FlowManager; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.TextField; + +/** + * + * @author neto + */ +public class SettingsForm extends Form implements CommandListener { + + //public static final String DEFAULT_MAC = "0006660412A9"; //bluesmirf + public static final String DEFAULT_MAC = "00066604127D"; //bluesmirf + //public static final String DEFAULT_MAC = "000666041225"; //bluesmirf + + private Command backCommand = new Command("Back", Command.BACK, 0); + private Command saveCommand = new Command("Save", Command.OK, 1); + + private TextField macAddressTextField; + + public SettingsForm() { + super("Settings"); + + String macAddress = FlowManager.loadSettings(); + macAddressTextField = new TextField("Bluetooth: ", + macAddress == null ? DEFAULT_MAC : macAddress, 12, TextField.ANY); + this.append(macAddressTextField); + + this.setCommandListener(this); + this.addCommand(backCommand); + this.addCommand(saveCommand); + } + + public void commandAction(Command cmnd, Displayable dsplbl) { + if ( cmnd.equals(backCommand) ) { + FlowManager.getInstance().showMainScreen(); + } else if ( cmnd.equals(saveCommand)) { + FlowManager.saveSettings(macAddressTextField.getString()); + FlowManager.getInstance().showMainScreen(); + } + } +} \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/build.xml b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/build.xml new file mode 100644 index 0000000..387c825 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/build.xml @@ -0,0 +1,47 @@ + + + + + + Builds, tests, and runs the project ArduhomeJavaFX. + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/build/compiled/desktopapplication1/Main.fxc b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/build/compiled/desktopapplication1/Main.fxc new file mode 100644 index 0000000..101ad23 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/build/compiled/desktopapplication1/Main.fxc @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/build/compiled/org/netbeans/javafx/design/md5sums.md5 b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/build/compiled/org/netbeans/javafx/design/md5sums.md5 new file mode 100644 index 0000000..9bd8b6e --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/build/compiled/org/netbeans/javafx/design/md5sums.md5 @@ -0,0 +1,2 @@ +0175d1cc2edc8cfc8a24505f1c3dc94d DesignState.fx +2d7e067ad3042476a4539c95835ca643 DesignStateChangeType.java diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1.html b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1.html new file mode 100644 index 0000000..934432d --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1.html @@ -0,0 +1,22 @@ + + + +DesktopApplication1 + + +

DesktopApplication1

+ + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1.jnlp b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1.jnlp new file mode 100644 index 0000000..cf2bb15 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1.jnlp @@ -0,0 +1,21 @@ + + + + DesktopApplication1 + vsenger + + DesktopApplication1 + + + + + + + + + + + MainJavaFXScript=desktopapplication1.Main + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1_browser.jnlp b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1_browser.jnlp new file mode 100644 index 0000000..e6170d9 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/dist/DesktopApplication1_browser.jnlp @@ -0,0 +1,21 @@ + + + + DesktopApplication1 + vsenger + + DesktopApplication1 + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/build-impl.xml b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/build-impl.xml new file mode 100644 index 0000000..01d6c4f --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/build-impl.xml @@ -0,0 +1,397 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set build.dir + Must set dist.dir + Must set dist.javadoc.dir + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/genfiles.properties b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/genfiles.properties new file mode 100644 index 0000000..9162bad --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=74174ecf +build.xml.script.CRC32=918ef008 +build.xml.stylesheet.CRC32=37714ed0@1.11.2 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=74174ecf +nbproject/build-impl.xml.script.CRC32=8ed6c15f +nbproject/build-impl.xml.stylesheet.CRC32=f3287c92@1.11.2 diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/config.properties b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/private.properties b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/private.properties new file mode 100644 index 0000000..1ccfb47 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/private.properties @@ -0,0 +1,5 @@ +application.args=\ +javac.debug=true +javadoc.preview=true +mobile.device=DefaultFxPhone1 +user.properties.file=/home/vsenger/.netbeans/6.9/build.properties diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/private.xml b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/private.xml new file mode 100644 index 0000000..1fb0a64 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/private/private.xml @@ -0,0 +1,7 @@ + + + + + file:/media/Vinicius/EletronLivre/Program-ME/Arduino%20Sketches/Projetos/JavaOne2010/ArduhomeJavaFX/src/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/project.properties b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/project.properties new file mode 100644 index 0000000..a3216b4 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/project.properties @@ -0,0 +1,55 @@ +applet.draggable=true +applet.height=200 +applet.width=200 +application.title=DesktopApplication1 +application.vendor=vsenger +build.classes.excludes=**/*.java,**/*.form,**/*.fx +build.classpath=\ + ${javac.classpath}:\ + ${src.dir}:\ + ${build.classes.dir}: +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +debug.classpath=\ + ${run.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ArduhomeJavaFX.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +file.reference.RXTXcomm.jar=../../../../../../../../java/netbeans-6.9.1/javafx/javafx-sdk/lib/shared/RXTXcomm.jar +includes=** +jar.compress=true +javac.classpath=\ + ${file.reference.RXTXcomm.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.source=1.5 +javac.target=1.5 +javadoc.additionalparam= +javadoc.author=true +javadoc.encoding= +javadoc.private=true +javadoc.version=false +javafx.profile=desktop +jnlp.codebase.type=local +jnlp.offline-allowed=true +jnlp.packEnabled=false +jnlp.signed=false +main.class=desktopapplication1.Main +manifest.file=manifest.mf +pack200.jar.compress=true +platform.active=default_fx_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs=-Dgnu.io.rxtx.SerialPorts=/dev/rfcomm0 +source.encoding=UTF-8 +src.dir=src diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/project.xml b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/project.xml new file mode 100644 index 0000000..3a7d05c --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/nbproject/project.xml @@ -0,0 +1,13 @@ + + + org.netbeans.modules.javafx.project + + + ArduhomeJavaFX + 1.6.5 + + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java new file mode 100644 index 0000000..93e57e3 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/br/com/globalcode/eletronlivre/arduino/serial/Arduino.java @@ -0,0 +1,138 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package br.com.globalcode.eletronlivre.arduino.serial; + +import gnu.io.CommPortIdentifier; +import gnu.io.SerialPort; +import gnu.io.UnsupportedCommOperationException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Enumeration; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author vsenger + */ +public class Arduino { + + static boolean init = false; + static Enumeration portList; + static CommPortIdentifier portId; + static String messageString = "10"; + static SerialPort serialPort; + static OutputStream outputStream; + static InputStream inputStream; + static boolean outputBufferEmptyFlag = false; + static String defaultPort = "/dev/rfcomm1"; + //static String defaultPort = "/dev/ttyUSB0"; + public static void begin(int bps) { + if (!init) { + init(); + } + + } + public static void delay(long milis) { + try { + Thread.sleep(milis); + } catch (InterruptedException ex) { + } + + } + + public static void init() { + init = true; + portList = CommPortIdentifier.getPortIdentifiers(); + + System.out.println("Iniciando"); + //System.out.println(portList.); + while (portList.hasMoreElements()) { + portId = (CommPortIdentifier) portList.nextElement(); + System.out.println(portId.getName()); + if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { + if (portId.getName().equals(defaultPort)) { + System.out.println("Found port " + defaultPort); + try { + serialPort = + (SerialPort) portId.open("SimpleWriteCOM17", 9600); + } catch (Exception e) { + System.out.println("Port in use."); + continue; + } + + + try { + outputStream = serialPort.getOutputStream(); + inputStream = serialPort.getInputStream(); + serialPort.setSerialPortParams(9600, + SerialPort.DATABITS_8, + SerialPort.STOPBITS_1, + SerialPort.PARITY_NONE); + + serialPort.notifyOnOutputEmpty(true); + } catch (UnsupportedCommOperationException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + System.out.println("Error setting event notification"); + System.out.println(e.toString()); + } + } + } + } + } + + public static void enviar(float f) throws Exception { + + enviar(new byte[]{(byte) f}); + } + //100, 1, 1024, 1, 9 + public static int map(int val, int minOriginal, int maxOriginal, int minTarget, int maxTarget) { + return val / ((maxOriginal - minOriginal) / (maxTarget - minTarget)); + + + } + public static void main(String[] args) { + System.out.println(map(100,1,1024,1,9)); + System.out.println(map(1000,1,1024,1,9)); + System.out.println(map(500,1,1024,1,9)); + System.out.println(map(50,1,1024,1,9)); + } + public static void enviar(byte bytes[]) throws Exception { + if (!init) { + init(); + } + + System.out.println("Escrevendo..."); + outputStream.write(66); //my I2C ID + System.out.println(bytes[0]); + + outputStream.write(bytes[0] ==0 ? 10 : bytes[0] ); + outputStream.flush(); + System.out.println("Esperando..."); + + + } + class BluetoothListener extends Thread { + public void run() { + while(true) { + try { + if (inputStream.available() > 0) { + while(inputStream.available()>0) { + System.out.print(inputStream.read()); + } + } + } catch (IOException ex) { + Logger.getLogger(Arduino.class.getName()).log(Level.SEVERE, null, ex); + } + Arduino.delay(50); + + } + } + } +} diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/.LCKMain.fx~ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/.LCKMain.fx~ new file mode 100644 index 0000000..d0d4b5a --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/.LCKMain.fx~ @@ -0,0 +1 @@ +/home/vsenger/DesktopApplication1/src/desktopapplication1/Main.fx \ No newline at end of file diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/Main.fx b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/Main.fx new file mode 100644 index 0000000..1a74841 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/Main.fx @@ -0,0 +1,150 @@ +/* + * Main.fx + * + * Created on Aug 11, 2010, 6:44:24 PM + */ +package desktopapplication1; + +import br.com.globalcode.eletronlivre.arduino.serial.Arduino; + +/** + * @author vsenger + */ +public class Main { + + // //GEN-BEGIN:main + def __layoutInfo_scrollBar: javafx.scene.layout.LayoutInfo = javafx.scene.layout.LayoutInfo { + width: 361.0 + height: 17.0 + } + public-read def scrollBar: javafx.scene.control.ScrollBar = javafx.scene.control.ScrollBar { + opacity: 1.0 + layoutX: 14.0 + layoutY: 46.0 + layoutInfo: __layoutInfo_scrollBar + onMouseClicked: null + onMousePressed: null + onMouseReleased: teste + min: 20.0 + max: 120.0 + } + + public-read def Luz_1: javafx.scene.control.Label = javafx.scene.control.Label { + layoutX: 20.0 + layoutY: 18.0 + text: "Luz 1" + } + + public-read def button: javafx.scene.control.Button = javafx.scene.control.Button { + visible: false + layoutX: 404.0 + layoutY: 279.0 + text: "Button" + } + + def __layoutInfo_arduinoConsole: javafx.scene.layout.LayoutInfo = javafx.scene.layout.LayoutInfo { + } + public-read def arduinoConsole: javafx.scene.control.TextBox = javafx.scene.control.TextBox { + visible: false + layoutX: 17.0 + layoutY: 279.0 + layoutInfo: __layoutInfo_arduinoConsole + } + + public-read def color: javafx.scene.paint.Color = javafx.scene.paint.Color { + red: 0.9529412 + green: 0.8980392 + blue: 0.11372549 + } + + public-read def circle: javafx.scene.shape.Circle = javafx.scene.shape.Circle { + opacity: 1.0 + layoutX: 406.0 + layoutY: 33.0 + fill: color + radius: 25.0 + } + + public-read def scene: javafx.scene.Scene = javafx.scene.Scene { + width: 480.0 + height: 320.0 + content: getDesignRootNodes () + } + + public-read def currentState: org.netbeans.javafx.design.DesignState = org.netbeans.javafx.design.DesignState { + names: [ "teste", ] + actual: 0 + timelines: [ + javafx.animation.Timeline { + keyFrames: [ + javafx.animation.KeyFrame { + time: 0ms + action: function() { + scrollBar.layoutX = 95.0; + scrollBar.layoutY = 46.0; + Luz_1.layoutX = 95.0; + Luz_1.layoutY = 24.0; + circle.layoutX = 33.0; + circle.layoutY = 46.0; + button.visible = true; + button.layoutX = 327.0; + button.layoutY = 279.0; + button.text = "Begin Communication"; + button.action = buttonActionAtteste; + arduinoConsole.visible = true; + __layoutInfo_arduinoConsole.width = 274.0; + } + } + ] + } + ] + } + + public-read def connected: org.netbeans.javafx.design.DesignState = org.netbeans.javafx.design.DesignState { + names: [ "State 1", ] + actual: 0 + timelines: [ + javafx.animation.Timeline { + keyFrames: [ + javafx.animation.KeyFrame { + time: 0ms + } + ] + } + ] + } + + public function getDesignRootNodes (): javafx.scene.Node[] { + [ scrollBar, Luz_1, circle, button, arduinoConsole, ] + } + + public function getDesignScene (): javafx.scene.Scene { + scene + } + // //GEN-END:main + + function buttonActionAtteste(): Void { + Arduino.begin(9600); + + //TODO + } + + function teste(event: javafx.scene.input.MouseEvent): Void { + java.lang.System.out.println(scrollBar.value); + circle.opacity = -1 - scrollBar.value / 100; + if(Arduino.map(scrollBar.value, 20, 121, 1, 9)==0) { + Arduino.enviar(9); + } + else Arduino.enviar(Arduino.map(scrollBar.value, 20, 121, 1, 9)); + } + +} + +function run (): Void { + var design = Main {}; + + javafx.stage.Stage { + title: "Main" + scene: design.getDesignScene () + } +} diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/Main.fxc b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/Main.fxc new file mode 100644 index 0000000..101ad23 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/desktopapplication1/Main.fxc @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/DesignState.fx b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/DesignState.fx new file mode 100644 index 0000000..2a588ad --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/DesignState.fx @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2009, Oracle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution. + * * Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.netbeans.javafx.design; + +import javafx.animation.Timeline; +import org.netbeans.javafx.design.DesignStateChangeType; + +/** + * Represents a container of a single state variable in a design. + * State variable can hold at maximum one particular state at a time. + * The actual state is held in actual field. + * + * It is required to set timelines field. + * Then you can switch between states using actual field directly or any helper method e.g. previous or next. + * Optionally you can set names field to navigate to states using their names. + * + * The onActualStateChanged method provides a callback for actual field changes. + * The onTransitionFinished method provides a callback for notifying of a finished transition animations. + * The doNotAnimateOnce field allows to fast-forward a transition animation of next state change. + */ +public class DesignState { + + /** + * Contains a sequence of names. + * Each name is assigned to a particular state represented by an index starting from zero. + * For getting an index from a specified name, you can use findIndex method. + */ + public-init var names: String[]; + + /** + * Contains a sequence of timelines. + * Each timeline is assigned to a particular state represented by an index starting from zero. + * A timeline sets various properties of components in a design to specific value. + * At the end of the timeline, the design should look as designed for a specific state. + */ + public-init var timelines: Timeline[] on replace { + initiateTransitionStates (); + } + + + var transitionStates: TransitionState[]; + + function initiateTransitionStates (): Void { + if (not FX.isInitialized(transitionStates)) { + transitionStates = for (i in [0..PAUSE_AND_PLAY_FROM_START. + * If null value is set, IllegalArgumentException is thrown. + */ + public-init var stateChangeType = DesignStateChangeType.PAUSE_AND_PLAY_FROM_START on replace oldValue { + if (stateChangeType == null) { + stateChangeType = oldValue; + throw new java.lang.IllegalArgumentException (); + } + } + + /** + * This is a notification method called when the actual state is changed. + * @param oldState the previous state + * @param newState the new actual state + */ + public var onActualStateChanged: function (oldState: Integer, newState: Integer): Void; + + /** + * This method is called when a timeline for a specific state is interrupted or finished. + * This method can be used e.g. for switching to next states for a slide-show effect. + * If the finishedState parameter value equals to DesignState.actual value + * then the transition is finished normally by finishing playing the whole animation. + * If the finishedState parameter value does NOT equal to DesignState.actual value + * then the transition is interrupted by invoked switch to another state i.e. + * by setting DesignState.actual field value or using the control methods. + * @param finishedState the state which transition is finished; If equals to DesignState.actual then transition has finished normally. Otherwise it has been interrupted. + */ + public var onTransitionFinished: function (finishedState: Integer): Void; + + /** + * Defines whether the next animation is played normally or fast-forward to the end immediately. + * If initially set to true, then a design immediately skips an animation for the start state. + * Similarly if you want to fast-switch to a new state, then set this field to true right before setting the new actual state index. + * Once an animation is skipped, the field is set to false automatically. + * The field must not be initialized with bind expression. + */ + public var doNotAnimateOnce: Boolean = true; + + /** + * Holds the actual state index. The defined indices are [0 .. < sizeof names]. + * Any other index is taken as undefined. + * Default actual state index is -1. + * When a new actual state index is set, then based on onActualStateChanged + * a new timeline is started and onActualStateChanged method is called. + */ + public var actual = -1 on replace old { + initiateTransitionStates (); + def oldTimeline = timelines[old]; + def actualTimeline = timelines[actual]; + + if (stateChangeType == DesignStateChangeType.PAUSE_AND_PLAY_FROM_START) { + oldTimeline.stop (); + actualTimeline.evaluateKeyValues (); + actualTimeline.playFromStart (); + + } else if (stateChangeType == DesignStateChangeType.FINISH_AND_PLAY_FROM_START) { + oldTimeline.time = oldTimeline.totalDuration; + actualTimeline.evaluateKeyValues (); + actualTimeline.playFromStart (); + + } else if (stateChangeType == DesignStateChangeType.CONTINUE_AND_PLAY) { + actualTimeline.evaluateKeyValues (); + actualTimeline.play (); + + } else if (stateChangeType == DesignStateChangeType.DO_NOTHING) { + } + + if (doNotAnimateOnce) { + doNotAnimateOnce = false; + FX.deferAction (function (): Void { + actualTimeline.time = actualTimeline.totalDuration; + }); + } + + onActualStateChanged (old, actual); + } + + /** + * Returns a state index by a state name which can be found in names field. + * @param name the state name to search for + * @return the state index or -1 if not found. + */ + public function findIndex (name: String): Integer { + javafx.util.Sequences.indexOf(names, name); + } + + /** + * Returns whether the actual state index is 0 or less. + * @return true, if actual state index <= 0 + */ + public bound function isFirst (): Boolean { + actual <= 0 + } + + /** + * Returns whether the actual state index is equal or greater than the last defined index. + * @return true, if actual state index >= sizeof names - 1 + */ + public bound function isLast (): Boolean { + actual >= sizeof names - 1 + } + + /** + * If possible, sets the actual state index to previous state index + * i.e. decrements the actual state index by 1. + * The method cares about the lower limit and disables decrement + * when the new actual state index would be undefined index. + */ + public function previous () { + if (not isFirst ()) { + actual = actual - 1; + } + } + + /** + * If possible, sets the actual state index to next state index + * i.e. increments the actual state index by 1. + * The method cares about the upper limit and disables increment + * when the new actual state index would be undefined index. + */ + public function next () { + if (not isLast ()) { + actual = actual + 1; + } + } + + /** + * If possible, sets the actual state index to previous state index in a loop + * i.e. decrements the actual state index by 1 in a loop of defined indices. + * If the new actual state index would be undefined index, the last defined index is set instead. + */ + public function previousWrapped () { + actual = if (isFirst ()) then sizeof names - 1 else actual - 1 + } + + /** + * If possible, sets the actual state index to next state index in a loop + * i.e. increments the actual state index by 1 in a loop of defined indices. + * If the new actual state index would be undefined index, the first defined index is set instead. + */ + public function nextWrapped () { + actual = if (isLast ()) then 0 else actual + 1 + } + +} + +class TransitionState { + + public-init var designState: DesignState; + + public-init var timeline: Timeline; + + public-init var index: Integer; + + var running = bind timeline.running on replace oldRunning { + if (oldRunning and not running) { + designState.onTransitionFinished (index); + } + } + +} diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/DesignStateChangeType.java b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/DesignStateChangeType.java new file mode 100644 index 0000000..fecdb7e --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/DesignStateChangeType.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2009, Oracle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution. + * * Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.netbeans.javafx.design; + +/** + * Represents a type of behaviour for timelines of previous and new state when an actual state is changed in state a DesignState. + */ +public enum DesignStateChangeType { + + /** + * Use this constant for setting DesignState.stateChangeType field. + * This type stops previous timeline and plays the new timeline from its start. + */ + PAUSE_AND_PLAY_FROM_START, + + /** + * Use this constant for setting DesignState.stateChangeType field. + * This type finishes previous timeline by setting the time to the totalDuration and plays the new timeline from its start. + */ + FINISH_AND_PLAY_FROM_START, + + /** + * Use this constant for setting DesignState.stateChangeType field. + * This type leaves the previous timeline running and starts playing the new one. + * This behaviour may lead to some unconsistent state e.g. when a new timeline finishes before the old one. + */ + CONTINUE_AND_PLAY, + + /** + * Use this constant for setting DesignState.stateChangeType field. + * This type does not do anything with the timelines. + */ + DO_NOTHING + +} diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/md5sums.md5 b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/md5sums.md5 new file mode 100644 index 0000000..9bd8b6e --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/ArduhomeJavaFX/src/org/netbeans/javafx/design/md5sums.md5 @@ -0,0 +1,2 @@ +0175d1cc2edc8cfc8a24505f1c3dc94d DesignState.fx +2d7e067ad3042476a4539c95835ca643 DesignStateChangeType.java diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_Central/I2C_Central.pde b/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_Central/I2C_Central.pde new file mode 100644 index 0000000..3d8c712 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_Central/I2C_Central.pde @@ -0,0 +1,111 @@ +#include +#include + +char comando[16]; +int luz= 0; + +LiquidCrystal lcd(4, 9, 14, 15, 16, 17); + +void setup() +{ + Wire.begin(); + //Wire.onReceive(receiveEvent); + Serial.begin(115200); + initLCD(); +} + +void receiveEvent(int howMany) { + char string[16]; + int counter=0; + while(Wire.available()>0) { + string[counter++]=Wire.receive(); + } + + + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Central Updated"); + lcd.setCursor(0, 1); + lcd.print(string); + +} +void initLCD() { + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Mater I2C On"); + lcd.setCursor(0, 1); + lcd.print("Waiting command."); +} + +void loop () +{ + if(Serial.available()>0) { + limpaComando(); + + int counter =0; + while(Serial.available()>0) { + comando[counter++]=Serial.read(); + delay(20); + } + lcd.clear(); + lcd.setCursor(0, 0); + + lcd.print(comando); + executarComando(); + //lcd.print("Aguardando...."); + for(int x=0;x<4;x++) { + digitalWrite(4, HIGH); + delay(30); + digitalWrite(4, LOW); + delay(30); + } + } + delay(5); +} + + +void receiveEvent() { + if(Wire.available()>0) // slave may send less than requested + { + byte b = Wire.receive(); + while(Wire.available()) Wire.receive(); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("something new"); + lcd.setCursor(0, 1); + lcd.print(b, DEC); + + + } +} + +void executarComando() { + lcd.setCursor(0, 0); + lcd.print("Begin with "); + lcd.setCursor(12, 0); + lcd.print(comando[0]); + Wire.beginTransmission(comando[0]); + Wire.send(comando); + Wire.endTransmission(); + lcd.setCursor(2, 1); + lcd.print("commuicated..."); + +} +void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } +} + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_Dimmer_OK/I2C_Dimmer_OK.pde b/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_Dimmer_OK/I2C_Dimmer_OK.pde new file mode 100644 index 0000000..3d01296 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_Dimmer_OK/I2C_Dimmer_OK.pde @@ -0,0 +1,147 @@ +/* + AC Light Control + + Ryan McLaughlin + + Thanks to http://www.andrewkilpatrick.org/blog/?page_id=445 + and http://www.hoelscher-hi.de/hendrik/english/dimmer.htm + + */ +#include + +#define PING_PIN 4 + +int led13 = HIGH; +long counter = 0; +int stepStack = 0; + +int AC_pin = 7; // Output to Opto Triac +int olddim=0; +long duration, inches, cm, oldCm; +long MAX_DISTANCE = 50; + +//ISR Vars +volatile boolean wasInt = false; +volatile int dim = 120; // Dimming level (0-128) 0 = on, 128 = 0ff + +void setup() // run once, when the sketch starts +{ + pinMode(AC_pin, OUTPUT); // Set the light control pin as output + attachInterrupt(0, light, RISING); // Attach an Interupt to pin2 (interupt 0) for Zero Cross Detection + Wire.begin(66); + Wire.onReceive(receiveEvent); + readPing(true); + MAX_DISTANCE=cm; + Serial.begin(9600); + +} + +void receiveEvent(int howMany) +{ + byte comando[16]; + int counter=0; + while(1 < Wire.available()) + { + byte c = Wire.receive(); + comando[counter++]=c; + } + int x = Wire.receive(); + int val = comando[1]; + dim = map(val, 0,9,1,125); +} + +void light() // function to be fired at the zero crossing to dim the light +{ + Serial.println("ok"); + wasInt=true; + if(dim<125) { + long dimtime = (60*dim); // eval the proper pause to fire the triac + delayMicroseconds(dimtime); // delay the dim time + digitalWrite(AC_pin, HIGH); // fire the Triac + delayMicroseconds(1); // pause briefly to ensure the triac turned on + digitalWrite(AC_pin, LOW); // turn off the Triac gate (triac will not turn off until next zero cross) + } + else { + digitalWrite(AC_pin, LOW); // turn off the Triac gate (triac will not turn off until next zero cross) + } +} + +void pisca(int re) { + int dimold = dim; + for(int x=0;x 30 ? 30 : cm; + dim = map(cmn,1,30,10,125); + Wire.beginTransmission(60); + char texto[10]; + itoa(map(dim,10,125,1,9),texto, 1); + //Wire.send(texto); + //Wire.endTransmission(); + delay(20); + readPing(true); + + } + } + } + delay(150);*/ +} + +void readPing(boolean disableInt) +{ + wasInt=false; + + if(disableInt) noInterrupts(); + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + if(wasInt) return; + delayMicroseconds(2); + if(wasInt) return; + digitalWrite(PING_PIN, HIGH); + if(wasInt) return; + delayMicroseconds(5); + if(wasInt) return; + digitalWrite(PING_PIN, LOW); + pinMode(PING_PIN, INPUT); + if(wasInt) return; + duration = pulseIn(PING_PIN, HIGH); + if(wasInt) return; + interrupts(); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_RGB/I2C_RGB.pde b/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_RGB/I2C_RGB.pde new file mode 100644 index 0000000..10188c1 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_RGB/I2C_RGB.pde @@ -0,0 +1,51 @@ +#include + +#define RED 17 +#define GREEN 7 +#define BLUE 9 + + +void setup() +{ + pinMode(RED, OUTPUT); + pinMode(GREEN, OUTPUT); + pinMode(BLUE, OUTPUT); + pinMode(2, OUTPUT); + pinMode(3, OUTPUT); + + //Serial.begin(9600); + Wire.begin(67); + Wire.onReceive(receiveEvent); + +} +void receiveEvent(int howMany) +{ + char comando[16]; + int counter=0; + while(Wire.available()>0) { + digitalWrite(2,HIGH); + digitalWrite(3,HIGH); + delay(100); + digitalWrite(2,LOW); + digitalWrite(3,LOW); + Wire.receive();// skyp first byte, my ID + } + /*Serial.println("Evento, bytes recebidos"); + Serial.println(howMany); + + Serial.println(Wire.receive(),DEC); + Serial.println(Wire.receive(),DEC); + Serial.println(Wire.receive(),DEC); + Serial.println("Evento finalizado...");*/ + + +} + +void loop() +{ + +} + + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_Slave_Tomada/I2C_Slave_Tomada.pde b/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_Slave_Tomada/I2C_Slave_Tomada.pde new file mode 100644 index 0000000..5ee3712 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_Slave_Tomada/I2C_Slave_Tomada.pde @@ -0,0 +1,64 @@ + #include + + +void setup() +{ + pinMode(3, OUTPUT); + pinMode(4, OUTPUT); + Serial.begin(9600); + Wire.begin(65); // join i2c bus with address #4 + Wire.onReceive(receiveEvent); // register event + +} +void receiveEvent(int howMany) +{ + char comando[16]; + int counter=0; + while(1 < Wire.available()) // loop through all but the last + { + char c = Wire.receive(); // receive byte as a character + comando[counter++]=c; + Serial.print(c); // print the character + } + int x = Wire.receive(); // receive byte as an integer + Serial.println(x); // print the integer + + Serial.println("Evento"); + Serial.println(howMany); + if(comando[1]=='+') { + Serial.println("Ligando relê"); + digitalWrite(comando[2]=='A' ? 3 : 4, HIGH); + } + else if(comando[1]=='-') { + Serial.println("Desligando relê"); + digitalWrite(comando[2]=='A' ? 3 : 4, LOW); + } + + /*char comando[16]; + int c=0; + while(1 < Wire.available()) // loop through all but the last + { + if(c=0) Wire.receive(); //skip first byte (my ID) + comando[c++] = Wire.receive(); // receive byte as a character + + } + Serial.println(comando); + if(comando[0]=='+') { + Serial.println("Ligando relê"); + digitalWrite(comando[1]=='A' ? 3 : 4, HIGH); + } + else if(comando[0]=='-') { + Serial.println("Desligando relê"); + digitalWrite(comando[1]=='A' ? 3 : 4, LOW); + } */ +} + +void loop() +{ + Serial.println("esperando..."); + delay(1000); + +} + + + diff --git a/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_Tomada2/I2C_Tomada2.pde b/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_Tomada2/I2C_Tomada2.pde new file mode 100644 index 0000000..a56f224 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/JavaOne2010/I2C_Tomada2/I2C_Tomada2.pde @@ -0,0 +1,56 @@ +#include +#define RED 9 +#define GREEN 7 +#define BLUE 7 +int red=2,green=2,blue=2; + +void setup() +{ + pinMode(RED, OUTPUT); + pinMode(GREEN, OUTPUT); + pinMode(BLUE, OUTPUT); + Serial.begin(9600); + Wire.begin(67); // join i2c bus with address #4 + Wire.onReceive(receiveEvent); // register event + +} +void receiveEvent(int howMany) +{ + char comando[16]; + int counter=0; + while(1 < Wire.available()) // loop through all but the last + { + char c = Wire.receive(); // receive byte as a character + comando[counter++]=c; + } + char c = Wire.receive(); // receive byte as a character + + red = comando[1]; + green = comando[2]; + blue = comando[3]; + Serial.println("comando"); + Serial.println(comando); + +} + +void loop() +{ + analogWrite(RED, red==1 ? 0 : red); + analogWrite(BLUE, blue==1 ? 0 : blue); + analogWrite(GREEN, green==1 ? 0 : green); + Serial.println("Red"); + Serial.println(red); + Serial.println("Green"); + Serial.println(green); + Serial.println("Blue"); + Serial.println(blue); + + Serial.println("esperando..."); + delay(1000); + +} + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/MonitorDuino/monitorDuino_v1_0/monitorDuino_v1_0.pde b/arduino/all the sketchs of my life/Projetos/MonitorDuino/monitorDuino_v1_0/monitorDuino_v1_0.pde new file mode 100644 index 0000000..c2e501d --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/MonitorDuino/monitorDuino_v1_0/monitorDuino_v1_0.pde @@ -0,0 +1,212 @@ +/* :::MonitorDuino v_1.0::: +/* An Arduino based performance computer monitor +/* +/* AUTHOR: Stefano Manni | http://www.stefanomanni.it/arduino | ::FREE SOFTWARE:: +/* +/* HOW TO: upload sketch and run systemMonitor.sh script on your computer with LINUX OS + + * CIRCUIT: + * LCD --------------------------- ARDUINO + * + * Vss pin (1) to GND + * Vdd pin (2) to 5V + * VO/Contrast pin (3) to 5V through a potentiometer + * RS pin (4) to digital pin 12 + * Enable pin (6) to digital pin 11 + * D4 pin (11) to digital pin 5 + * D5 pin (12) to digital pin 4 + * D6 pin (13) to digital pin 3 + * D7 pin (14) to digital pin 2 + * R/W pin (5) to GND + * Led+ pin (15) to 5V + * Led- pin (16( to GND +*/ + +#include "string.h" +#include + +char UPTIME[6]; //system uptime [h:min] +char CPU[7]; //cpu utilization [%] +char RAM[6]; //memory used [MB] +char NET[11]; //download rate [kB/s] +char FS[4]; //upload rate [kB/s] +char TEMP[5]; //cpu temperature [°Celsius] + +int numR = 4; //number of rows on lcd +int numC = 20; //number of columns on lcd + +char string[40]; //string received from bash script via serial + +LiquidCrystal lcd(12,11,6,5,4,3); //constructor LiquidCrystal xxx (RS, Enable, D4, D5, D6, D7) + +boolean flag=false; + +//Pattern (P_) of constant strings and custom chars to visualize on lcd +byte P_arrowDown[9]={B00000,B00000,B11111,B01110,B00100,B00000,B00000,B00000,}; //custom char arrow down +byte P_arrowUp[9]={B00000,B00000,B00000,B00100,B01110,B11111,B00000,B00000,}; //custom char arrow up +char P_header[20] = "MonitorDuino v_1.0"; +char P_uptime[9]= "Uptime:"; +char P_cpuUsage[12]="Cpu usage:"; +char P_cpuTemp[11]= "Cpu temp:"; +char P_mem[12]="Mem usage:"; +char P_rx[10]="Rx rate:"; +char P_disk[13]="Disk usage:"; + + +void setup(){ +lcd.createChar(1,P_arrowDown); +lcd.createChar(2,P_arrowUp); +lcd.begin(numR,numC); +Serial.begin(115200); +attachInterrupt(0, changePage, RISING); //interrupt on digital pin 2 (pushbutton through a pull-down resistor) +initPage1(); +} + + +void initPage1(){ +lcd.clear(); +lcd.setCursor(0,0); +lcd.print(P_header); //defined in MonitorDuinoStrings.h +lcd.setCursor(0,1); +lcd.print(P_uptime); +lcd.setCursor(0,2); +lcd.print(P_cpuUsage); +lcd.setCursor(0,3); +lcd.print(P_cpuTemp); +lcd.setCursor(19,3); +lcd.write(1); //arrow DOWN +} + + +void initPage2(){ +lcd.clear(); +lcd.setCursor(0,0); +lcd.print(P_header); +lcd.setCursor(0,1); +lcd.print(P_mem); +lcd.setCursor(0,2); +lcd.print(P_rx); +lcd.setCursor(0,3); +lcd.print(P_disk); +lcd.setCursor(19,0); +lcd.write(2); //arrow UP +} + + +void changePage (){ //invoked when an interrupt occurs +flag=!flag; +if (!flag) initPage1(); +else initPage2(); +} + + +void clearRow(int col, int row){ +int k; + lcd.setCursor(col,row); + for(k=col;k 0){ + delay(10); + string[i]=Serial.read(); + i++; +} + +if (i!=0) { //if i've receveid something + + for(i;i" + echo "--disk= " + echo "--tty= " + echo "" + echo "EXAMPLES:" + echo "./systemMonitor.sh --net=eth0 --disk=/dev/sda1 --tty=/dev/ttyUSB0" + exit + ;; + + esac +done + +if [ "$netDev" == "" ] && [ "$diskPath" == "" ] && [ "$tty" == "" ] +then + echo "Usage: -h for help" + exit +fi + +if [ "$netDev" == "" ] +then + echo "Usage: --net= " + exit +fi + +if [ "$diskPath" == "" ] +then + echo "Usage: --disk= " + exit +fi + +if [ "$tty" == "" ] +then + echo "Usage: --tty= " + exit +fi + + +#Send data +clear +echo -n "Sending data to Arduino" + +while true; +do + UPTIME=$(uptime | awk '{ print $3 }' | cut -d, -f1) + CPU=$(mpstat -P ALL 1 1 | grep Average | grep all | awk '{print $3"%"}') + RAM=$(free -mo | grep Mem: | awk '{ print $3"MB" }') + NETdown=$(bwm-ng -o plain -c 1 | grep $netDev | awk '{print $2"kB/s"}') + FS=$(df -hT | grep $diskPath | awk '{print $6}') + TEMP=$(cat /proc/acpi/thermal_zone/TZS0/temperature | awk '{print $2"C"}') + + echo $UPTIME@$CPU@$RAM@$NETdown@$FS@$TEMP > $tty + echo -n "." + +done + + + diff --git a/arduino/all the sketchs of my life/Projetos/PainelLedRGB/PainelLedRGB.pde b/arduino/all the sketchs of my life/Projetos/PainelLedRGB/PainelLedRGB.pde new file mode 100644 index 0000000..314c532 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/PainelLedRGB/PainelLedRGB.pde @@ -0,0 +1,70 @@ +#include +void setup() { + pinMode(9, OUTPUT); + pinMode(10, OUTPUT); + pinMode(11, OUTPUT); + Serial.begin(9600); + Wire.begin(65); + Wire.onReceive(receiveEvent); + +} +int val; +byte comando[16]; + +void receiveEvent(int howMany) +{ + Serial.println(howMany); + + int counter=0; + while(1 < Wire.available()) + { + byte c = Wire.receive(); + comando[counter++]=c; + Serial.print(c); + } + char numero[3]; + numero[0]=comando[1]; + numero[1]=comando[2]; + numero[2]=comando[3]; + val = atoi(numero); + +} + + +void loop() { + /* Serial.println( analogRead(0)); + Serial.println( analogRead(1)); + Serial.println( analogRead(2)); + Serial.println( "============");*/ + //analogWrite(9, map(analogRead(0),0,1024,0,255)); + //analogWrite(10, map(analogRead(1),0,1024,0,255)); + //analogWrite(11, map(analogRead(2),0,1024,0,255)); + if(val>0 && val<90) { + analogWrite(9, map(val,0,90,0,255)); + analogWrite(10, 0); + analogWrite(11, 0); + + } + else if(val>90 && val<180) { + analogWrite(10, map(val,90,180,0,255)); + analogWrite(9, 0); + analogWrite(11, 0); + + } + else if(val>180 && val<270) { + analogWrite(11, map(val,180,270,0,255)); + analogWrite(10, 0); + analogWrite(9, 0); + } + else if(val>270 && val<360) { + analogWrite(9, map(val,270,360,0,255)); + analogWrite(10, map(val,270,360,0,255)); + analogWrite(11, 0); + } + +} + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/PainelMotores/PainelMotores.pde b/arduino/all the sketchs of my life/Projetos/PainelMotores/PainelMotores.pde new file mode 100644 index 0000000..319c8c8 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/PainelMotores/PainelMotores.pde @@ -0,0 +1,57 @@ +// Controlling a servo position using a potentiometer (variable resistor) +// by Michal Rinott + +#include + +Servo myservo; // create servo object to control a servo +Servo myservo1; // create servo object to control a servo + +int potpin = 1; // analog pin used to connect the potentiometer +int val; // variable to read the value from the analog pin + +void setup() +{ + Serial.begin(9600); + pinMode(9, OUTPUT); + pinMode(6, OUTPUT); + + myservo.attach(10); // attaches the servo on pin 9 to the servo object + myservo1.attach(11); // attaches the servo on pin 9 to the servo object +} + +void loop() +{ + myservo.write(map(analogRead(2), 0, 1023, 0, 179)); + myservo1.write(map(analogRead(0), 0, 1023, 0, 179)); + analogWrite(9,map(analogRead(1), 0, 1023, 0, 255)); + analogWrite(6,map(analogRead(1), 0, 1023, 0, 255)); + delay(50); + + + Serial.println( analogRead(0)); + + Serial.println( analogRead(1)); + Serial.println( analogRead(2)); + Serial.println( "============"); + /*if(Serial.available()>0) { + + while(Serial.available()>0) { + + int dado = int(Serial.read()); + Serial.println(dado,DEC); + myservo.write(dado); + int dado1 = int(Serial.read()); + Serial.println(dado1,DEC); + myservo1.write(dado1); + + } + }*/ + + /*val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) + //Serial.println(val); + val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) + //myservo.write(analogRead(1)/4); // sets the servo position according to the scaled value + //myservo1.write(analogRead(2)/4); // sets the servo position according to the scaled value */ + delay(10); // waits for the servo to get there +} + diff --git a/arduino/all the sketchs of my life/Projetos/PortasGlobalcode/PortasGlobalcode.pde b/arduino/all the sketchs of my life/Projetos/PortasGlobalcode/PortasGlobalcode.pde new file mode 100644 index 0000000..beac208 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/PortasGlobalcode/PortasGlobalcode.pde @@ -0,0 +1,31 @@ +void setup() { + Serial.begin(9600); + pinMode(8, OUTPUT); + pinMode(9, OUTPUT); +} + + +void loop() { + if(Serial.available() >0) { + int incoming=Serial.read(); + Serial.println("Recebendo dados"); + Serial.println(incoming, DEC); + abrirPorta(incoming); + + } +} + +void abrirPorta(int conjunto) { + if(conjunto=65) { + Serial.println("Abrindo porta do 22"); + digitalWrite(8, HIGH); + delay(200); + digitalWrite(8, LOW); + } + if(conjunto=66) { + Serial.println("Abrindo porta do 34"); + digitalWrite(9, HIGH); + delay(200); + digitalWrite(9, LOW); + } +} diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/Potenciometro_com_LED_e_Serial.pde b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/Potenciometro_com_LED_e_Serial.pde new file mode 100644 index 0000000..c23e7fb --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/Potenciometro_com_LED_e_Serial.pde @@ -0,0 +1,24 @@ +#include + +void setup() { + pinMode(3, OUTPUT); + pinMode(4, OUTPUT); + pinMode(5, OUTPUT); + pinMode(9, OUTPUT); + pinMode(2, INPUT); + Serial.begin(9600); +} + +void loop(){ + analogWrite(3, analogRead(2)); + analogWrite(4, analogRead(2)/4); + analogWrite(9, analogRead(2)/4); + analogWrite(5, analogRead(2)); + pos = analogRead(2) / 7; + + Serial.println(analogRead(2)); + delay(100); + +} + + diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..dc28a59 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.cpp b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.cpp new file mode 100644 index 0000000..763821f --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.cpp @@ -0,0 +1,107 @@ +#include + +#define P0 0 // Porta Digital 0 - Led 1 - +#define P1 1 // Porta Digital 1 - Led 2 +#define P2 2 // Porta Digital 2 - Led 3 - PWM +#define P3 3 // Porta Digital 3 - Led 4 +#define P4 4 // Porta Digital 4 - Led 5 - PWM +#define P5 5 // Porta Digital 5 - Led 6 - PWM +#define P6 6 // Porta Digital 6 - Led 7 +#define P7 7 // Porta Digital 7 - Led 8 +#define P8 8 // Porta Digital 8 - Transistor Q3 +#define P9 9 // Porta Digital 9 - Transistor Q2 - PWM +#define P10 10 // Porta Digital 10 - Servo1 - PWM +#define P11 11 // Porta Digital 11 - Servo2 - PWM +#define P12 12 // Porta Digital 12 - Buzzer +#define P13 13 // Porta Digital 13 - Led 9 +#define AP0 14 // Porta Analogica 0 +#define AP1 15 // Porta Analogica 1 +#define AP2 16 // Porta Analogica 2 +#define AP3 17 // Porta Analogica 3 +#define AP4 18 // Porta Analogica 4 +#define AP5 19 // Porta Analogica 5 + +#define A0 0 // Porta Analogica 0 - LDR +#define A1 1 // Porta Analogica 1 - POT 1 +#define A2 2 // Porta Analogica 2 - POT 2 +#define A3 3 // Porta Analogica 3 - Transistor Q5 +#define A4 4 // Porta Analogica 4 - Transistor Q4 +#define A5 5 // Porta Analogica 3 - Chave + +#define LED_1 0 +#define LED_2 1 +#define LED_3 2 +#define LED_4 3 +#define LED_5 4 +#define LED_6 5 +#define LED_7 6 +#define LED_8 7 +#define LED_9 13 + +#define Q2 9 +#define Q3 8 +#define Q4 17 +#define Q5 18 + +#define LDR 0 +#define POT1 1 +#define POT2 2 +#define CHAVE 5 +#include "WProgram.h" +void setup(); +void loop(); +int pos = 0; // variable to store the servo position + +int transistorPin1 = P8; +int transistorPin2 = P9; +int transistorPin3 = AP3; +int transistorPin4 = AP4; + +int inPin = AP5; + +int val = 0; + +//Servo myservo9; // create servo object to control a servo + +void setup() { + // myservo9.attach(10); // attaches the servo on pin 9 to the servo object + + pinMode(2, INPUT); + pinMode(5, OUTPUT); + pinMode(9, OUTPUT); + pinMode(10, OUTPUT); + pinMode(11, OUTPUT); + pinMode(3, OUTPUT); + pinMode(4, OUTPUT); + Serial.begin(9600); +} + +void loop(){ + analogWrite(3, analogRead(2)); + analogWrite(4, analogRead(2)/4); + analogWrite(9, analogRead(2)/4); + //analogWrite(9, 128); + //digitalWrite (9, HIGH); + pos = analogRead(2) / 7; + //myservo9.write(pos); // tell servo to go to position in variable 'pos' + + analogWrite(5, analogRead(2)); + Serial.println(analogRead(2)); + delay(100); + +} + + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.cpp.o b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.cpp.o new file mode 100644 index 0000000..7256e71 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.eep b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.elf b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.elf new file mode 100644 index 0000000..d30bfe2 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.elf differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.hex b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.hex new file mode 100644 index 0000000..e618d93 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.hex @@ -0,0 +1,160 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C94CA020C948A000C94F4000C948A005C +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000AD0111241FBECFEFD4E0DEBFCDBFD5 +:1000D00011E0A0E0B1E0ECEDF9E002C005900D9276 +:1000E000A830B107D9F711E0A8E0B1E001C01D9236 +:1000F000AC3AB107E1F710E0C4ECD0E004C02297BD +:10010000FE010E94E804C23CD107C9F70E94ED003D +:100110000C94EC040C94000082E00E949E03BC014D +:1001200083E00E94BC0382E00E949E0364E070E0D2 +:100130000E94820484E00E94BC0382E00E949E032D +:1001400064E070E00E94820489E00E94BC0382E0C7 +:100150000E949E0367E070E00E9482047093090190 +:100160006093080182E00E949E03BC0185E00E942A +:10017000BC0382E00E949E03BC018EE891E00E94D5 +:10018000BA0264E670E080E090E00E943A030895CD +:1001900082E060E00E94150485E061E00E941504A1 +:1001A00089E061E00E9415048AE061E00E94150484 +:1001B0008BE061E00E94150483E061E00E94150479 +:1001C00084E061E00E9415048EE891E040E855E289 +:1001D00060E070E00E94310108950E9464030E9473 +:1001E000C8000E948C00FDCF1F920F920FB60F9295 +:1001F00011242F933F934F935F936F937F938F932C +:100200009F93AF93BF93EF93FF934091C600E0910C +:100210008A01F0918B01CF01019660E870E00E94A5 +:1002200082049C0180918C0190918D0128173907DF +:1002300039F0E65FFE4F408330938B0120938A01B3 +:10024000FF91EF91BF91AF919F918F917F916F91AE +:100250005F914F913F912F910F900FBE0F901F9084 +:100260001895AF92BF92CF92DF92EF92FF920F93C9 +:100270001F93CF93DF936C017A018B01DC011496FD +:10028000AD90BC901597CB01BA0122E030E040E080 +:1002900050E00E94B704205C3D4B404F5F4FCA01C5 +:1002A000B901A80197010E94B704C901DA010197B9 +:1002B000A109B109292F3A2F4B2F552747FD5A95F0 +:1002C0000196A11DB11DE5012883E601EE81FF81A4 +:1002D00081508083EA85FB85208141E050E0CA019E +:1002E0000E8402C0880F991F0A94E2F7282B2083FE +:1002F000EA85FB852081CA010F8402C0880F991FFF +:100300000A94E2F7282B2083EA85FB858081088800 +:1003100002C0440F551F0A94E2F7842B8083DF91BB +:10032000CF911F910F91FF90EF90DF90CF90BF90F2 +:10033000AF900895FC01A085B18521898C9190E052 +:10034000022E02C0959587950A94E2F780FFF6CFBA +:100350000484F585E02D6083089585E091E0909315 +:100360008F0180938E018AE091E0909391018093B8 +:10037000900185EC90E0909393018093920184EC3E +:1003800090E0909395018093940180EC90E090939D +:1003900097018093960181EC90E09093990180936E +:1003A000980186EC90E090939B0180939A0184E001 +:1003B00080939C0183E080939D0187E080939E0160 +:1003C00085E080939F0108950F931F938C01DC01BA +:1003D000ED91FC910190F081E02D6DE00995D8013F +:1003E000ED91FC910190F081E02DC8016AE0099542 +:1003F0001F910F9108952F923F924F925F926F92AB +:100400007F928F929F92AF92BF92CF92DF92EF92A4 +:10041000FF920F931F93DF93CF93CDB7DEB7A097D3 +:100420000FB6F894DEBF0FBECDBF1C016A017B0181 +:10043000411551056105710549F4DC01ED91FC910F +:100440000190F081E02D60E3099554C0882499243F +:100450005401422E55246624772401E010E00C0F4D +:100460001D1F080D191DC701B601A30192010E94AD +:100470009504F80160830894811C911CA11CB11C97 +:10048000C701B601A30192010E949504C901DA01D6 +:100490006C017D01C114D104E104F104F1F681E0A5 +:1004A000E82EF12CEC0EFD1EE80CF91C3E01089420 +:1004B000611C711CD501C4010197A109B1096C012E +:1004C000C818D90814C0F601EE0DFF1D60816A300E +:1004D00010F4605D01C0695CD101ED91FC91019067 +:1004E000F081E02DC10109950894E108F1086E142E +:1004F0007F0449F7A0960FB6F894DEBF0FBECDBFBC +:10050000CF91DF911F910F91FF90EF90DF90CF90EF +:10051000BF90AF909F908F907F906F905F904F9023 +:100520003F902F900895EF92FF920F931F93CF93D8 +:10053000DF93EC017A018B0177FF0FC0E881F9812D +:100540000190F081E02D6DE2099510950095F094F1 +:10055000E094E11CF11C011D111DCE01B801A701A1 +:100560002AE00E94FB01DF91CF911F910F91FF9034 +:10057000EF9008950F931F938C01AB01662757FDF1 +:100580006095762F0E949302C8010E94E4011F919A +:100590000F9108951F920F920FB60F9211242F936F +:1005A0008F939F93AF93BF938091A0019091A101EE +:1005B000A091A201B091A3010196A11DB11D80934C +:1005C000A0019093A101A093A201B093A3018091F7 +:1005D000A4019091A501A091A601B091A70180501E +:1005E000904CAF4FBF4F8093A4019093A501A0936F +:1005F000A601B093A70127C08091A4019091A50105 +:10060000A091A601B091A70180589E43A040B040A0 +:100610008093A4019093A501A093A601B093A70194 +:100620008091A8019091A901A091AA01B091AB017C +:100630000196A11DB11D8093A8019093A901A093DB +:10064000AA01B093AB018091A4019091A501A09162 +:10065000A601B091A70181589E43A040B04060F62A +:10066000BF91AF919F918F912F910F900FBE0F90DF +:100670001F901895EF92FF920F931F937B018C01AF +:100680008FB7F8944091A8015091A9016091AA01F7 +:100690007091AB018FBF2FB7F8948091A801909112 +:1006A000A901A091AA01B091AB012FBF841B950BAA +:1006B000A60BB70BE816F9060A071B0760F71F9190 +:1006C0000F91FF90EF900895789484B5826084BD77 +:1006D00084B5816084BD85B5826085BD85B5816046 +:1006E00085BDEEE6F0E0808181608083E1E8F0E0A6 +:1006F000808182608083808181608083E0E8F0E097 +:10070000808181608083E1EBF0E080818460808380 +:10071000E0EBF0E0808181608083EAE7F0E08081B7 +:100720008460808380818260808380818160808317 +:100730008081806880831092C100089587709091B5 +:1007400000019295990F990F907C982B90937C00C3 +:1007500080917A00806480937A0080917A0086FD8F +:10076000FCCF2091780040917900942F80E030E018 +:10077000282B392BC90108951F93CF93DF93182F8E +:10078000EB0161E00E941504E12FF0E0E255FF4F1C +:100790008491833051F48091800080688093800040 +:1007A000D0938900C09388003CC0843051F480917C +:1007B0008000806280938000D0938B00C0938A0079 +:1007C00030C0813039F4209729F184B5806884BD28 +:1007D000C7BD27C0823039F42097E1F084B580622C +:1007E00084BDC8BD1EC0863041F48091B0008068D1 +:1007F0008093B000C093B30014C0873041F480915F +:10080000B00080628093B000C093B4000AC0C038CA +:10081000D1051CF4812F60E002C0812F61E00E94AD +:100820003504DF91CF911F910895282F30E0C90141 +:1008300086569F4FFC0194912A573F4FF9018491AE +:10084000882391F0E82FF0E0EE0FFF1FE859FF4FEB +:10085000A591B491662329F48C91909589238C936A +:1008600008958C91892B8C930895482F50E0CA01EC +:1008700082559F4FFC012491CA0186569F4FFC016F +:1008800094914A575F4FFA0134913323D1F12223D7 +:1008900031F1233021F4809180008F7705C024301E +:1008A00031F4809180008F7D8093800018C02130CA +:1008B00019F484B58F7704C0223021F484B58F7D7C +:1008C00084BD0DC0263021F48091B0008F7705C023 +:1008D000273029F48091B0008F7D8093B000E32F02 +:1008E000F0E0EE0FFF1FEE58FF4FA591B491662385 +:1008F00029F48C91909589238C9308958C91892B60 +:100900008C93089597FB092E07260AD077FD04D013 +:1009100049D006D000201AF4709561957F4F089554 +:10092000F6F7909581959F4F0895A1E21A2EAA1B84 +:10093000BB1BFD010DC0AA1FBB1FEE1FFF1FA2178F +:10094000B307E407F50720F0A21BB30BE40BF50B8C +:10095000661F771F881F991F1A9469F76095709515 +:10096000809590959B01AC01BD01CF01089597FB47 +:10097000092E05260ED057FD04D0D7DF0AD0001C63 +:1009800038F450954095309521953F4F4F4F5F4F2C +:100990000895F6F790958095709561957F4F8F4FEC +:1009A0009F4F0895AA1BBB1B51E107C0AA1FBB1F85 +:1009B000A617B70710F0A61BB70B881F991F5A95EB +:1009C000A9F780959095BC01CD010895EE0FFF1F0A +:0C09D0000590F491E02D0994F894FFCFFD +:0809DC0001000000009A010077 +:00000001FF diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.pde b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.pde new file mode 100644 index 0000000..7d50858 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Potenciometro_com_LED_e_Serial.pde @@ -0,0 +1,91 @@ +#include + +#define P0 0 // Porta Digital 0 - Led 1 - +#define P1 1 // Porta Digital 1 - Led 2 +#define P2 2 // Porta Digital 2 - Led 3 - PWM +#define P3 3 // Porta Digital 3 - Led 4 +#define P4 4 // Porta Digital 4 - Led 5 - PWM +#define P5 5 // Porta Digital 5 - Led 6 - PWM +#define P6 6 // Porta Digital 6 - Led 7 +#define P7 7 // Porta Digital 7 - Led 8 +#define P8 8 // Porta Digital 8 - Transistor Q3 +#define P9 9 // Porta Digital 9 - Transistor Q2 - PWM +#define P10 10 // Porta Digital 10 - Servo1 - PWM +#define P11 11 // Porta Digital 11 - Servo2 - PWM +#define P12 12 // Porta Digital 12 - Buzzer +#define P13 13 // Porta Digital 13 - Led 9 +#define AP0 14 // Porta Analogica 0 +#define AP1 15 // Porta Analogica 1 +#define AP2 16 // Porta Analogica 2 +#define AP3 17 // Porta Analogica 3 +#define AP4 18 // Porta Analogica 4 +#define AP5 19 // Porta Analogica 5 + +#define A0 0 // Porta Analogica 0 - LDR +#define A1 1 // Porta Analogica 1 - POT 1 +#define A2 2 // Porta Analogica 2 - POT 2 +#define A3 3 // Porta Analogica 3 - Transistor Q5 +#define A4 4 // Porta Analogica 4 - Transistor Q4 +#define A5 5 // Porta Analogica 3 - Chave + +#define LED_1 0 +#define LED_2 1 +#define LED_3 2 +#define LED_4 3 +#define LED_5 4 +#define LED_6 5 +#define LED_7 6 +#define LED_8 7 +#define LED_9 13 + +#define Q2 9 +#define Q3 8 +#define Q4 17 +#define Q5 18 + +#define LDR 0 +#define POT1 1 +#define POT2 2 +#define CHAVE 5 +int pos = 0; // variable to store the servo position + +int transistorPin1 = P8; +int transistorPin2 = P9; +int transistorPin3 = AP3; +int transistorPin4 = AP4; + +int inPin = AP5; + +int val = 0; + +Servo myservo9; // create servo object to control a servo + +void setup() { + // myservo9.attach(10); // attaches the servo on pin 9 to the servo object + + pinMode(2, INPUT); + pinMode(5, OUTPUT); + pinMode(9, OUTPUT); + pinMode(10, OUTPUT); + pinMode(11, OUTPUT); + pinMode(3, OUTPUT); + pinMode(4, OUTPUT); + Serial.begin(9600); +} + +void loop(){ + analogWrite(3, analogRead(2)); + analogWrite(4, analogRead(2)/4); + analogWrite(9, analogRead(2)/4); + //analogWrite(9, 128); + //digitalWrite (9, HIGH); + pos = analogRead(2) / 7; + //myservo9.write(pos); // tell servo to go to position in variable 'pos' + + analogWrite(5, analogRead(2)); + Serial.println(analogRead(2)); + delay(100); + +} + + diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Print.cpp.o b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Print.cpp.o new file mode 100644 index 0000000..6205c51 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/WInterrupts.c.o new file mode 100644 index 0000000..b74dfbb Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/WMath.cpp.o new file mode 100644 index 0000000..4e4cf44 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/core.a b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/core.a new file mode 100644 index 0000000..92e9407 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/pins_arduino.c.o new file mode 100644 index 0000000..c450af7 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring.c.o b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring.c.o new file mode 100644 index 0000000..acbd542 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_analog.c.o new file mode 100644 index 0000000..b56797d Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_digital.c.o new file mode 100644 index 0000000..3928ccd Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_pulse.c.o new file mode 100644 index 0000000..525eda2 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_serial.c.o b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_serial.c.o new file mode 100644 index 0000000..b8d4c17 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_serial.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_shift.c.o new file mode 100644 index 0000000..8e0db5b Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/Potenciometro_com_LED_e_Serial/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/Receptor_RF/Receptor_RF.pde b/arduino/all the sketchs of my life/Projetos/Receptor_RF/Receptor_RF.pde new file mode 100644 index 0000000..beedd68 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/Receptor_RF/Receptor_RF.pde @@ -0,0 +1,57 @@ +#include + +#define BOTAO_PORTAO 9 +#define BOTAO_INTERFONE 8 +#define LED 4 +int valor_anterior = -1; +int erro =0; +int recebidos = 0; + +uint8_t buf[VW_MAX_MESSAGE_LEN]; +uint8_t buflen = VW_MAX_MESSAGE_LEN; + + +void setup() +{ + Serial.begin(9600); // Debugging only + //Serial.println("setup"); + pinMode(LED, OUTPUT); + pinMode(BOTAO_PORTAO, OUTPUT); + pinMode(BOTAO_INTERFONE, OUTPUT); + pinMode(12, INPUT); + vw_set_rx_pin (12); + vw_setup(2000); // Bits per sec + vw_rx_start(); +} + +void loop() +{ + digitalWrite(BOTAO_PORTAO, true); + digitalWrite(BOTAO_INTERFONE, false); + //Serial.println("Esperando..."); + if (vw_get_message(buf, &buflen)) // Non-blocking + { + digitalWrite(BOTAO_PORTAO, false); + digitalWrite(BOTAO_INTERFONE, true); + digitalWrite(LED, true); + Serial.println("Chegou"); + delay(1000); + switch (buf[0]){ + case '0': + break; + case '1': + break; + case '2': + break; + case '9': + break; + } + digitalWrite(BOTAO_PORTAO, true); + digitalWrite(BOTAO_INTERFONE, false); + digitalWrite(LED, false); + recebidos++; + } +} + + + diff --git a/arduino/all the sketchs of my life/Projetos/RoboVoador/RoboVoador.pde b/arduino/all the sketchs of my life/Projetos/RoboVoador/RoboVoador.pde new file mode 100644 index 0000000..8f87c31 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/RoboVoador/RoboVoador.pde @@ -0,0 +1,31 @@ +#include + +#define MOTOR1 11 +#define SERVO1 10 +#define LDR 0 +Servo myservo; + +void setup() +{ + Serial.begin(9600); + myservo.attach(SERVO1); +} + +void loop() +{ + myservo.write(1); + funcionaMotor(1500); + delay(5000); + myservo.write(90); + funcionaMotor(1500); + delay(5000); + myservo.write(178); + funcionaMotor(1500); + delay(5000); +} + +void funcionaMotor(int tempo) { + analogWrite(MOTOR1,80); + delay(tempo); + analogWrite(MOTOR1,0); +} diff --git a/arduino/all the sketchs of my life/Projetos/Teste_Receptor/Teste_Receptor.pde b/arduino/all the sketchs of my life/Projetos/Teste_Receptor/Teste_Receptor.pde new file mode 100644 index 0000000..fb5299d --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/Teste_Receptor/Teste_Receptor.pde @@ -0,0 +1,44 @@ +#include +#include + +uint8_t buf[VW_MAX_MESSAGE_LEN]; +uint8_t buflen = VW_MAX_MESSAGE_LEN; + +LiquidCrystal lcd(14, 17, 4, 3, 2, 18); + +void setup() { + setupReceptorRF(); + lcd.begin(16, 2); + initLCD(); +} +void initLCD() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("BRoBot:"); + lcd.setCursor(0, 1); + lcd.print("Aguardando...."); +} +void setupReceptorRF() { + pinMode(1,INPUT); + pinMode(12, OUTPUT); + vw_set_rx_pin (1); //Pino que recebe os dados + vw_setup(2000); // Bits per sec + vw_rx_start(); // Start the receiver PLL running +} + +void loop(){ + uint8_t buf[VW_MAX_MESSAGE_LEN]; + uint8_t buflen = VW_MAX_MESSAGE_LEN; + if (vw_get_message(buf, &buflen)) // Non-blocking + { + char conteudo[buflen]; + for(int x=0;x0) { + byte incoming=Serial.read(); + Serial.println("Recebendo dados"); + Serial.println(incoming, DEC); + if(incoming==1) { + digitalWrite(3, HIGH); + delay(2000); + digitalWrite(3, LOW); + } + else { + digitalWrite(2, HIGH); + delay(2000); + digitalWrite(2, LOW); + } + } +} + diff --git a/arduino/all the sketchs of my life/Projetos/Transmissor_Serial/Transmissor_Serial.pde b/arduino/all the sketchs of my life/Projetos/Transmissor_Serial/Transmissor_Serial.pde new file mode 100644 index 0000000..f41a530 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/Transmissor_Serial/Transmissor_Serial.pde @@ -0,0 +1,48 @@ +#include + +char comando[16]; + +void setup() +{ + Serial.begin(9600); + pinMode(3, OUTPUT); + vw_set_tx_pin(3); + vw_setup(2000); +} + +void loop() +{ + int counter=0; + if(Serial.available()>0) { + limpaComando(); + Serial.print("Lendo "); + while(Serial.available()>0 && counter<=16 && comando[counter]!='\n') { + comando[counter]=Serial.read(); + Serial.print(comando[counter]); + counter++; + delay(10); + } + Serial.print(" - "); + Serial.print(counter-1); + Serial.println("bytes lidos"); + Serial.print("Enviando "); + Serial.print(sizeof(comando)); + Serial.print(" bytes="); + Serial.println(comando); + enviar(comando); + //processar(comando); + } +} + +void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } +} +void enviar(char* comando) { + vw_send((uint8_t *) comando,strlen(comando)); +} + + + + diff --git a/arduino/all the sketchs of my life/Projetos/Ubatuba/Ubatuba.pde b/arduino/all the sketchs of my life/Projetos/Ubatuba/Ubatuba.pde new file mode 100644 index 0000000..50b8a11 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/Ubatuba/Ubatuba.pde @@ -0,0 +1,17 @@ +void setup() { + for(int x=0;x<20;x++) { + pinMode(x, OUTPUT); + } +} + +void loop() { + for(int x=0;x<20;x++) { + digitalWrite(x, HIGH); + } + delay(1000); + for(int x=0;x<20;x++) { + digitalWrite(x, LOW); + } + delay(1000); +} + diff --git a/arduino/all the sketchs of my life/Projetos/_3ShieldTest/Servo1.pde b/arduino/all the sketchs of my life/Projetos/_3ShieldTest/Servo1.pde new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/Projetos/_3ShieldTest/_3ShieldTest.pde b/arduino/all the sketchs of my life/Projetos/_3ShieldTest/_3ShieldTest.pde new file mode 100644 index 0000000..3bdfced --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/_3ShieldTest/_3ShieldTest.pde @@ -0,0 +1,118 @@ +#include +#include +//#include + +#define MOTOR1_P 12 +#define MOTOR1_N 11 +#define MOTOR1_PWM 5 + +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 6 +LiquidCrystal lcd(14, 15, 16, 17, 18, 19); + +//Servo servoHorizontal; // create servo object to control a servo +//Servo servoVertical; // create servo object to control a servo + + +void setup() { + setupReceptorRF(); + + pinMode(5, OUTPUT); + pinMode(6, OUTPUT); + pinMode(7, OUTPUT); + pinMode(8, OUTPUT); + pinMode(9, OUTPUT); + pinMode(10, OUTPUT); + pinMode(14, OUTPUT); + pinMode(15, OUTPUT); + pinMode(16, OUTPUT); + pinMode(17, OUTPUT); + pinMode(18, OUTPUT); + pinMode(19, OUTPUT); + + //servoHorizontal.attach(10); // attaches the servo on pin 9 to the servo object + //servoVertical.attach(11); + Serial.begin(9600); + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("BRoBot:"); + lcd.setCursor(0, 1); + lcd.print("Aguardando...."); +} +void setupReceptorRF() { + pinMode(12, OUTPUT); + digitalWrite(12, LOW); + //Configura o Receptor + vw_set_rx_pin (12); //Pino que recebe os dados + vw_setup(2000); // Bits per sec + vw_rx_start(); // Start the receiver PLL running + +} +void loop() { + + //Serial.println(analogRead(0)/4); + /*if(Serial.available()>0) { + + while(Serial.available()>0) { + + int dado = int(Serial.read()); + Serial.println(dado,DEC); + //servoVertical.write(dado); + int dado1 = int(Serial.read()); + Serial.println(dado1,DEC); + //servoHorizontal.write(dado1); + + } + }*/ + analogWrite(MOTOR1_PWM,250); + //digitalWrite(MOTOR1_PWM, HIGH); + digitalWrite(MOTOR1_P, HIGH); + digitalWrite(MOTOR1_N, LOW); + analogWrite(MOTOR2_PWM, 250); + //digitalWrite(MOTOR2_PWM, HIGH); + digitalWrite(MOTOR2_P, HIGH); + digitalWrite(MOTOR2_N, LOW); + delay(2000); + + /*uint8_t buf[VW_MAX_MESSAGE_LEN]; + uint8_t buflen = VW_MAX_MESSAGE_LEN; + Serial.println("Esperando..."); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("BRoBot:"); + lcd.setCursor(0, 1); + + if (vw_get_message(buf, &buflen)) // Non-blocking + { + int i; + Serial.println("cHEGOU..."); + lcd.setCursor(0, 1); + lcd.print("Recebendo Dados..."); + + for (i = 0; i < buflen-1; i++) + { + lcd.clear(); + lcd.setCursor(0, 0); + if(buf[i]='a') { + lcd.print("Vou andar"); + + analogWrite(MOTOR1_PWM, 250); + digitalWrite(MOTOR1_P, !HIGH); + digitalWrite(MOTOR1_N, !LOW); + analogWrite(MOTOR2_PWM, 250); + digitalWrite(MOTOR2_P, !HIGH); + digitalWrite(MOTOR2_N, !LOW); + delay(1000); + } + Serial.print(buf[i]); + } + lcd.clear(); + + }*/ + +} + + + diff --git a/arduino/all the sketchs of my life/Projetos/android/android.pde b/arduino/all the sketchs of my life/Projetos/android/android.pde new file mode 100644 index 0000000..5d2b30b --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/android/android.pde @@ -0,0 +1,57 @@ +/* + Sends sensor data to Android + (needs SensorGraph and Amarino app installed and running on Android) +*/ +#include +#include +#include + +MeetAndroid meetAndroid; +int sensor = 5; +int bussolaVal =200; + +LiquidCrystal lcd(4, 9, 14, 15, 16, 17); + +void setup() +{ + // use the baud rate your bluetooth module is configured to + // not all baud rates are working well, i.e. ATMEGA168 works best with 57600 + Serial.begin(115200); + Wire.begin(0x12); + Wire.onRequest(sendBussola); + initLCD(); + lcd.begin(16, 2); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Device Ready"); + // we initialize pin 5 as an input pin + pinMode(sensor, INPUT); + meetAndroid.registerFunction(bussola, 'A'); +} + +void sendBussola() { + Wire.send(bussolaVal); + +} + +void bussola(byte flag, byte numOfValues) { + int b[numOfValues]; + meetAndroid.getIntValues(b); + bussolaVal=b[0]; + + lcd.setCursor(0, 1); + lcd.print(b[0]); +} + +void initLCD() { +} +void loop() +{ + meetAndroid.receive(); // you need to keep this in your loop() to receive events + + // read input pin and send result to Android + meetAndroid.send(analogRead(sensor)); + + // add a little delay otherwise the phone is pretty busy + delay(200); +} diff --git a/arduino/all the sketchs of my life/Projetos/android_masterobot/android_masterobot.pde b/arduino/all the sketchs of my life/Projetos/android_masterobot/android_masterobot.pde new file mode 100644 index 0000000..c313049 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/android_masterobot/android_masterobot.pde @@ -0,0 +1,36 @@ +/* + Sends sensor data to Android + (needs SensorGraph and Amarino app installed and running on Android) +*/ +#include + +int bussolaVal =200; +boolean dataReady = false; + +void setup() +{ + Serial.begin(9600); + Wire.begin(); +} + + +void loop() +{ + delay(200); + + Wire.requestFrom(0x12 , 2); + delay(50); + boolean timeout = true; + for (int i = 0; i < 10; i++) { + if (Wire.available() > 0) { + timeout = false; + Serial.print("Receive"); + bussolaVal=Wire.receive(); + Serial.println(bussolaVal); + break; + } + + } + Serial.println("esperando"); + +} diff --git a/arduino/all the sketchs of my life/Projetos/home3/RGB.ino b/arduino/all the sketchs of my life/Projetos/home3/RGB.ino new file mode 100644 index 0000000..d549ee8 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/home3/RGB.ino @@ -0,0 +1,62 @@ +void modo_change_rgb_red_setup() { + lcd.setCursor(0, 1); + lcd.print("RED"); + rgb='R'; +} +void modo_change_rgb_green_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("GREEN"); + rgb='G'; +} +void modo_change_rgb_blue_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("BLUE"); + rgb='B'; +} +void modo_change_rgb() { + lcd.clear(); + lcd.setCursor(0, 0); + readPing(); + int port = 0; + if(rgb=='R') { + port = RED; + lcd.print("RGB Red"); + } + else if(rgb=='G') { + port = GREEN; + lcd.print("RGB Green"); + } + else if(rgb=='B') { + port = BLUE; + lcd.print("RGB Blue"); + } + if(cm<10) { + delay(200); + readPing(); + if(cm<10){ + blink(port, 3, 100); + while(cm<50) { + int cmok=cm; + cmok = cmok>25 ? 25 : cmok; + cmok = cmok<5 ? 5 : cmok; + + int amount = map(cmok,5,25,255,0); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(amount); + analogWrite(port, amount); + delay(50); + readPing(); + } + } + } + delay(150); +} + diff --git a/arduino/all the sketchs of my life/Projetos/home3/home3.ino b/arduino/all the sketchs of my life/Projetos/home3/home3.ino new file mode 100644 index 0000000..b073dcf --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/home3/home3.ino @@ -0,0 +1,280 @@ +#include +#include +#include +#include "hrmi_funcs.h" + +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 +#define MAX_IN_BUFFSIZE 16 + +LiquidCrystal_I2C lcd(0x27,16,2); + +#define RELAY1 7 +#define RELAY2 8 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo + +#define BLUE 9 +#define GREEN 6 +#define RED 3 + +#define TEMPERATURE 2 +#define LIGHT 3 +#define PING_PIN 5 + +#define LED 13 +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use + +long duration, inches, cm; +boolean connected = false; +long handTimer=0; + +char rgb='R'; +void setup() +{ + hrmi_open(); + + Kernel.setup(INTERRUPTION); + + Kernel.registerMode("M1", modo_default_setup); + Kernel.registerTask(modo_default); + Kernel.registerMode("MH", modo_heart_monitor_setup); + Kernel.registerTask(modo_heart_monitor); + + Kernel.registerMode("M2", modo_change_rgb_red_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M3", modo_change_rgb_green_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M4", modo_change_rgb_blue_setup); + Kernel.registerTask(modo_change_rgb); + + Serial.begin(115200); + pinMode(LED, OUTPUT); + //pinMode(RELAY1, OUTPUT); + //pinMode(RELAY2, OUTPUT); + lcd.init(); + lcd.setBacklight(0); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print("by Globalcode"); + delay(500); +} + + +void loop() +{ + Kernel.loop(); +} +void modo_heart_monitor_setup() { +} +void modo_heart_monitor() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + //} + Serial.println(" "); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Heart Monitor"); + lcd.setCursor(0, 1); + //char c*[]; + //toa(i2cRspArray[2],&c); + String n = String(i2cRspArray[2]); + + lcd.print(i2cRspArray[2],DEC); + + } + if (++numEntries > 30) numEntries = 0; + Kernel.wait(300); +} + +void modo_default_setup() { + lcd.setBacklight(15); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); +} +void modo_default() { + + if(Serial.available()) receiveCommand(); + if(millis()-handTimer>1000) { + readPing(); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(readTemperatureCelsius()); + handTimer=millis(); + } + +} + +float readTemperatureCelsius() { + float temperatura = (analogRead(TEMPERATURE) * 0.00488); // 5V / 1023 = 0.00488 (precisão do A/D) + temperatura = temperatura * 100; //Converte milivolts para graus celcius, lembrando que a cada 10mV equivalem a 1 grau celcius + return temperatura; +} + +void handShake() { + //Serial.print("ID 0|bluetooth prototype device|6|A|relay|B|dimmer|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.print("ID 1|bluetooth board sensor|6|H|heartbeat|C|temperature-bluetooth|D|light-bluetooth|S|allsensors|R|RGB-bluetooth|F|distance"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); + connected=false; +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + //if(comando[0]=='A') relayCommand(comando[1], 'A'); + //if(comando[0]=='B') relayCommand(comando[1], 'B'); + if(comando[0]=='R') RGB(comando); + if(comando[0]=='D') readLight(); + if(comando[0]=='H') readHeartBeat(); + if(comando[0]=='F') readDistance(); + if(comando[0]=='C') readTemperature(); + if(comando[0]=='S') readAllSensors(); + if(comando[0]=='X') shutdown(); +} +void readHeartBeat() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + Serial.flush(); + } + if (++numEntries > 30) numEntries = 0; +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void readLight() { + String toSend = String(analogRead(LIGHT)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(TEMPERATURE)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + Serial.print("|"); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + +void readDistance() { + readPing(); + sendToPC(String(cm)); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + + + + + + + +void blink(int port, int n, int d) { + pinMode(port, OUTPUT); + for(int x=0;x + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.write(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/Projetos/jHome/jHome.pde b/arduino/all the sketchs of my life/Projetos/jHome/jHome.pde new file mode 100644 index 0000000..cbe1b16 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/jHome/jHome.pde @@ -0,0 +1,176 @@ +# Default jHome pin +#define RX 0 +#define TX 1 +#define AUX_INT 2 + +#define RELAY1 3 +#define RELAY2 4 + +#define RED 5 +#define GREEN 6 + +#define AUX1 7 +#define AUX2 8 + +#define BLUE 9 +//10, 11, 12, 13 SPI port reserved for ethernet + +//ANALOG +#define RELAY1 14 //0 +#define RELAY2 15 //1 + +#define TEMPERATURE 2 +#define LIGHT 3 +//4, 5 reserved for I2C component, ex. LCD display + +long duration, inches, cm; +boolean connected = false; + +void setup() +{ + Serial.begin(115200); + pinMode(LED, OUTPUT); + pinMode(RELAY1, OUTPUT); + pinMode(RELAY2, OUTPUT); + pinMode(PORTAO_1, OUTPUT); + pinMode(PORTAO_2, OUTPUT); + +} + +void loop() +{ + if(Serial.available()) receiveCommand(); +} + +void handShake() { + //Serial.print("ID 0|bluetooth prototype device|6|A|relay|B|dimmer|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.print("ID 1|USB prototype device|6|A|lamp|B|wallsocket|C|temperature|D|light|S|allsensors|R|RGB"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); + connected=false; +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + if(comando[0]=='A') relayCommand(comando[1], 'A'); + if(comando[0]=='B') relayCommand(comando[1], 'B'); + if(comando[0]=='R') RGB(comando); + if(comando[0]=='D') readLight(); + if(comando[0]=='F') readDistance(); + if(comando[0]=='C') readTemperature(); + if(comando[0]=='S') readAllSensors(); + if(comando[0]=='X') shutdown(); +} + +void relayCommand(char operation, char relay) { + if(operation=='+') { + digitalWrite(relay=='A' ? RELAY1 : RELAY2, HIGH); + } + else if(operation=='-') { + digitalWrite(relay=='A' ? RELAY1 : RELAY2, LOW); + } +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void dimmer(char* comando) { +} + +void readLight() { + String toSend = String(analogRead(LIGHT)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(TEMPERATURE)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + +void readDistance() { + readPing(); + sendToPC(cm); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/jHome_device1/jHome_device1.pde b/arduino/all the sketchs of my life/Projetos/jHome_device1/jHome_device1.pde new file mode 100644 index 0000000..8ec7f8b --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/jHome_device1/jHome_device1.pde @@ -0,0 +1,171 @@ +#define RELAY1 2 +#define RELAY2 4 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo + +#define BLUE 9 +#define GREEN 6 +#define RED 5 + +#define TEMPERATURE 2 +#define LIGHT 3 +#define PING_PIN 3 + +#define PORTAO_1 7 +#define PORTAO_2 8 + +#define LED 13 + +long duration, inches, cm; +boolean connected = false; + +void setup() +{ + Serial.begin(115200); + pinMode(LED, OUTPUT); + pinMode(RELAY1, OUTPUT); + pinMode(RELAY2, OUTPUT); + pinMode(PORTAO_1, OUTPUT); + pinMode(PORTAO_2, OUTPUT); + +} + +void loop() +{ + if(Serial.available()) receiveCommand(); +} + +void handShake() { + //Serial.print("ID 0|bluetooth prototype device|6|A|relay|B|dimmer|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.print("ID 1|USB prototype device|6|A|lamp|B|wallsocket|C|temperature|D|light|S|allsensors|R|RGB"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); + connected=false; +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + if(comando[0]=='A') relayCommand(comando[1], 'A'); + if(comando[0]=='B') relayCommand(comando[1], 'B'); + if(comando[0]=='R') RGB(comando); + if(comando[0]=='D') readLight(); + if(comando[0]=='F') readDistance(); + if(comando[0]=='C') readTemperature(); + if(comando[0]=='S') readAllSensors(); + if(comando[0]=='X') shutdown(); +} + +void relayCommand(char operation, char relay) { + if(operation=='+') { + digitalWrite(relay=='A' ? RELAY1 : RELAY2, HIGH); + } + else if(operation=='-') { + digitalWrite(relay=='A' ? RELAY1 : RELAY2, LOW); + } +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void dimmer(char* comando) { +} + +void readLight() { + String toSend = String(analogRead(LIGHT)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(TEMPERATURE)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + +void readDistance() { + readPing(); + sendToPC(cm); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + diff --git a/arduino/all the sketchs of my life/Projetos/jHome_deviceJL/jHome_deviceJL.ino b/arduino/all the sketchs of my life/Projetos/jHome_deviceJL/jHome_deviceJL.ino new file mode 100644 index 0000000..ae85fff --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/jHome_deviceJL/jHome_deviceJL.ino @@ -0,0 +1,136 @@ + +#define RELAY1 14 +#define RELAY2 15 +#define RELAY3 16 +#define RELAY4 17 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo + +#define BLUE 9 +#define GREEN 6 +#define RED 5 + +#define TEMPERATURE 2 +#define LIGHT 3 +#define PING_PIN 3 + +#define LED 13 + +long duration, inches, cm; +boolean connected = false; + +void setup() +{ + Serial.begin(115200); + pinMode(LED, OUTPUT); + pinMode(RELAY1, OUTPUT); + pinMode(RELAY2, OUTPUT); + pinMode(RELAY3, OUTPUT); + pinMode(RELAY4, OUTPUT); + +} + +void loop() +{ + if(Serial.available()) receiveCommand(); +} + +void handShake() { + //Serial.print("ID 0|bluetooth prototype device|6|A|relay|B|dimmer|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.print("ID 4|USB prototype device|4|A|wallsock1|B|wallsocket2|C|wallsock3|D|wallsock4"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); + connected=false; +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + if(comando[0]=='A') relayCommand(comando[1], 'A'); + if(comando[0]=='B') relayCommand(comando[1], 'B'); + if(comando[0]=='C') relayCommand(comando[1], 'C'); + if(comando[0]=='D') relayCommand(comando[1], 'D'); + if(comando[0]=='X') shutdown(); +} + +void relayCommand(char operation, char relay) { + if(operation=='+') { + digitalWrite(relay=='A' ? RELAY1 : relay=='B' ? RELAY2 : relay=='C' ? RELAY3 : RELAY4, HIGH); + } + else if(operation=='-') { + digitalWrite(relay=='A' ? RELAY1 : relay=='B' ? RELAY2 : relay=='C' ? RELAY3 : RELAY4, LOW); + } + +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void dimmer(char* comando) { +} + +void readLight() { + String toSend = String(analogRead(LIGHT)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(TEMPERATURE)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + + + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + diff --git a/arduino/all the sketchs of my life/Projetos/jHome_sensor/hrmi_funcs.cpp b/arduino/all the sketchs of my life/Projetos/jHome_sensor/hrmi_funcs.cpp new file mode 100644 index 0000000..a0c8c46 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/jHome_sensor/hrmi_funcs.cpp @@ -0,0 +1,60 @@ +/* + * hrmi_funcs.cpp + * + * Arduino library to communicate with a HRMI using I2C + * + * Written by Dan Julio, www.danjuliodesigns.com + * Version 1.1, 12/28/2008 + * + */ + + #include + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.write(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/Projetos/jHome_sensor/jHome_sensor.ino b/arduino/all the sketchs of my life/Projetos/jHome_sensor/jHome_sensor.ino new file mode 100644 index 0000000..bfa3195 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/jHome_sensor/jHome_sensor.ino @@ -0,0 +1,341 @@ +#include +#include +#include + +#include "hrmi_funcs.h" +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 +#define MAX_IN_BUFFSIZE 16 + +LiquidCrystal_I2C lcd(0x27,16,2); + +#define RELAY1 7 +#define RELAY2 8 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo + +#define BLUE 9 +#define GREEN 6 +#define RED 3 + +#define TEMPERATURE 2 +#define LIGHT 3 +#define PING_PIN 5 + +#define LED 13 +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use + +long duration, inches, cm; +boolean connected = false; +long handTimer=0; + +char rgb='R'; +void setup() +{ + hrmi_open(); + + Kernel.setup(INTERRUPTION); + + Kernel.registerMode("M1", modo_default_setup); + Kernel.registerTask(modo_default); + Kernel.registerMode("MH", modo_heart_monitor_setup); + Kernel.registerTask(modo_heart_monitor); + + Kernel.registerMode("M2", modo_change_rgb_red_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M3", modo_change_rgb_green_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M4", modo_change_rgb_blue_setup); + Kernel.registerTask(modo_change_rgb); + + Serial.begin(115200); + pinMode(LED, OUTPUT); + //pinMode(RELAY1, OUTPUT); + //pinMode(RELAY2, OUTPUT); + lcd.init(); + lcd.setBacklight(0); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print("by Globalcode"); + delay(500); +} + + +void loop() +{ + Kernel.loop(); +} +void modo_heart_monitor_setup() { +} +void modo_heart_monitor() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + //} + Serial.println(" "); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Heart Monitor"); + lcd.setCursor(0, 1); + //char c*[]; + //toa(i2cRspArray[2],&c); + String n = String(i2cRspArray[2]); + + lcd.print(i2cRspArray[2],DEC); + + } + if (++numEntries > 30) numEntries = 0; + Kernel.wait(300); +} + +void modo_change_rgb_red_setup() { + lcd.setCursor(0, 1); + lcd.print("RED"); + rgb='R'; +} +void modo_change_rgb_green_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("GREEN"); + rgb='G'; +} +void modo_change_rgb_blue_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("BLUE"); + rgb='B'; +} +void modo_change_rgb() { + lcd.clear(); + lcd.setCursor(0, 0); + readPing(); + int port = 0; + if(rgb=='R') { + port = RED; + lcd.print("RGB Red"); + } + else if(rgb=='G') { + port = GREEN; + lcd.print("RGB Green"); + } + else if(rgb=='B') { + port = BLUE; + lcd.print("RGB Blue"); + } + if(cm<10) { + delay(200); + readPing(); + if(cm<10){ + blink(port, 3, 100); + while(cm<50) { + int cmok=cm; + cmok = cmok>25 ? 25 : cmok; + cmok = cmok<5 ? 5 : cmok; + + int amount = map(cmok,5,25,255,0); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(amount); + analogWrite(port, amount); + delay(50); + readPing(); + } + } + } + delay(150); +} +void modo_default_setup() { + lcd.setBacklight(15); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); +} +void modo_default() { + + if(Serial.available()) receiveCommand(); + if(millis()-handTimer>1000) { + readPing(); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(readTemperatureCelsius()); + handTimer=millis(); + } + +} + +float readTemperatureCelsius() { + float temperatura = (analogRead(TEMPERATURE) * 0.00488); // 5V / 1023 = 0.00488 (precisão do A/D) + temperatura = temperatura * 100; //Converte milivolts para graus celcius, lembrando que a cada 10mV equivalem a 1 grau celcius + return temperatura; +} + +void handShake() { + //Serial.print("ID 0|bluetooth prototype device|6|A|relay|B|dimmer|C|RGB|E|temperature|F|distance|S|allsensors"); + Serial.print("ID 1|bluetooth board sensor|6|H|heartbeat|C|temperature-bluetooth|D|light-bluetooth|S|allsensors|R|RGB-bluetooth|F|distance"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); + connected=false; +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + //if(comando[0]=='A') relayCommand(comando[1], 'A'); + //if(comando[0]=='B') relayCommand(comando[1], 'B'); + if(comando[0]=='R') RGB(comando); + if(comando[0]=='D') readLight(); + if(comando[0]=='H') readHeartBeat(); + if(comando[0]=='F') readDistance(); + if(comando[0]=='C') readTemperature(); + if(comando[0]=='S') readAllSensors(); + if(comando[0]=='X') shutdown(); +} +void readHeartBeat() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + Serial.flush(); + } + if (++numEntries > 30) numEntries = 0; +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void readLight() { + String toSend = String(analogRead(LIGHT)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(TEMPERATURE)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + Serial.print("|"); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + +void readDistance() { + readPing(); + sendToPC(String(cm)); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + + + + + + + +void blink(int port, int n, int d) { + pinMode(port, OUTPUT); + for(int x=0;x + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.write(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/Projetos/jHome_sensor_teste/jHome_sensor_teste.ino b/arduino/all the sketchs of my life/Projetos/jHome_sensor_teste/jHome_sensor_teste.ino new file mode 100644 index 0000000..d89df85 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/jHome_sensor_teste/jHome_sensor_teste.ino @@ -0,0 +1,303 @@ +#include +#include +#include +#include +#include "etherShield.h" +#include "ETHER_28J60.h" +#include "hrmi_funcs.h" +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 +#define MAX_IN_BUFFSIZE 16 +Device homeDevice=Device("sensor-device"); + +LiquidCrystal_I2C lcd(0x27,16,2); + + +#define BLUE 9 +#define GREEN 6 +#define RED 3 + +#define PING_PIN 5 + +#define LED 13 +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use + +long duration, inches, cm; +boolean connected = false; +long handTimer=0; + +char rgb='R'; +void setup() +{ + homeDevice.add("red", PWM, 3); + homeDevice.add("green", PWM, 6); + homeDevice.add("blue", PWM, 9); + + homeDevice.add("distance", LIB, 5); + + homeDevice.add("light", LIGHT, 3); + homeDevice.add("temp", TEMP, 2); + hrmi_open(); + + Kernel.setup(INTERRUPTION); + + Kernel.registerMode("M1", modo_default_setup); + Kernel.registerTask(modo_d efault); + Kernel.registerMode("MH", modo_heart_monitor_setup); + Kernel.registerTask(modo_heart_monitor); + + Kernel.registerMode("M2", modo_change_rgb_red_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M3", modo_change_rgb_green_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M4", modo_change_rgb_blue_setup); + Kernel.registerTask(modo_change_rgb); + + Serial.begin(115200); + pinMode(LED, OUTPUT); + //pinMode(RELAY1, OUTPUT); + //pinMode(RELAY2, OUTPUT); + lcd.init(); + lcd.setBacklight(0); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print("by Globalcode"); + delay(500); +} + + +void loop() +{ + Kernel.loop(); +} + +void modo_heart_monitor_setup() { +} + +void modo_heart_monitor() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + //} + Serial.println(" "); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Heart Monitor"); + lcd.setCursor(0, 1); + //char c*[]; + //toa(i2cRspArray[2],&c); + String n = String(i2cRspArray[2]); + + lcd.print(i2cRspArray[2],DEC); + + } + if (++numEntries > 30) numEntries = 0; + Kernel.wait(300); +} + +void modo_change_rgb_red_setup() { + lcd.setCursor(0, 1); + lcd.print("RED"); + rgb='R'; +} +void modo_change_rgb_green_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("GREEN"); + rgb='G'; +} +void modo_change_rgb_blue_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("BLUE"); + rgb='B'; +} +void modo_change_rgb() { + lcd.clear(); + lcd.setCursor(0, 0); + readPing(); + int port = 0; + if(rgb=='R') { + port = RED; + lcd.print("RGB Red"); + } + else if(rgb=='G') { + port = GREEN; + lcd.print("RGB Green"); + } + else if(rgb=='B') { + port = BLUE; + lcd.print("RGB Blue"); + } + if(cm<10) { + delay(200); + readPing(); + if(cm<10){ + blink(port, 3, 100); + while(cm<50) { + int cmok=cm; + cmok = cmok>25 ? 25 : cmok; + cmok = cmok<5 ? 5 : cmok; + + int amount = map(cmok,5,25,255,0); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(amount); + analogWrite(port, amount); + delay(50); + readPing(); + } + } + } + delay(150); +} +void modo_default_setup() { + lcd.setBacklight(15); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); +} +void modo_default() { + homeDevice.loop(); + //if(Serial.available()) receiveCommand(); + if(millis()-handTimer>1000) { + readPing(); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(readTemperatureCelsius()); + handTimer=millis(); + readDistance(); + } + +} + +float readTemperatureCelsius() { + float temperatura = (analogRead(2) * 0.00488); // 5V / 1023 = 0.00488 (precisão do A/D) + temperatura = temperatura * 100; //Converte milivolts para graus celcius, lembrando que a cada 10mV equivalem a 1 grau celcius + return temperatura; +} +void readHeartBeat() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + Serial.flush(); + } + if (++numEntries > 30) numEntries = 0; +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void readLight() { + String toSend = String(analogRead(3)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(2)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + Serial.print("|"); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + +void readDistance() { + readPing(); + sendToPC(String(cm)); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); + Serial.println(analogRead(3)); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + + + + + + + +void blink(int port, int n, int d) { + pinMode(port, OUTPUT); + for(int x=0;x + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.write(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/Projetos/jHome_sensor_teste1/jHome_sensor_teste1.ino b/arduino/all the sketchs of my life/Projetos/jHome_sensor_teste1/jHome_sensor_teste1.ino new file mode 100644 index 0000000..76f98b6 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/jHome_sensor_teste1/jHome_sensor_teste1.ino @@ -0,0 +1,304 @@ +#include +#include +#include +#include +#include "etherShield.h" +#include "ETHER_28J60.h" +#include "hrmi_funcs.h" +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 +#define MAX_IN_BUFFSIZE 16 +Device homeDevice=Device("sensor-device"); + +LiquidCrystal_I2C lcd(0x27,16,2); + + +#define BLUE 9 +#define GREEN 6 +#define RED 3 + +#define PING_PIN 5 + +#define LED 13 +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use + +long duration, inches, cm; +boolean connected = false; +long handTimer=0; + +char rgb='R'; +void setup() +{ + homeDevice.add("red", PWM, 3); + homeDevice.add("green", PWM, 6); + homeDevice.add("blue", PWM, 9); + + homeDevice.add("distance", PING, 5); + + homeDevice.add("light", LIGHT, 3); + homeDevice.add("temp", TEMP, 2); + hrmi_open(); + + + Kernel.setup(INTERRUPTION); + + Kernel.registerMode("M1", modo_default_setup); + Kernel.registerTask(modo_default); + Kernel.registerMode("MH", modo_heart_monitor_setup); + Kernel.registerTask(modo_heart_monitor); + + Kernel.registerMode("M2", modo_change_rgb_red_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M3", modo_change_rgb_green_setup); + Kernel.registerTask(modo_change_rgb); + Kernel.registerMode("M4", modo_change_rgb_blue_setup); + Kernel.registerTask(modo_change_rgb); + + + Serial.begin(115200); + pinMode(LED, OUTPUT); + //pinMode(RELAY1, OUTPUT); + //pinMode(RELAY2, OUTPUT); + lcd.init(); + lcd.setBacklight(0); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print("by Globalcode"); + delay(500); +} + + +void loop() +{ + Kernel.loop(); + +} + +void modo_heart_monitor_setup() { +} + +void modo_heart_monitor() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + //} + Serial.println(" "); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Heart Monitor"); + lcd.setCursor(0, 1); + //char c*[]; + //toa(i2cRspArray[2],&c); + String n = String(i2cRspArray[2]); + + lcd.print(i2cRspArray[2],DEC); + + } + if (++numEntries > 30) numEntries = 0; + Kernel.wait(300); +} + +void modo_change_rgb_red_setup() { + lcd.setCursor(0, 1); + lcd.print("RED"); + rgb='R'; +} +void modo_change_rgb_green_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("GREEN"); + rgb='G'; +} +void modo_change_rgb_blue_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("BLUE"); + rgb='B'; +} +void modo_change_rgb() { + lcd.clear(); + lcd.setCursor(0, 0); + readPing(); + int port = 0; + if(rgb=='R') { + port = RED; + lcd.print("RGB Red"); + } + else if(rgb=='G') { + port = GREEN; + lcd.print("RGB Green"); + } + else if(rgb=='B') { + port = BLUE; + lcd.print("RGB Blue"); + } + if(cm<10) { + delay(200); + readPing(); + if(cm<10){ + blink(port, 3, 100); + while(cm<50) { + int cmok=cm; + cmok = cmok>25 ? 25 : cmok; + cmok = cmok<5 ? 5 : cmok; + + int amount = map(cmok,5,25,255,0); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(amount); + analogWrite(port, amount); + delay(50); + readPing(); + } + } + } + delay(150); +} +void modo_default_setup() { + lcd.setBacklight(15); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); +} +void modo_default() { + homeDevice.loop(); + //if(Serial.available()) receiveCommand(); + if(millis()-handTimer>1000) { + readPing(); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(readTemperatureCelsius()); + handTimer=millis(); + } + +} + +float readTemperatureCelsius() { + float temperatura = (analogRead(2) * 0.00488); // 5V / 1023 = 0.00488 (precisão do A/D) + temperatura = temperatura * 100; //Converte milivolts para graus celcius, lembrando que a cada 10mV equivalem a 1 grau celcius + return temperatura; +} +void readHeartBeat() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + Serial.flush(); + } + if (++numEntries > 30) numEntries = 0; +} + +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = RED; + if(comando[1]=='G') port = GREEN; + if(comando[1]=='B') port = BLUE; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + + +void readLight() { + String toSend = String(analogRead(3)); + sendToPC(toSend); +} + +void readTemperature() { + String toSend = String(analogRead(2)); + sendToPC(toSend); +} + +void readAllSensors() { + //readLight(); + //Serial.print("|"); + //delay(2); + readTemperature(); + Serial.print("|"); + readLight(); + Serial.print("|"); + + //Serial.print("|"); + //String toSend3 = String(cm); + //Serial.print(cm); + //Serial.flush(); +} + + +char* readDistance() { + readPing(); + + sendToPC(String(cm)); +} + +void sendToPC(String dado) { + Serial.print(dado); + Serial.flush(); +} + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + Serial.print("duration "); + Serial.println(duration); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + + + + + + + + + + + +void blink(int port, int n, int d) { + pinMode(port, OUTPUT); + for(int x=0;xanalogRead(POTENCIOMETRO_1)) { + digitalWrite(TOMADA, HIGH); + } + else { + digitalWrite(TOMADA, LOW); + } + Serial.println(ldr); + delay(200); + +} + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.cpp.o b/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.cpp.o new file mode 100644 index 0000000..fe5656c Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.cpp.o differ diff --git a/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.eep b/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.elf b/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.elf new file mode 100644 index 0000000..fec028f Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.elf differ diff --git a/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.hex b/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.hex new file mode 100644 index 0000000..d42652f --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.hex @@ -0,0 +1,143 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C949B020C948A000C94C5000C948A00BA +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C00000007E0111241FBECFEFD8E0DEBFCDBF00 +:1000D00011E0A0E0B1E0ECECF8E002C005900D9278 +:1000E000A830B107D9F711E0A8E0B1E001C01D9236 +:1000F000AA3AB107E1F710E0C4ECD0E004C02297BF +:10010000FE010E946004C23CD107C9F70E94BE00F4 +:100110000C9464040C940000CF93DF9380E00E9461 +:100120006F03EC0181E00E946F038C179D071CF4A4 +:1001300082E161E002C082E160E00E94AD038CE8F0 +:1001400091E0BE010E948B0268EC70E080E090E0DC +:100150000E940B03DF91CF91089581E060E00E943F +:100160008D0382E161E00E948D038CE891E040E81C +:1001700055E260E070E00E94020108950E9435039C +:100180000E94AD000E948C00FDCF1F920F920FB60F +:100190000F9211242F933F934F935F936F937F930D +:1001A0008F939F93AF93BF93EF93FF934091C600BC +:1001B000E0918801F0918901CF01019660E870E03B +:1001C0000E94FA039C0180918A0190918B0128176B +:1001D000390739F0E85FFE4F40833093890120935F +:1001E0008801FF91EF91BF91AF919F918F917F9186 +:1001F0006F915F914F913F912F910F900FBE0F9094 +:100200001F901895AF92BF92CF92DF92EF92FF921C +:100210000F931F93CF93DF936C017A018B01DC0165 +:100220001496AD90BC901597CB01BA0122E030E056 +:1002300040E050E00E942F04205C3D4B404F5F4F58 +:10024000CA01B901A80197010E942F04C901DA016E +:100250000197A109B109292F3A2F4B2F552747FDA7 +:100260005A950196A11DB11DE5012883E601EE8195 +:10027000FF8181508083EA85FB85208141E050E049 +:10028000CA010E8402C0880F991F0A94E2F7282B36 +:100290002083EA85FB852081CA010F8402C0880F74 +:1002A000991F0A94E2F7282B2083EA85FB85808139 +:1002B000088802C0440F551F0A94E2F7842B8083FC +:1002C000DF91CF911F910F91FF90EF90DF90CF9032 +:1002D000BF90AF900895FC01A085B18521898C91D4 +:1002E00090E0022E02C0959587950A94E2F780FF70 +:1002F000F6CF0484F585E02D6083089585E091E0D4 +:1003000090938D0180938C0188E091E090938F0110 +:1003100080938E0185EC90E0909391018093900101 +:1003200084EC90E0909393018093920180EC90E0B4 +:10033000909395018093940181EC90E090939701C4 +:100340008093960186EC90E09093990180939801B8 +:1003500084E080939A0183E080939B0187E08093FF +:100360009C0185E080939D0108950F931F938C015C +:10037000DC01ED91FC910190F081E02D6DE009959B +:10038000D801ED91FC910190F081E02DC8016AE067 +:1003900009951F910F9108952F923F924F925F926E +:1003A0006F927F928F929F92AF92BF92CF92DF9285 +:1003B000EF92FF920F931F93DF93CF93CDB7DEB7EA +:1003C000A0970FB6F894DEBF0FBECDBF1C016A0127 +:1003D0007B01411551056105710549F4DC01ED9181 +:1003E000FC910190F081E02D60E3099554C08824D0 +:1003F00099245401422E55246624772401E010E00C +:100400000C0F1D1F080D191DC701B601A301920194 +:100410000E940D04F80160830894811C911CA11CAA +:10042000B11CC701B601A30192010E940D04C901CC +:10043000DA016C017D01C114D104E104F104F1F68B +:1004400081E0E82EF12CEC0EFD1EE80CF91C3E01BB +:100450000894611C711CD501C4010197A109B1095F +:100460006C01C818D90814C0F601EE0DFF1D60819B +:100470006A3010F4605D01C0695CD101ED91FC91BE +:100480000190F081E02DC10109950894E108F1087F +:100490006E147F0449F7A0960FB6F894DEBF0FBE26 +:1004A000CDBFCF91DF911F910F91FF90EF90DF9023 +:1004B000CF90BF90AF909F908F907F906F905F9004 +:1004C0004F903F902F900895EF92FF920F931F93BC +:1004D000CF93DF93EC017A018B0177FF0FC0E881A6 +:1004E000F9810190F081E02D6DE20995109500955C +:1004F000F094E094E11CF11C011D111DCE01B80126 +:10050000A7012AE00E94CC01DF91CF911F910F91AA +:10051000FF90EF9008950F931F938C01AB01662716 +:1005200057FD6095762F0E946402C8010E94B501B4 +:100530001F910F9108951F920F920FB60F921124E1 +:100540002F938F939F93AF93BF9380919E01909130 +:100550009F01A091A001B091A1010196A11DB11D23 +:1005600080939E0190939F01A093A001B093A1015D +:100570008091A2019091A301A091A401B091A50145 +:100580008050904CAF4FBF4F8093A2019093A30136 +:10059000A093A401B093A50127C08091A2019091DE +:1005A000A301A091A401B091A50180589E43A04051 +:1005B000B0408093A2019093A301A093A401B093B3 +:1005C000A5018091A6019091A701A091A801B091E9 +:1005D000A9010196A11DB11D8093A6019093A701C9 +:1005E000A093A801B093A9018091A2019091A301C9 +:1005F000A091A401B091A50181589E43A040B040B4 +:1006000060F6BF91AF919F918F912F910F900FBE88 +:100610000F901F901895EF92FF920F931F937B01FD +:100620008C018FB7F8944091A6015091A701609179 +:10063000A8017091A9018FBF2FB7F8948091A601EE +:100640009091A701A091A801B091A9012FBF841B8F +:10065000950BA60BB70BE816F9060A071B0760F700 +:100660001F910F91FF90EF900895789484B5826068 +:1006700084BD84B5816084BD85B5826085BD85B546 +:10068000816085BDEEE6F0E0808181608083E1E8F5 +:10069000F0E0808182608083808181608083E0E8F7 +:1006A000F0E0808181608083E1EBF0E08081846014 +:1006B0008083E0EBF0E0808181608083EAE7F0E016 +:1006C000808184608083808182608083808181607A +:1006D00080838081806880831092C1000895877034 +:1006E000909100019295990F990F907C982B90937F +:1006F0007C0080917A00806480937A0080917A00F7 +:1007000086FDFCCF2091780040917900942F80E005 +:1007100030E0282B392BC9010895282F30E0C9017A +:1007200086569F4FFC0194912A573F4FF9018491BF +:10073000882391F0E82FF0E0EE0FFF1FE859FF4FFC +:10074000A591B491662329F48C91909589238C937B +:1007500008958C91892B8C930895482F50E0CA01FD +:1007600082559F4FFC012491CA0186569F4FFC0180 +:1007700094914A575F4FFA0134913323D1F12223E8 +:1007800031F1233021F4809180008F7705C024302F +:1007900031F4809180008F7D8093800018C02130DB +:1007A00019F484B58F7704C0223021F484B58F7D8D +:1007B00084BD0DC0263021F48091B0008F7705C034 +:1007C000273029F48091B0008F7D8093B000E32F13 +:1007D000F0E0EE0FFF1FEE58FF4FA591B491662396 +:1007E00029F48C91909589238C9308958C91892B71 +:1007F0008C93089597FB092E07260AD077FD04D025 +:1008000049D006D000201AF4709561957F4F089565 +:10081000F6F7909581959F4F0895A1E21A2EAA1B95 +:10082000BB1BFD010DC0AA1FBB1FEE1FFF1FA217A0 +:10083000B307E407F50720F0A21BB30BE40BF50B9D +:10084000661F771F881F991F1A9469F76095709526 +:10085000809590959B01AC01BD01CF01089597FB58 +:10086000092E05260ED057FD04D0D7DF0AD0001C74 +:1008700038F450954095309521953F4F4F4F5F4F3D +:100880000895F6F790958095709561957F4F8F4FFD +:100890009F4F0895AA1BBB1B51E107C0AA1FBB1F96 +:1008A000A617B70710F0A61BB70B881F991F5A95FC +:1008B000A9F780959095BC01CD010895EE0FFF1F1B +:0C08C0000590F491E02D0994F894FFCF0E +:0808CC0001000000006B0100B7 +:00000001FF diff --git a/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.pde b/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.pde new file mode 100644 index 0000000..e9eb876 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/tomada/applet/tomada.pde @@ -0,0 +1,21 @@ +#define TOMADA 18 +#define POTENCIOMETRO_1 1 +#define LDR 0 +void setup() { + pinMode(POTENCIOMETRO_1, INPUT); + pinMode(TOMADA, OUTPUT); + Serial.begin(9600); +} + +void loop() { + int ldr = analogRead(LDR); + if(ldr>analogRead(POTENCIOMETRO_1)) { + digitalWrite(TOMADA, HIGH); + } + else { + digitalWrite(TOMADA, LOW); + } + Serial.println(ldr); + delay(200); + +} diff --git a/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring.c.o b/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring.c.o new file mode 100644 index 0000000..acbd542 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_analog.c.o new file mode 100644 index 0000000..b56797d Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_digital.c.o new file mode 100644 index 0000000..3928ccd Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_pulse.c.o new file mode 100644 index 0000000..525eda2 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_serial.c.o b/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_serial.c.o new file mode 100644 index 0000000..b8d4c17 Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_serial.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_shift.c.o new file mode 100644 index 0000000..8e0db5b Binary files /dev/null and b/arduino/all the sketchs of my life/Projetos/tomada/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Projetos/tomada/tomada.pde b/arduino/all the sketchs of my life/Projetos/tomada/tomada.pde new file mode 100644 index 0000000..03aa143 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/tomada/tomada.pde @@ -0,0 +1,13 @@ +#define TOMADA 2 +void setup() { + pinMode(TOMADA, OUTPUT); + Serial.begin(9600); +} + +void loop() { + digitalWrite(TOMADA, HIGH); + delay(2000); + digitalWrite(TOMADA, LOW); + delay(2000); + +} diff --git a/arduino/all the sketchs of my life/Projetos/ubatubino_sample1/ubatubino_sample1.pde b/arduino/all the sketchs of my life/Projetos/ubatubino_sample1/ubatubino_sample1.pde new file mode 100644 index 0000000..31bb8b2 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/ubatubino_sample1/ubatubino_sample1.pde @@ -0,0 +1,43 @@ +#define T1 3 +#define T2 9 +#define T3 11 +#define T4 12 + +void setup() { + pinMode(T1,OUTPUT); + pinMode(T2,OUTPUT); + pinMode(T3,OUTPUT); + pinMode(T4,OUTPUT); +} + +void loop() { + digitalWrite(T1, HIGH); + digitalWrite(T2, HIGH); + digitalWrite(T3, HIGH); + digitalWrite(T4, HIGH); + delay(1000); + digitalWrite(T1, LOW); + digitalWrite(T2, LOW); + digitalWrite(T3, LOW); + digitalWrite(T4, LOW); + delay(1000); + + digitalWrite(T1, HIGH); + delay(1000); + digitalWrite(T1, LOW); + delay(1000); + digitalWrite(T2, HIGH); + delay(1000); + digitalWrite(T2, LOW); + delay(1000); + digitalWrite(T3, HIGH); + delay(1000); + digitalWrite(T3, LOW); + delay(1000); + digitalWrite(T4, HIGH); + delay(1000); + digitalWrite(T4, LOW); + delay(1000); + + +} diff --git a/arduino/all the sketchs of my life/Projetos/xacualeitor/xacualeitor.pde b/arduino/all the sketchs of my life/Projetos/xacualeitor/xacualeitor.pde new file mode 100644 index 0000000..0bfc07a --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/xacualeitor/xacualeitor.pde @@ -0,0 +1,48 @@ +// Controlling a servo position using a potentiometer (variable resistor) +// by Michal Rinott + +#include + +Servo myservo; // create servo object to control a servo +Servo myservo1; // create servo object to control a servo + +int potpin = 1; // analog pin used to connect the potentiometer +int val; // variable to read the value from the analog pin + +void setup() +{ + Serial.begin(9600); + pinMode(9, OUTPUT); + pinMode(6, OUTPUT); + + myservo.attach(10); // attaches the servo on pin 9 to the servo object + myservo1.attach(11); // attaches the servo on pin 9 to the servo object +} + +void loop() +{ + /*for(int x=45;x<145;x++) { + if(x%10==0) { + myservo.write(x); + myservo1.write(x); + } + delay(300); + } + for(int x=145;x>45;x--) { + if(x%10==0) { + myservo.write(x); + myservo1.write(x); + } + delay(300); + }*/ + myservo.write(30); + myservo1.write(30); + delay(500); + myservo.write(70); + myservo1.write(70); + delay(500); + + +} + + diff --git a/arduino/all the sketchs of my life/Projetos/xacualeitor/xacualeitor/xacualeitor.pde b/arduino/all the sketchs of my life/Projetos/xacualeitor/xacualeitor/xacualeitor.pde new file mode 100644 index 0000000..163df66 --- /dev/null +++ b/arduino/all the sketchs of my life/Projetos/xacualeitor/xacualeitor/xacualeitor.pde @@ -0,0 +1,32 @@ +#include + +Servo myservo9; // create servo object to control a servo +Servo myservo10; // create servo object to control a servo + +int pos = 0; // variable to store the servo position + +void setup() +{ + myservo9.attach(11); // attaches the servo on pin 9 to the servo object + myservo10.attach(10); // attaches the servo on pin 10 to the servo object +} + +void loop() +{ + myservo10.write(95); + delay(3000); + + myservo10.write(110); + delay(3000); + /* + for(int x=85;x<105;x+=5) { + myservo10.write(x); + delay(2500); + } + + for(int x=110;x>80;x-=5) { + myservo10.write(x); + delay(2500); + }*/ +} + diff --git a/arduino/all the sketchs of my life/RCTim/RCTim.pde b/arduino/all the sketchs of my life/RCTim/RCTim.pde new file mode 100644 index 0000000..e92540f --- /dev/null +++ b/arduino/all the sketchs of my life/RCTim/RCTim.pde @@ -0,0 +1,29 @@ +int sensorPin = 5; // 220 or 1k resistor connected to this pin +long result = 0; +void setup() // run once, when the sketch starts +{ + Serial.begin(9600); + Serial.println("start"); // a personal quirk +} +void loop() // run over and over again +{ + + Serial.println( RCtime(sensorPin) ); + delay(10); + +} + +long RCtime(int sensPin){ + long result = 0; + pinMode(sensPin, OUTPUT); // make pin OUTPUT + digitalWrite(sensPin, HIGH); // make pin HIGH to discharge capacitor - study the schematic + delay(1); // wait a ms to make sure cap is discharged + + pinMode(sensPin, INPUT); // turn pin into an input and time till pin goes low + digitalWrite(sensPin, LOW); // turn pullups off - or it won't work + while(digitalRead(sensPin)){ // wait for pin to go low + result++; + } + + return result; // report results +} diff --git a/arduino/all the sketchs of my life/Robo_Competicao/Robo_Competicao.pde b/arduino/all the sketchs of my life/Robo_Competicao/Robo_Competicao.pde new file mode 100644 index 0000000..0a8e9bc --- /dev/null +++ b/arduino/all the sketchs of my life/Robo_Competicao/Robo_Competicao.pde @@ -0,0 +1,128 @@ +#include +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define DISTANCIA 1 + +int sentido; +Servo servoV; +Servo servoH; +int contador=0; +int direcaoServo=0; +long distancia; +long distanciaEsquerda; +long distanciaDireita; + +void setup() { + servoH.attach(11); + servoV.attach(10); + Serial.begin(9600); + + +} +void loop() { + /*andarFrente(2500,4); + parar(); + andarTraz(2500,4); + parar(); + girarNoEixo(2000,4,1);*/ + Serial.println(analogRead(1)); + delay(10); +} + +void lerPing() { + distancia = analogRead(1); +} +void lerPingFull() { + servoH.write(30); + delay(400); + distanciaEsquerda = analogRead(1); + servoH.write(100); + delay(400); + distancia = analogRead(1); + servoH.write(150); + delay(400); + distanciaDireita = analogRead(1); + servoH.write(90); +} + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarTraz(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarFrente(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + diff --git a/arduino/all the sketchs of my life/Robotica/Android_Servo/Android_Servo.pde b/arduino/all the sketchs of my life/Robotica/Android_Servo/Android_Servo.pde new file mode 100644 index 0000000..68c9087 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Android_Servo/Android_Servo.pde @@ -0,0 +1,127 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int SensorTemperatura = 1 ; +int LDR = 5; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo servoV; +Servo servoH; +int modo = 1; +int sentido; + + +void setup() { + Serial.begin(115200); + servoH.attach(10); + servoV.attach(11); + + meetAndroid.registerFunction(acelera, 'C'); + + /* set up the LCD's number of rows and columns: + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Aguardando");*/ + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + pinMode(LED_RED, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + //testeLeds(); + servoH.write(10); + delay(1000); + servoH.write(170); + delay(1000); + servoH.write(90); + delay(1000); + servoV.write(10); + delay(1000); + servoV.write(170); + delay(1000); + servoV.write(90); + delay(1000); + +} + +void loop() { + meetAndroid.receive(); + //meetAndroid.send(analogRead(1)); + //testeLeds(); +} +void leds(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + + if(comando[0]=='R') { + pinMode(LED_RED,INPUT); + int ligado = digitalRead(LED_RED); + pinMode(LED_RED,OUTPUT); + digitalWrite(LED_RED,!ligado); + + } + else if(comando[0]=='G') { + pinMode(LED_GREEN,INPUT); + int ligado = digitalRead(LED_GREEN); + pinMode(LED_GREEN,OUTPUT); + digitalWrite(LED_GREEN,!ligado); + } + else if(comando[0]=='B') { + pinMode(LED_BLUE,INPUT); + int ligado = digitalRead(LED_BLUE); + pinMode(LED_BLUE,OUTPUT); + digitalWrite(LED_BLUE,!ligado); + } + +} +void testeLeds() { + digitalWrite(LED_RED, HIGH); + delay(200); + digitalWrite(LED_RED, LOW); + delay(200); + digitalWrite(LED_BLUE, HIGH); + delay(200); + digitalWrite(LED_BLUE, LOW); + delay(200); + digitalWrite(LED_GREEN, HIGH); + delay(200); + digitalWrite(LED_GREEN, LOW); + delay(200); +} + +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + delay(5); +} + + + + diff --git a/arduino/all the sketchs of my life/Robotica/Android_Servo/AtualizarDisplay.pde b/arduino/all the sketchs of my life/Robotica/Android_Servo/AtualizarDisplay.pde new file mode 100644 index 0000000..51b700a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Android_Servo/AtualizarDisplay.pde @@ -0,0 +1,46 @@ +/*void atualizaDisplay() { + lcd.clear(); + + //atualiza temperatura + //lcd.setCursor(col,row); + lcd.setCursor(8,1); + lcd.print(analogRead(SensorTemperatura)/2); + lcd.print("oC"); + + Serial.print("Temperatura= "); + Serial.println(analogRead(SensorTemperatura)/2); + + //atualiza luminosidade + //lcd.setCursor(col,row); + lcd.setCursor(0,1); + lcd.print(map((analogRead(LDR)), 0, 1023, 100,0)); + lcd.print(" %"); + + Serial.print("Luminosidade= "); + Serial.println(map((analogRead(LDR)), 0, 1023, 100,0)); + Serial.println(" "); + + + //lcd.setCursor(col,row); + lcd.setCursor(0,0); + lcd.print(DistanciaEsquerda); + lcd.print(" cms"); + + //atualiza distancia esquerda + Serial.print("Distancia Esquerda= "); + Serial.println(DistanciaEsquerda); + + //atualiza distancia direita + //lcd.setCursor(col,row); + lcd.setCursor(8,0); + lcd.print(DistanciaDireita); + lcd.print(" cms"); + + Serial.print("Distancia Direita= "); + Serial.println(DistanciaDireita); + + + +} +*/ + diff --git a/arduino/all the sketchs of my life/Robotica/Android_Servo/Wask.pde b/arduino/all the sketchs of my life/Robotica/Android_Servo/Wask.pde new file mode 100644 index 0000000..3a66535 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Android_Servo/Wask.pde @@ -0,0 +1,277 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 +long duration, inches, cm; +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServoOK(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} +void changeServo(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/Robotica/BR1/BR1.pde b/arduino/all the sketchs of my life/Robotica/BR1/BR1.pde new file mode 100644 index 0000000..4c0491a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR1/BR1.pde @@ -0,0 +1,63 @@ +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 + +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 5 + +#define SERVO_1 10 +#define SERVO_2 11 + +#define MODE_DEMO 3 +#define MODE_WALK 2 +#define MODE_SUNSPOT 1 +#define MODE_STOP 0 +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=3; +Servo myservo10; // create servo object to control a servo + + +void setup() { + setupEngines(); + + setupComponents(); + myservo10.attach(10); // attaches the servo on pin 10 to the servo object + Serial.begin(9600); +} +void setupComponents() { + pinMode(9, OUTPUT); +} + +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + //andarFrente(2000,5); + + +} + +void loop(){ + if(mode==MODE_DEMO) { + //Demo(); + //return; + } + else if(mode==MODE_WALK) { + //Walk(); + } +} + + + + + diff --git a/arduino/all the sketchs of my life/Robotica/BR1/Demo.pde b/arduino/all the sketchs of my life/Robotica/BR1/Demo.pde new file mode 100644 index 0000000..541d53a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR1/Demo.pde @@ -0,0 +1,194 @@ +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/Robotica/BR1/Walk.pde b/arduino/all the sketchs of my life/Robotica/BR1/Walk.pde new file mode 100644 index 0000000..519d1f3 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR1/Walk.pde @@ -0,0 +1,253 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + readPing(); + if(cm<30) { + digitalWrite(9, HIGH); + delay(50); + digitalWrite(9, LOW); + + parar(); + while(cm<30) { + if(random(0,1)) { + girarNoEixo(200,3,random(0,1)); + } + else { + andarTraz(500,3); + } + readPing(); + } + } + else if(cm>30 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + + +void readPing() +{ + /* + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm);*/ +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/Robotica/BR1_Coracao/BR1_Coracao.pde b/arduino/all the sketchs of my life/Robotica/BR1_Coracao/BR1_Coracao.pde new file mode 100644 index 0000000..4c0491a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR1_Coracao/BR1_Coracao.pde @@ -0,0 +1,63 @@ +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 + +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 5 + +#define SERVO_1 10 +#define SERVO_2 11 + +#define MODE_DEMO 3 +#define MODE_WALK 2 +#define MODE_SUNSPOT 1 +#define MODE_STOP 0 +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=3; +Servo myservo10; // create servo object to control a servo + + +void setup() { + setupEngines(); + + setupComponents(); + myservo10.attach(10); // attaches the servo on pin 10 to the servo object + Serial.begin(9600); +} +void setupComponents() { + pinMode(9, OUTPUT); +} + +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + //andarFrente(2000,5); + + +} + +void loop(){ + if(mode==MODE_DEMO) { + //Demo(); + //return; + } + else if(mode==MODE_WALK) { + //Walk(); + } +} + + + + + diff --git a/arduino/all the sketchs of my life/Robotica/BR1_Coracao/Demo.pde b/arduino/all the sketchs of my life/Robotica/BR1_Coracao/Demo.pde new file mode 100644 index 0000000..541d53a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR1_Coracao/Demo.pde @@ -0,0 +1,194 @@ +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/Robotica/BR1_Coracao/Walk.pde b/arduino/all the sketchs of my life/Robotica/BR1_Coracao/Walk.pde new file mode 100644 index 0000000..519d1f3 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR1_Coracao/Walk.pde @@ -0,0 +1,253 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + readPing(); + if(cm<30) { + digitalWrite(9, HIGH); + delay(50); + digitalWrite(9, LOW); + + parar(); + while(cm<30) { + if(random(0,1)) { + girarNoEixo(200,3,random(0,1)); + } + else { + andarTraz(500,3); + } + readPing(); + } + } + else if(cm>30 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + + +void readPing() +{ + /* + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm);*/ +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/Robotica/BR1_Garra_LCD/BR1_Garra_LCD.pde b/arduino/all the sketchs of my life/Robotica/BR1_Garra_LCD/BR1_Garra_LCD.pde new file mode 100644 index 0000000..7b380ce --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR1_Garra_LCD/BR1_Garra_LCD.pde @@ -0,0 +1,53 @@ +#include +#include +LiquidCrystal_I2C lcd(0x27,16,2); + +void setup() { + lcd.init(); + lcd.backlight(); + lcd.setCursor(0, 1); + lcd.print("Program-ME v2"); + + Serial.begin(9600); + + Wire.begin(); + delay(1000); + Wire.beginTransmission(65); + Wire.send("1+"); + Wire.endTransmission(); + Wire.beginTransmission(65); + Wire.send("2-"); + Wire.endTransmission(); + + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1."); + Wire.endTransmission(); + Wire.beginTransmission(65); + Wire.send("2."); + Wire.endTransmission(); + + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1-"); + Wire.endTransmission(); + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1."); + Wire.endTransmission(); + delay(2000); + +} + +void loop() { + /*if(Serial.available()>0) Wire.beginTransmission(65); + while(Serial.available()>0) Wire.send(Serial.read()); + Wire.endTransmission(); */ + +} + + + diff --git a/arduino/all the sketchs of my life/Robotica/BR2/BR2.pde b/arduino/all the sketchs of my life/Robotica/BR2/BR2.pde new file mode 100644 index 0000000..0f4b0a6 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2/BR2.pde @@ -0,0 +1,27 @@ +boolean DEBUG_LIGADO = true; + +#define IDLE 1 +#define SEGUIR_LINHA 2 +#define DEMONSTRACAO 3 +#define CAMPEONATO 4 + +int modo=DEMONSTRACAO; + +void setup(){ + Serial.begin(115200); + setupMotor(); + setupGarra(); + setupInit(); + +} + +void loop(){ + if(modo==IDLE) modoZero(); + if(modo==SEGUIR_LINHA) seguirLinha(); + if(modo==CAMPEONATO) campeonato(); + if(modo==DEMONSTRACAO) demo1(); +} + + + + diff --git a/arduino/all the sketchs of my life/Robotica/BR2/Campeonato.pde b/arduino/all the sketchs of my life/Robotica/BR2/Campeonato.pde new file mode 100644 index 0000000..f6cc304 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2/Campeonato.pde @@ -0,0 +1,3 @@ +void campeonato() { +} + diff --git a/arduino/all the sketchs of my life/Robotica/BR2/Demo1.pde b/arduino/all the sketchs of my life/Robotica/BR2/Demo1.pde new file mode 100644 index 0000000..db1fa0b --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2/Demo1.pde @@ -0,0 +1,6 @@ +void demo1() { + Serial.println(lerSensor(1)); + delay(500); +} + + diff --git a/arduino/all the sketchs of my life/Robotica/BR2/Garra.pde b/arduino/all the sketchs of my life/Robotica/BR2/Garra.pde new file mode 100644 index 0000000..d89e0d0 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2/Garra.pde @@ -0,0 +1,5 @@ +#include + +void setupGarra() { +} + diff --git a/arduino/all the sketchs of my life/Robotica/BR2/Motores.pde b/arduino/all the sketchs of my life/Robotica/BR2/Motores.pde new file mode 100644 index 0000000..74c970b --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2/Motores.pde @@ -0,0 +1,95 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + + +int sentido=0; +void setupMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/Robotica/BR2/SeguidorLinha.pde b/arduino/all the sketchs of my life/Robotica/BR2/SeguidorLinha.pde new file mode 100644 index 0000000..fc49972 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2/SeguidorLinha.pde @@ -0,0 +1,136 @@ +#include +#include + +#define NUM_SENSORS 5 // number of sensors used +#define TIMEOUT 2500 // waits for 2500 us for sensor outputs to go low +#define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2 +unsigned int last_proportional = 0; +long integral = 0; +boolean calibrado = false; + +// sensores 1 a 5 estao conectados nas portas digitais 5, 9, 2, 3 e 4, respectivamente +PololuQTRSensorsRC qtrrc((unsigned char[]) {5, 9, 2, 3, 4}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); +unsigned int sensorValues[NUM_SENSORS]; + + +void calibrarSensorDeLinha() { + int i; + // Auto-calibration: turn right and left while calibrating the sensors. + for (i = 0; i < 155; i++) { // make the calibration take about 10 seconds + if (i < 40 || i > 110) + setSpeeds(60, -60); + else + setSpeeds(-60, 60); + qtrrc.calibrate(); // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call) + } + setSpeeds(0, 0); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMinimumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMaximumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + //Serial.println(); + calibrado=true; +} + +void seguirLinha() { + if(!calibrado) calibrarSensorDeLinha(); + if(modo!=SEGUIR_LINHA) return; + unsigned int position = qtrrc.readLine(sensorValues); // Get the position of the line. + int proportional = (int)position - 2000;// The "proportional" term should be 0 when we are on the line. + int derivative = proportional - last_proportional; // Compute the derivative (change) of the position. + integral += proportional; // Compute the integral (sum) of the position. + last_proportional = proportional; // Remember the last position. + + // Compute the difference between the two motor power settings, + // m1 - m2. If this is a positive number the robot will turn + // to the right. If it is a negative number, the robot will + // turn to the left, and the magnitude of the number determines + // the sharpness of the turn. You can adjust the constants by which + // the proportional, integral, and derivative terms are multiplied to + // improve performance. + int power_difference = proportional/20 + integral/10000 + derivative*3/2; + + // Compute the actual motor settings. We never set either motor + // to a negative value. + const int maximum = 70; + if (power_difference > maximum) + power_difference = maximum; + if (power_difference < -maximum) + power_difference = -maximum; + // Serial.print("power diference: "); + // Serial.println(power_difference); + //setSpeeds(70,70); + if (power_difference < 0){ + setSpeeds(maximum + power_difference, maximum); + // Serial.print("motores: "); + // Serial.println(maximum + power_difference); + // Serial.print(" : "); + // Serial.println(maximum); + } + else{ + setSpeeds(maximum, maximum - power_difference); + // Serial.print("motores: "); + // Serial.print(maximum); + // Serial.print(" : "); + // Serial.println(maximum - power_difference); + // Serial.println(" "); + } + if(DEBUG_LIGADO) { + Serial.print("position: "); + Serial.println(position); + delay(10); + Serial.println("sensor values: "); + for(int x=0;x 0){ + digitalWrite(MOTOR1_control_A,HIGH); + digitalWrite(MOTOR1_control_B,LOW); + } + else { + digitalWrite(MOTOR1_control_A,LOW); + digitalWrite(MOTOR1_control_B,HIGH); + } + if (M2 > 0){ + digitalWrite(MOTOR2_control_A,HIGH); + digitalWrite(MOTOR2_control_B,LOW); + } + else { + digitalWrite(MOTOR2_control_A,LOW); + digitalWrite(MOTOR2_control_B,HIGH); + } + analogWrite(MOTOR1_PWM,abs(M1) ); + analogWrite(MOTOR2_PWM,abs(M2) ); +} + + + + + diff --git a/arduino/all the sketchs of my life/Robotica/BR2/SensorDistancia.pde b/arduino/all the sketchs of my life/Robotica/BR2/SensorDistancia.pde new file mode 100644 index 0000000..f9ea32d --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2/SensorDistancia.pde @@ -0,0 +1,17 @@ +int lerSensor(int numeroSensor) { + int val = analogRead(numeroSensor); + float volts = (5.0/1024.0) * val; + Serial.print("Valor puro: "); + Serial.println(val); + Serial.print("Volts: "); + Serial.println(volts); + + if(volts>1.3 && volts<1.5) return 10; + if(volts>1.5 && volts<1.65) return 5; + if(volts>1.65 && volts<2.05) return 3; + if(volts>2.05) return 0; +} + + + + diff --git a/arduino/all the sketchs of my life/Robotica/BR2/xlib.pde b/arduino/all the sketchs of my life/Robotica/BR2/xlib.pde new file mode 100644 index 0000000..13955b2 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2/xlib.pde @@ -0,0 +1,29 @@ + +long lastDebounce=0; +long debounceDelay=50; + +void setupInit() { + //attachInterrupt(0, mudarModo, LOW); +} + +void mudarModo() { + if(millis()-lastDebounce>debounceDelay) { + modoReset(); + modo = modo>5? 1 : modo + 1; + lastDebounce=millis(); + } +} +void modoReset() { + parar(); +} + +void modoZero() { + piscaLed13(1000); +} + +void piscaLed13(long tempo) { + digitalWrite(13, HIGH); + delay(tempo); + digitalWrite(13, LOW); + delay(tempo); +} diff --git a/arduino/all the sketchs of my life/Robotica/BR2_Dante1/BR2_Dante1.pde b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/BR2_Dante1.pde new file mode 100644 index 0000000..8ef7726 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/BR2_Dante1.pde @@ -0,0 +1,28 @@ +boolean DEBUG_LIGADO = true; + +#define IDLE 1 +#define SEGUIR_LINHA 2 +#define DEMONSTRACAO 3 +#define CAMPEONATO 4 + +int modo=IDLE; + +void setup(){ + Serial.begin(115200); + setupMotor(); + setupGarra(); + setupInit(); + +} + +void loop(){ + andarFrente( + /*if(modo==IDLE) modoZero(); + if(modo==SEGUIR_LINHA) seguirLinha(); + if(modo==CAMPEONATO) campeonato(); + if(modo==DEMONSTRACAO) demo1();*/ +} + + + + diff --git a/arduino/all the sketchs of my life/Robotica/BR2_Dante1/Campeonato.pde b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/Campeonato.pde new file mode 100644 index 0000000..f56c146 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/Campeonato.pde @@ -0,0 +1,4 @@ +void campeonato() { + +} + diff --git a/arduino/all the sketchs of my life/Robotica/BR2_Dante1/Demo1.pde b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/Demo1.pde new file mode 100644 index 0000000..f2f3a60 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/Demo1.pde @@ -0,0 +1,4 @@ +void demo1() { + Serial.println(lerSensor(1)); + delay(500); +} diff --git a/arduino/all the sketchs of my life/Robotica/BR2_Dante1/Garra.pde b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/Garra.pde new file mode 100644 index 0000000..d89e0d0 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/Garra.pde @@ -0,0 +1,5 @@ +#include + +void setupGarra() { +} + diff --git a/arduino/all the sketchs of my life/Robotica/BR2_Dante1/Motores.pde b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/Motores.pde new file mode 100644 index 0000000..d91aaca --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/Motores.pde @@ -0,0 +1,94 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + +int sentido=0; +void setupMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTras(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/Robotica/BR2_Dante1/SeguidorLinha.pde b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/SeguidorLinha.pde new file mode 100644 index 0000000..fc49972 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/SeguidorLinha.pde @@ -0,0 +1,136 @@ +#include +#include + +#define NUM_SENSORS 5 // number of sensors used +#define TIMEOUT 2500 // waits for 2500 us for sensor outputs to go low +#define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2 +unsigned int last_proportional = 0; +long integral = 0; +boolean calibrado = false; + +// sensores 1 a 5 estao conectados nas portas digitais 5, 9, 2, 3 e 4, respectivamente +PololuQTRSensorsRC qtrrc((unsigned char[]) {5, 9, 2, 3, 4}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); +unsigned int sensorValues[NUM_SENSORS]; + + +void calibrarSensorDeLinha() { + int i; + // Auto-calibration: turn right and left while calibrating the sensors. + for (i = 0; i < 155; i++) { // make the calibration take about 10 seconds + if (i < 40 || i > 110) + setSpeeds(60, -60); + else + setSpeeds(-60, 60); + qtrrc.calibrate(); // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call) + } + setSpeeds(0, 0); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMinimumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMaximumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + //Serial.println(); + calibrado=true; +} + +void seguirLinha() { + if(!calibrado) calibrarSensorDeLinha(); + if(modo!=SEGUIR_LINHA) return; + unsigned int position = qtrrc.readLine(sensorValues); // Get the position of the line. + int proportional = (int)position - 2000;// The "proportional" term should be 0 when we are on the line. + int derivative = proportional - last_proportional; // Compute the derivative (change) of the position. + integral += proportional; // Compute the integral (sum) of the position. + last_proportional = proportional; // Remember the last position. + + // Compute the difference between the two motor power settings, + // m1 - m2. If this is a positive number the robot will turn + // to the right. If it is a negative number, the robot will + // turn to the left, and the magnitude of the number determines + // the sharpness of the turn. You can adjust the constants by which + // the proportional, integral, and derivative terms are multiplied to + // improve performance. + int power_difference = proportional/20 + integral/10000 + derivative*3/2; + + // Compute the actual motor settings. We never set either motor + // to a negative value. + const int maximum = 70; + if (power_difference > maximum) + power_difference = maximum; + if (power_difference < -maximum) + power_difference = -maximum; + // Serial.print("power diference: "); + // Serial.println(power_difference); + //setSpeeds(70,70); + if (power_difference < 0){ + setSpeeds(maximum + power_difference, maximum); + // Serial.print("motores: "); + // Serial.println(maximum + power_difference); + // Serial.print(" : "); + // Serial.println(maximum); + } + else{ + setSpeeds(maximum, maximum - power_difference); + // Serial.print("motores: "); + // Serial.print(maximum); + // Serial.print(" : "); + // Serial.println(maximum - power_difference); + // Serial.println(" "); + } + if(DEBUG_LIGADO) { + Serial.print("position: "); + Serial.println(position); + delay(10); + Serial.println("sensor values: "); + for(int x=0;x 0){ + digitalWrite(MOTOR1_control_A,HIGH); + digitalWrite(MOTOR1_control_B,LOW); + } + else { + digitalWrite(MOTOR1_control_A,LOW); + digitalWrite(MOTOR1_control_B,HIGH); + } + if (M2 > 0){ + digitalWrite(MOTOR2_control_A,HIGH); + digitalWrite(MOTOR2_control_B,LOW); + } + else { + digitalWrite(MOTOR2_control_A,LOW); + digitalWrite(MOTOR2_control_B,HIGH); + } + analogWrite(MOTOR1_PWM,abs(M1) ); + analogWrite(MOTOR2_PWM,abs(M2) ); +} + + + + + diff --git a/arduino/all the sketchs of my life/Robotica/BR2_Dante1/SensorDistancia.pde b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/SensorDistancia.pde new file mode 100644 index 0000000..f9ea32d --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/SensorDistancia.pde @@ -0,0 +1,17 @@ +int lerSensor(int numeroSensor) { + int val = analogRead(numeroSensor); + float volts = (5.0/1024.0) * val; + Serial.print("Valor puro: "); + Serial.println(val); + Serial.print("Volts: "); + Serial.println(volts); + + if(volts>1.3 && volts<1.5) return 10; + if(volts>1.5 && volts<1.65) return 5; + if(volts>1.65 && volts<2.05) return 3; + if(volts>2.05) return 0; +} + + + + diff --git a/arduino/all the sketchs of my life/Robotica/BR2_Dante1/xlib.pde b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/xlib.pde new file mode 100644 index 0000000..ad153d8 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2_Dante1/xlib.pde @@ -0,0 +1,29 @@ + +long lastDebounce=0; +long debounceDelay=50; + +void setupInit() { + attachInterrupt(0, mudarModo, LOW); +} + +void mudarModo() { + if(millis()-lastDebounce>debounceDelay) { + modoReset(); + modo = modo>5? 1 : modo + 1; + lastDebounce=millis(); + } +} +void modoReset() { + parar(); +} + +void modoZero() { + piscaLed13(1000); +} + +void piscaLed13(long tempo) { + digitalWrite(13, HIGH); + delay(tempo); + digitalWrite(13, LOW); + delay(tempo); +} diff --git a/arduino/all the sketchs of my life/Robotica/BR2_Dante_V0/BR2_Dante_V0.pde b/arduino/all the sketchs of my life/Robotica/BR2_Dante_V0/BR2_Dante_V0.pde new file mode 100644 index 0000000..ee97b8b --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2_Dante_V0/BR2_Dante_V0.pde @@ -0,0 +1,101 @@ +#include +#include +#include + +SensorLinha sensorLinha((unsigned char[]){14, 15, 3, 4, 5}, 5); + +Motores motores; //default para motores Program-ME + +void setup(){ + Serial.begin(115200); + + Kernel.setup(INTERRUPTION); + Kernel.registerChangeModeListener(pararMotores); + + Kernel.registerMode(0, "Idle"); + Kernel.registerTask(0, padrao); + + Kernel.registerMode(1, "Testar Motores",testarMotores); + Kernel.registerTask(1, padrao); + + Kernel.registerMode(2, "Testar Seguidor",testarSeguidor); + Kernel.registerTask(2, padrao); + +} + +void loop(){ + Kernel.loop(); +} + +void testarSeguidor() { + //calibrar uma so vez + sensorLinha.calibrarSensores(); + //ler os sensores + sensorLinha.lerSensores(); + + Serial.print(sensorLinha.sensor[0]); + Serial.print(" "); + Serial.print(sensorLinha.sensor[1]); + Serial.print(" "); + Serial.print(sensorLinha.sensor[2]); + Serial.print(" "); + Serial.print(sensorLinha.sensor[3]); + Serial.print(" "); + Serial.print(sensorLinha.sensor[4]); + Serial.print(" "); + +} + +void pararMotores() { + motores.parar(); +} +void padrao() { + Serial.println("modo padrao"); + delay(500); +} +void padrao_setup() { +} +void testarMotores() { + Serial.println("iniciando teste motores"); + motores.andarParaTras(200); + delay(1000); + //Kernel.wait(2000); + //if(Kernel.abortMode()) return; + motores.andarParaFrente(200); + delay(1000); + + //Kernel.wait(2000); + //if(Kernel.abortMode()) return; + motores.girarSentidoHorario(200); + //Kernel.wait(2000); + //if(Kernel.abortMode()) return; + delay(1000); + + motores.girarSentidoAntiHorario(200); + //Kernel.wait(2000); + delay(1000); + + motores.parar(); + //motores.ajustarVelocidade(50,100); + +} +void imprimirSensores() { + sensorLinha.lerSensores(); + imprimirSensorLinha(); + Kernel.wait(250); + +} +int lerSensor(int numeroSensor) { + int val = analogRead(numeroSensor); + float volts = (5.0/1024.0) * val; + Serial.print("Valor puro: "); + Serial.println(val); + Serial.print("Volts: "); + Serial.println(volts); + + if(volts>1.3 && volts<1.5) return 10; + if(volts>1.5 && volts<1.65) return 5; + if(volts>1.65 && volts<2.05) return 3; + if(volts>2.05) return 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/BR2_Dante_V0/Pilha.pde b/arduino/all the sketchs of my life/Robotica/BR2_Dante_V0/Pilha.pde new file mode 100644 index 0000000..e69de29 diff --git a/arduino/all the sketchs of my life/Robotica/BR2_Dante_V0/SeguidorLinha.pde b/arduino/all the sketchs of my life/Robotica/BR2_Dante_V0/SeguidorLinha.pde new file mode 100644 index 0000000..58526c7 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2_Dante_V0/SeguidorLinha.pde @@ -0,0 +1,44 @@ +void calibrarSensorDeLinha() { + sensorLinha.calibrarSensores(); + sensorLinha.lerSensores(); + imprimirSensorLinha(); +} + + + +void imprimirSensorLinha() { + /*lcd.imprimir(" ",0,1); + lcd.imprimir(sensorLinha.sensor[0],0,1); + lcd.imprimir(sensorLinha.sensor[1],6,1); + lcd.imprimir(sensorLinha.sensor[2],11,1); */ +} + +void seguirLinha() { + sensorLinha.lerSensores(); + imprimirSensorLinha(); + /*sensorLinha.imprimirPID();*/ + motores.andarParaFrente(40); + + if(sensorLinha.sensor[0]!=0) { + motores.ajustarVelocidade(20,40); + } + else if(sensorLinha.sensor[1]!=1000 ) { + } + else if(sensorLinha.sensor[2]!=0) { + motores.ajustarVelocidade(40,20); + } + +} + +int caso() { + if(sensorLinha.sensor[1]==1000 && sensorLinha.sensor[0]==0 && sensorLinha.sensor[2]==0) return 1; + else if(sensorLinha.sensor[1]==0 && sensorLinha.sensor[0]==0 && sensorLinha.sensor[2]==0) return 2; + else if(sensorLinha.sensor[1]==1000 && sensorLinha.sensor[0]==1000 && sensorLinha.sensor[2]==1000) return 3; + else if(sensorLinha.sensor[1]==0 && sensorLinha.sensor[0]==0 && sensorLinha.sensor[2]==1000) return 4; + else if(sensorLinha.sensor[1]==0 && sensorLinha.sensor[0]==1000 && sensorLinha.sensor[2]==1000) return 5; +} + +void seguirLinha_setup(){ + //lcd.imprimir("Modo Seguir Linha"); +} + diff --git a/arduino/all the sketchs of my life/Robotica/BR2_V1_0_Beta/BR2_V1_0_Beta.pde b/arduino/all the sketchs of my life/Robotica/BR2_V1_0_Beta/BR2_V1_0_Beta.pde new file mode 100644 index 0000000..f399e64 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2_V1_0_Beta/BR2_V1_0_Beta.pde @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include + +Motores motores; //default para motores Program-ME +SensorLinha sensorLinha((unsigned char[]){3, 4, 5}, 3); +LCD lcd; + +void setup(){ + Serial.begin(115200); + lcd.iniciar(); + + Kernel.setup(); + + Kernel.registerChangeModeListener(pararMotores); + + Kernel.registerMode(0, "Idle", padrao_setup); + Kernel.registerTask(0, padrao); + + Kernel.registerMode(1, "Calibrate Sensor"); + Kernel.registerTask(calibrarSensorDeLinha); + + Kernel.registerMode("Print Sensor"); + + Kernel.registerTask(imprimirSensorDeLinha); + +} + +void imprimirSensores() { + lcd.imprimir(caso()); + sensorLinha.lerSensores(); + imprimirSensorLinha(); + Kernel.wait(250); + +} +void loop(){ + Kernel.loop(); +} +void pararMotores() { + motores.parar(); +} +void padrao() { +} +void padrao_setup() { + lcd.imprimir("Modo Padrao - IDLE"); +} +void testeMotor() { + lcd.imprimir("Modo Teste Motor"); + lcd.imprimir("Para Tras",1,0); + motores.andarParaTras(100); + Kernel.wait(2000); + if(Kernel.abortMode()) return; + lcd.imprimir("Para Frente",1,0); + motores.andarParaFrente(100); + Kernel.wait(2000); + if(Kernel.abortMode()) return; + lcd.imprimir("Girando horario",1,0); + motores.girarSentidoHorario(100); + Kernel.wait(2000); + if(Kernel.abortMode()) return; + lcd.imprimir("Girando antihorario",1,0); + motores.girarSentidoAntiHorario(100); + Kernel.wait(2000); + motores.parar(); +} + diff --git a/arduino/all the sketchs of my life/Robotica/BR2_V1_0_Beta/SeguidorLinha.pde b/arduino/all the sketchs of my life/Robotica/BR2_V1_0_Beta/SeguidorLinha.pde new file mode 100644 index 0000000..7e8b1d8 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/BR2_V1_0_Beta/SeguidorLinha.pde @@ -0,0 +1,46 @@ +void calibrarSensorDeLinha() { + lcd.imprimir("Calibrando..."); + sensorLinha.calibrarSensores(); + lcd.imprimir("Calibrado OK"); + sensorLinha.lerSensores(); + imprimirSensorLinha(); +} + + + +void imprimirSensorLinha() { + lcd.imprimir(" ",0,1); + lcd.imprimir(sensorLinha.sensor[0],0,1); + lcd.imprimir(sensorLinha.sensor[1],6,1); + lcd.imprimir(sensorLinha.sensor[2],11,1); +} + +void seguirLinha() { + sensorLinha.lerSensores(); + imprimirSensorLinha(); + /*sensorLinha.imprimirPID();*/ + motores.andarParaFrente(40); + + if(sensorLinha.sensor[0]!=0) { + motores.ajustarVelocidade(20,40); + } + else if(sensorLinha.sensor[1]!=1000 ) { + } + else if(sensorLinha.sensor[2]!=0) { + motores.ajustarVelocidade(40,20); + } + +} + +int caso() { + if(sensorLinha.sensor[1]==1000 && sensorLinha.sensor[0]==0 && sensorLinha.sensor[2]==0) return 1; + else if(sensorLinha.sensor[1]==0 && sensorLinha.sensor[0]==0 && sensorLinha.sensor[2]==0) return 2; + else if(sensorLinha.sensor[1]==1000 && sensorLinha.sensor[0]==1000 && sensorLinha.sensor[2]==1000) return 3; + else if(sensorLinha.sensor[1]==0 && sensorLinha.sensor[0]==0 && sensorLinha.sensor[2]==1000) return 4; + else if(sensorLinha.sensor[1]==0 && sensorLinha.sensor[0]==1000 && sensorLinha.sensor[2]==1000) return 5; +} + +void seguirLinha_setup(){ + lcd.imprimir("Modo Seguir Linha"); +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/Lab_Capitulo_3_Item_1_Micro_Chave.pde b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/Lab_Capitulo_3_Item_1_Micro_Chave.pde new file mode 100644 index 0000000..be9dc48 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/Lab_Capitulo_3_Item_1_Micro_Chave.pde @@ -0,0 +1,127 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +//Incluir na solucao +#include + +int pino_leitura = P6; +int limpa = CHAVE; +int pino_escrita = P14; +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int contador = -1; +int ja_leu = 0; +// Instancia um objeto Debounce com tempo de debounce de 20 milisegundos +Debounce leitura_micro_chave = Debounce( 20 , pino_leitura); + + +void setup () { + int i; + pinMode(pino_leitura, INPUT); // configura o pino como entrada + pinMode(limpa, INPUT); + digitalWrite(pino_leitura, HIGH); // ativa o resistor () interno de pullup + + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + //pinMode(pino_escrita, OUTPUT); +} + +void bipa(){ +} + +void loop () { + int i; + int leitura; + + //problema + leitura = digitalRead(pino_leitura); + + //solucao + leitura_micro_chave.update ( ); + leitura = leitura_micro_chave.read (); + + + if (leitura == LOW && ja_leu == 0) { + contador++; + contador = contador%num_pins; + if (contador >= 0 ){ + digitalWrite(led[contador], HIGH); + } + ja_leu = 1; + } else { + if (leitura == HIGH){ + ja_leu = 0; + } + } + + if (digitalRead(limpa) == LOW){ + contador = -1; + for (i = 0; i < num_pins; i++){ + digitalWrite(led[i], LOW); + } + } + +} + + + + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Debounce/Debounce.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Debounce/Debounce.cpp.o new file mode 100644 index 0000000..9889c84 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Debounce/Debounce.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp new file mode 100644 index 0000000..70dde1c --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp @@ -0,0 +1,144 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +//Incluir na solucao +#include + +#include "WProgram.h" +void setup (); +void bipa(); +void loop (); +int pino_leitura = P6; +int limpa = CHAVE; +int pino_escrita = P14; +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int contador = -1; +int ja_leu = 0; +// Instancia um objeto Debounce com tempo de debounce de 20 milisegundos +Debounce leitura_micro_chave = Debounce( 20 , pino_leitura); + + +void setup () { + int i; + pinMode(pino_leitura, INPUT); // configura o pino como entrada + pinMode(limpa, INPUT); + digitalWrite(pino_leitura, HIGH); // ativa o resistor () interno de pullup + + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + //pinMode(pino_escrita, OUTPUT); +} + +void bipa(){ +} + +void loop () { + int i; + int leitura; + + //problema + leitura = digitalRead(pino_leitura); + + //solucao + leitura_micro_chave.update ( ); + leitura = leitura_micro_chave.read (); + + + if (leitura == LOW && ja_leu == 0) { + contador++; + contador = contador%num_pins; + if (contador >= 0 ){ + digitalWrite(led[contador], HIGH); + } + ja_leu = 1; + } else { + if (leitura == HIGH){ + ja_leu = 0; + } + } + + if (digitalRead(limpa) == LOW){ + contador = -1; + for (i = 0; i < num_pins; i++){ + digitalWrite(led[i], LOW); + } + } + +} + + + + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.eep b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.elf b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.elf new file mode 100644 index 0000000..dd45060 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.elf differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.hex b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.hex new file mode 100644 index 0000000..296ef3e --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.hex @@ -0,0 +1,99 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C947E010C948A000C948A000C948A0013 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000DA0011241FBECFEFD8E0DEBFCDBFA5 +:1000D00011E0A0E0B1E0E2EFF5E002C005900D9282 +:1000E000A831B107D9F711E0A8E1B1E001C01D9234 +:1000F000AF32B107E1F710E0C4ECD0E004C02297C2 +:10010000FE010E94F302C23CD107C9F70E947701A9 +:100110000C94F7020C940000FC01808590E0089597 +:100120001F93CF93DF93EC0189850E947B02182FE8 +:1001300088858117E9F00E94C601288139814A81AA +:100140005B81621B730B840B950B2C813D814E816F +:100150005F81621773078407950750F00E94C601FC +:10016000688379838A839B83188721E030E002C00B +:1001700020E030E0C901DF91CF911F910895FF92F7 +:100180000F931F938C01F22EFC01448355836683E9 +:1001900077830E94C601F801608371838283938311 +:1001A0008F2D0E947B02F8018087F1861F910F91AD +:1001B000FF9008958CE191E044E150E060E070E050 +:1001C000209100010E94BF0008950F931F93CF93C9 +:1001D000DF93809100010E947B028CE191E00E94FC +:1001E00090008CE191E00E948C009C01009739F511 +:1001F00080911A0190911B01892B09F580911601BC +:1002000090911701609114017091150101960E945F +:10021000CA02FC01909317018093160197FD08C054 +:10022000EE0FFF1FEE5FFE4F808161E00E942E0205 +:1002300081E090E090931B0180931A0107C0213068 +:10024000310521F410921B0110921A0180911801BE +:100250000E947B02892BD1F48FEF9FEF90931701BF +:100260008093160102E011E0C0E0D0E008C0F80180 +:10027000808160E00E942E0221960E5F1F4F8091C8 +:10028000140190911501C817D9078CF3DF91CF9114 +:100290001F910F9108950F931F93CF93DF93809138 +:1002A000000160E00E940E028091180160E00E944F +:1002B0000E028091000161E00E942E0202E011E036 +:1002C000C0E0D0E008C0F801808161E00E940E0229 +:1002D00021960E5F1F4F8091140190911501C81750 +:1002E000D9078CF3DF91CF911F910F9108950E9450 +:1002F000D4010E944B010E94E500FDCF1F920F9296 +:100300000FB60F9211242F933F938F939F93AF9328 +:10031000BF9380912A0190912B01A0912C01B09163 +:100320002D0130912E010196A11DB11D232F2D5FAE +:100330002D3720F02D570196A11DB11D20932E01C0 +:1003400080932A0190932B01A0932C01B0932D014F +:100350008091260190912701A0912801B091290157 +:100360000196A11DB11D8093260190932701A093B2 +:100370002801B0932901BF91AF919F918F913F9137 +:100380002F910F900FBE0F901F9018958FB7F89474 +:1003900020912A0130912B0140912C0150912D0187 +:1003A0008FBFB901CA010895789484B5826084BD75 +:1003B00084B5816084BD85B5826085BD85B5816069 +:1003C00085BDEEE6F0E0808181608083E1E8F0E0C9 +:1003D000808182608083808181608083E0E8F0E0BA +:1003E000808181608083E1EBF0E0808184608083A4 +:1003F000E0EBF0E0808181608083EAE7F0E08081DB +:10040000846080838081826080838081816080833A +:100410008081806880831092C1000895282F30E089 +:10042000C90186569F4FFC0194912A573F4FF9010D +:100430008491882391F0E82FF0E0EE0FFF1FE85938 +:10044000FF4FA591B491662329F48C91909589234F +:100450008C9308958C91892B8C930895482F50E0AC +:10046000CA0182559F4FFC012491CA0186569F4FB5 +:10047000FC0194914A575F4FFA0134913323D1F133 +:10048000222331F1233021F4809180008F7705C041 +:10049000243031F4809180008F7D8093800018C0DB +:1004A000213019F484B58F7704C0223021F484B54B +:1004B0008F7D84BD0DC0263021F48091B0008F77F0 +:1004C00005C0273029F48091B0008F7D8093B00063 +:1004D000E32FF0E0EE0FFF1FEE58FF4FA591B49110 +:1004E000662329F48C91909589238C9308958C919F +:1004F000892B8C930895682F70E0CB0182559F4F14 +:10050000FC012491CB0186569F4FFC0144916A5710 +:100510007F4FFB019491992319F420E030E038C01B +:10052000222331F1233021F4809180008F7705C0A0 +:10053000243031F4809180008F7D8093800018C03A +:10054000213019F484B58F7704C0223021F484B5AA +:100550008F7D84BD0DC0263021F48091B0008F774F +:1005600005C0273029F48091B0008F7D8093B000C2 +:10057000892F90E0880F991F84589F4FFC01A59107 +:10058000B4918C9120E030E0842311F021E030E040 +:10059000C901089597FB092E07260AD077FD04D0DC +:1005A0000CD006D000201AF4709561957F4F089505 +:1005B000F6F7909581959F4F0895AA1BBB1B51E1BB +:1005C00007C0AA1FBB1FA617B70710F0A61BB70BC3 +:1005D000881F991F5A95A9F780959095BC01CD0168 +:1005E0000895EE0FFF1F0590F491E02D0994F89403 +:0205F000FFCF3B +:1005F20006000E00010002000300040005000800CE +:0806020007000D000900FFFFD5 +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.o new file mode 100644 index 0000000..91e9f6d Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Lab_Capitulo_3_Item_1_Micro_Chave.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Print.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/core.a b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/core.a new file mode 100644 index 0000000..1034ae1 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_1_Micro_Chave/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/Lab_Capitulo_3_Item_2_LDR.pde b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/Lab_Capitulo_3_Item_2_LDR.pde new file mode 100644 index 0000000..a362e7d --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/Lab_Capitulo_3_Item_2_LDR.pde @@ -0,0 +1,88 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = LED_9; + +void setup() { + int i; + pinMode(LDR, INPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura = 0; + + leitura = analogRead(LDR); // Le o valor analogico da entrada com o divisor resistivo LDR + + digitalWrite(LED, HIGH); // Liga o LED 1 + delay(leitura); // Espera o total de tempo da leitura analogica x 1ms + + digitalWrite(LED, LOW); // Desliga o LED + delay(leitura); // Espera o total de tempo da leitura analogica x 1ms + Serial.print("Valor do LDR: "); + Serial.println(leitura); +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp new file mode 100644 index 0000000..10f3555 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp @@ -0,0 +1,104 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +#include "WProgram.h" +void setup(); +void loop(); +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = LED_9; + +void setup() { + int i; + pinMode(LDR, INPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura = 0; + + leitura = analogRead(LDR); // Le o valor analogico da entrada com o divisor resistivo LDR + + digitalWrite(LED, HIGH); // Liga o LED 1 + delay(leitura); // Espera o total de tempo da leitura analogica x 1ms + + digitalWrite(LED, LOW); // Desliga o LED + delay(leitura); // Espera o total de tempo da leitura analogica x 1ms + Serial.print("Valor do LDR: "); + Serial.println(leitura); +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.eep b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.elf b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.elf new file mode 100644 index 0000000..38bf49e Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.elf differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.hex b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.hex new file mode 100644 index 0000000..e31fd8b --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.hex @@ -0,0 +1,176 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C94F1000C948A000C9428020C948A0001 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000710311241FBECFEFD8E0DEBFCDBF0B +:1000D00011E0A0E0B1E0E6EBFAE002C005900D927D +:1000E000A033B107D9F711E0A0E3B1E001C01D9240 +:1000F000A03DB107E1F710E0C4ECD0E004C02297C6 +:10010000FE010E945505C23CD107C9F70E94EA00D2 +:100110000C9459050C940000CF92DF92EF92FF925D +:100120000F931F9385E00E949D018C018091230114 +:1001300061E00E94DB016801EE24D7FCE094FE2C14 +:10014000C701B6010E9439018091230160E00E943D +:10015000DB01C701B6010E9439018DEBE82E81E079 +:10016000F82EC70160E071E00E94E203C701B80108 +:100170000E94C0041F910F91FF90EF90DF90CF90ED +:1001800008950F931F93CF93DF9385E060E00E9463 +:10019000BB010FE011E0C0E0D0E008C0F8018081B1 +:1001A00061E00E94BB0121960E5F1F4F80912101EB +:1001B00090912201C817D9078CF38DEB91E040E8AC +:1001C00055E260E070E00E946502DF91CF911F91DF +:1001D0000F9108950E9463010E94C1000E948C004B +:1001E000FDCF1F920F920FB60F9211242F933F93C2 +:1001F0008F939F93AF93BF9380913401909135017A +:10020000A0913601B0913701309138010196A11DBE +:10021000B11D232F2D5F2D3720F02D570196A11DE5 +:10022000B11D209338018093340190933501A09340 +:100230003601B09337018091300190913101A09146 +:100240003201B09133010196A11DB11D809330019F +:1002500090933101A0933201B0933301BF91AF91DC +:100260009F918F913F912F910F900FBE0F901F90F4 +:100270001895EF92FF920F931F937B018C018FB71C +:10028000F89440913401509135016091360170919C +:1002900037018FBF2FB7F8948091340190913501C9 +:1002A000A0913601B09137012FBF841B950BA60B8F +:1002B000B70BE816F9060A071B0760F71F910F91A5 +:1002C000FF90EF900895789484B5826084BD84B5E2 +:1002D000816084BD85B5826085BD85B5816085BD41 +:1002E000EEE6F0E0808181608083E1E8F0E08081EB +:1002F00082608083808181608083E0E8F0E080819B +:1003000081608083E1EBF0E0808184608083E0EBBA +:10031000F0E0808181608083EAE7F0E080818460A2 +:1003200080838081826080838081816080838081FE +:10033000806880831092C10008958F70909125018C +:100340009295990F990F907C982B90937C008091B7 +:100350007A00806480937A0080917A0086FDFCCFD9 +:100360002091780040917900942F80E030E0282B94 +:10037000392BC9010895282F30E0C90186569F4FB7 +:10038000FC0194912A573F4FF9018491882391F001 +:10039000E82FF0E0EE0FFF1FE859FF4FA591B49151 +:1003A000662329F48C91909589238C9308958C91E0 +:1003B000892B8C930895482F50E0CA0182559F4F96 +:1003C000FC012491CA0186569F4FFC0194914A5723 +:1003D0005F4FFA0134913323D1F1222331F12330DD +:1003E00021F4809180008F7705C0243031F4809112 +:1003F00080008F7D8093800018C0213019F484B56F +:100400008F7704C0223021F484B58F7D84BD0DC068 +:10041000263021F48091B0008F7705C0273029F471 +:100420008091B0008F7D8093B000E32FF0E0EE0F5D +:10043000FF1FEE58FF4FA591B491662329F48C91CC +:10044000909589238C9308958C91892B8C93089592 +:100450001F920F920FB60F9211242F933F934F9339 +:100460005F936F937F938F939F93AF93BF93EF931C +:10047000FF934091C600E091B901F091BA01CF011C +:10048000019660E870E00E94EF049C018091BB013E +:100490009091BC012817390739F0E75CFE4F408383 +:1004A0003093BA012093B901FF91EF91BF91AF91C1 +:1004B0009F918F917F916F915F914F913F912F917C +:1004C0000F900FBE0F901F9018955F926F927F92C2 +:1004D0008F929F92AF92BF92CF92DF92EF92FF9254 +:1004E0000F931F93CF93DF93EC013A014B014134FB +:1004F00082E458078FE0680780E078070CF07FC03F +:1005000060E874E88EE190E0A40193010E94240564 +:100510002150304040405040CA01B90122E030E053 +:1005200040E050E00E94240559016A01A6019501AE +:10053000209530954095509594E0220F331F441F2D +:10054000551F9A95D1F760E074E284EF90E00E9425 +:100550002405CA01B9012FEF30E040E050E00E94CD +:10056000D004A40193010E942405C90181509F4F2A +:10057000181619061CF4522E5A9403C0552453948D +:10058000521A60E079E08DE390E0A40193010E94AB +:1005900024052150304040405040CA01B90122E0BA +:1005A00030E040E050E00E942405209530954095D1 +:1005B000509583E0220F331F441F551F8A95D1F7B2 +:1005C00060E074E284EF90E00E942405CA01B90162 +:1005D0002FEF30E040E050E00E94D004A4019301EE +:1005E0000E942405C90181509F4F181619061CF45A +:1005F000822F815002C081E0821B851500F5E885BD +:10060000F98581E090E00A8802C0880F991F0A945A +:10061000E2F7808360E079E08DE390E0A40193014C +:100620000E9424052150304040405040CA01B90189 +:1006300022E030E040E050E00E94240504C0E8855C +:10064000F98510829501EC81FD813083EE81FF8177 +:100650002083EA85FB85208141E050E0CA010E84B9 +:1006600002C0880F991F0A94E2F7282B2083EA859D +:10067000FB852081CA010F8402C0880F991F0A944C +:10068000E2F7282B2083EA85FB858081088802C059 +:10069000440F551F0A94E2F7842B8083DF91CF919A +:1006A0001F910F91FF90EF90DF90CF90BF90AF9090 +:1006B0009F908F907F906F905F900895FC01A08530 +:1006C000B18521898C9190E0022E02C09595879585 +:1006D0000A94E2F780FFF6CF0484F585E02D60836D +:1006E00008958AE291E09093BE018093BD0189E371 +:1006F00091E09093C0018093BF0185EC90E09093CE +:10070000C2018093C10184EC90E09093C401809376 +:10071000C30180EC90E09093C6018093C50181EC09 +:1007200090E09093C8018093C70186EC90E090938D +:10073000CA018093C90184E08093CB0183E0809358 +:10074000CC0187E08093CD0185E08093CE0181E0EC +:100750008093CF0108950F931F93CF93DF938C0164 +:10076000EB0109C02196D801ED91FC910190F08137 +:10077000E02DC801099568816623A1F7DF91CF912B +:100780001F910F910895EF92FF920F931F93CF93B4 +:10079000DF938C017B01EA010CC0D7016D917D01D3 +:1007A000D801ED91FC910190F081E02DC8010995EF +:1007B0002197209791F7DF91CF911F910F91FF9093 +:1007C000EF900895DC01ED91FC910280F381E02D22 +:1007D000099508950F931F938C01DC01ED91FC9115 +:1007E0000190F081E02D6DE00995D801ED91FC912B +:1007F0000190F081E02DC8016AE009951F910F91E9 +:1008000008952F923F924F925F926F927F928F92B4 +:100810009F92AF92BF92CF92DF92EF92FF920F938F +:100820001F93DF93CF93CDB7DEB7A0970FB6F894A1 +:10083000DEBF0FBECDBF1C016A017B014115510512 +:100840006105710549F4DC01ED91FC910190F081A5 +:10085000E02D60E3099554C0882499245401422E68 +:1008600055246624772401E010E00C0F1D1F080DAD +:10087000191DC701B601A30192010E940205F801EA +:1008800060830894811C911CA11CB11CC701B60196 +:10089000A30192010E940205C901DA016C017D01E8 +:1008A000C114D104E104F104F1F681E0E82EF12C49 +:1008B000EC0EFD1EE80CF91C3E010894611C711C35 +:1008C000D501C4010197A109B1096C01C818D90863 +:1008D00014C0F601EE0DFF1D60816A3010F4605DFA +:1008E00001C0695CD101ED91FC910190F081E02D96 +:1008F000C10109950894E108F1086E147F0449F7D5 +:10090000A0960FB6F894DEBF0FBECDBFCF91DF919A +:100910001F910F91FF90EF90DF90CF90BF90AF901D +:100920009F908F907F906F905F904F903F902F900F +:100930000895EF92FF920F931F93CF93DF93EC01F3 +:100940007A018B0177FF0FC0E881F9810190F08176 +:10095000E02D6DE2099510950095F094E094E11C6E +:10096000F11C011D111DCE01B801A7012AE00E9452 +:100970000104DF91CF911F910F91FF90EF900895A7 +:100980000F931F938C01AB01662757FD6095762F5F +:100990000E949904C8010E94EA031F910F910895D3 +:1009A000629FD001739FF001829FE00DF11D649F53 +:1009B000E00DF11D929FF00D839FF00D749FF00DDF +:1009C000659FF00D9927729FB00DE11DF91F639F80 +:1009D000B00DE11DF91FBD01CF011124089597FB52 +:1009E000092E07260AD077FD04D049D006D0002072 +:1009F0001AF4709561957F4F0895F6F7909581955B +:100A00009F4F0895A1E21A2EAA1BBB1BFD010DC02A +:100A1000AA1FBB1FEE1FFF1FA217B307E407F507AE +:100A200020F0A21BB30BE40BF50B661F771F881F8A +:100A3000991F1A9469F760957095809590959B0120 +:100A4000AC01BD01CF01089597FB092E05260ED0FC +:100A500057FD04D0D7DF0AD0001C38F450954095DC +:100A6000309521953F4F4F4F5F4F0895F6F7909582 +:100A70008095709561957F4F8F4F9F4F0895AA1B6A +:100A8000BB1B51E107C0AA1FBB1FA617B70710F079 +:100A9000A61BB70B881F991F5A95A9F780959095AB +:100AA000BC01CD010895EE0FFF1F0590F491E02DDC +:060AB0000994F894FFCF49 +:100AB60056616C6F7220646F204C44523A20000ECF +:100AC6000001000200030004000500080007000DF5 +:100AD6000009000D0001000000005E03AB03C30324 +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.o new file mode 100644 index 0000000..9ca45d6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Lab_Capitulo_3_Item_2_LDR.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Print.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/core.a b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/core.a new file mode 100644 index 0000000..d97a584 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_2_LDR/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/Lab_Capitulo_3_Item_3_FotoDiodo.pde b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/Lab_Capitulo_3_Item_3_FotoDiodo.pde new file mode 100644 index 0000000..09d0367 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/Lab_Capitulo_3_Item_3_FotoDiodo.pde @@ -0,0 +1,93 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = AP4; + +void setup() { + int i; + pinMode(A3, INPUT); + pinMode(LED, OUTPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura_analogica = 0; + int leitura_digital = 0; + + Serial.println(""); + digitalWrite(LED, LOW); // Desliga o LED + delay (100); + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led apagado: "); + Serial.println(leitura_analogica); + digitalWrite(LED, HIGH); // Liga o LED 1 + delay(100); // Espera + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led aceso: "); + Serial.println(leitura_analogica); + delay (2000); +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp new file mode 100644 index 0000000..2ef516d --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp @@ -0,0 +1,109 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +#include "WProgram.h" +void setup(); +void loop(); +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = AP4; + +void setup() { + int i; + pinMode(A3, INPUT); + pinMode(LED, OUTPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura_analogica = 0; + int leitura_digital = 0; + + Serial.println(""); + digitalWrite(LED, LOW); // Desliga o LED + delay (100); + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led apagado: "); + Serial.println(leitura_analogica); + digitalWrite(LED, HIGH); // Liga o LED 1 + delay(100); // Espera + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led aceso: "); + Serial.println(leitura_analogica); + delay (2000); +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.eep b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.elf b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.elf new file mode 100644 index 0000000..0c7b91a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.elf differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.hex b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.hex new file mode 100644 index 0000000..bd2ecd0 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.hex @@ -0,0 +1,186 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C9407010C948A000C943E020C948A00D4 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000870311241FBECFEFD8E0DEBFCDBFF5 +:1000D00011E0A0E0B1E0E8EFFAE002C005900D9277 +:1000E000A438B107D9F712E0A4E8B1E001C01D922D +:1000F000A432B107E1F710E0C4ECD0E004C02297CD +:10010000FE010E947605C23CD107C9F70E9400019A +:100110000C947A050C940000EF92FF920F931F93BA +:1001200001E112E0C80160E071E00E9417048091D3 +:10013000770160E00E94F10164E670E080E090E009 +:100140000E944F0183E00E94B3017C01C80161E07D +:1001500071E00E94F803C801B7010E94E104809198 +:10016000770161E00E94F10164E670E080E090E0D8 +:100170000E944F0183E00E94B3017C01C80163E348 +:1001800071E00E94F803C801B7010E94E10460ED2C +:1001900077E080E090E00E944F011F910F91FF9067 +:1001A000EF9008950F931F93CF93DF9383E060E068 +:1001B0000E94D1018091770161E00E94D10103E6A4 +:1001C00011E0C0E0D0E008C0F801808161E00E9449 +:1001D000D10121960E5F1F4F80917501909176019C +:1001E000C817D9078CF381E192E040E855E260E05E +:1001F00070E00E947B02DF91CF911F910F910895D3 +:100200000E9479010E94D2000E948C00FDCF1F92B3 +:100210000F920FB60F9211242F933F938F939F93BA +:10022000AF93BF938091880190918901A0918A0139 +:10023000B0918B0130918C010196A11DB11D232F2E +:100240002D5F2D3720F02D570196A11DB11D209354 +:100250008C018093880190938901A0938A01B093C7 +:100260008B018091840190918501A0918601B091CC +:1002700087010196A11DB11D809384019093850192 +:10028000A0938601B0938701BF91AF919F918F9109 +:100290003F912F910F900FBE0F901F901895EF92E6 +:1002A000FF920F931F937B018C018FB7F8944091BD +:1002B00088015091890160918A0170918B018FBFF3 +:1002C0002FB7F8948091880190918901A0918A01BB +:1002D000B0918B012FBF841B950BA60BB70BE816B3 +:1002E000F9060A071B0760F71F910F91FF90EF9027 +:1002F0000895789484B5826084BD84B5816084BD9E +:1003000085B5826085BD85B5816085BDEEE6F0E08E +:10031000808181608083E1E8F0E080818260808379 +:10032000808181608083E0E8F0E08081816080836B +:10033000E1EBF0E0808184608083E0EBF0E080819D +:1003400081608083EAE7F0E080818460808380813F +:1003500082608083808181608083808180688083E7 +:100360001092C10008958F70909179019295990F24 +:10037000990F907C982B90937C0080917A008064F8 +:1003800080937A0080917A0086FDFCCF20917800DE +:1003900040917900942F80E030E0282B392BC9015F +:1003A0000895282F30E0C90186569F4FFC01949193 +:1003B0002A573F4FF9018491882391F0E82FF0E00C +:1003C000EE0FFF1FE859FF4FA591B491662329F462 +:1003D0008C91909589238C9308958C91892B8C9383 +:1003E0000895482F50E0CA0182559F4FFC01249187 +:1003F000CA0186569F4FFC0194914A575F4FFA01FC +:1004000034913323D1F1222331F1233021F480912F +:1004100080008F7705C0243031F4809180008F7D7B +:100420008093800018C0213019F484B58F7704C000 +:10043000223021F484B58F7D84BD0DC0263021F497 +:100440008091B0008F7705C0273029F48091B000EB +:100450008F7D8093B000E32FF0E0EE0FFF1FEE588A +:10046000FF4FA591B491662329F48C91909589232F +:100470008C9308958C91892B8C9308951F920F92E1 +:100480000FB60F9211242F933F934F935F936F9367 +:100490007F938F939F93AF93BF93EF93FF9340917D +:1004A000C600E0910D02F0910E02CF01019660E8C6 +:1004B00070E00E9410059C0180910F029091100243 +:1004C0002817390739F0E357FE4F408330930E0267 +:1004D00020930D02FF91EF91BF91AF919F918F916A +:1004E0007F916F915F914F913F912F910F900FBE30 +:1004F0000F901F9018955F926F927F928F929F92AC +:10050000AF92BF92CF92DF92EF92FF920F931F9321 +:10051000CF93DF93EC013A014B01413482E4580759 +:100520008FE0680780E078070CF07FC060E874E82F +:100530008EE190E0A40193010E94450521503040D6 +:1005400040405040CA01B90122E030E040E050E0B4 +:100550000E94450559016A01A60195012095309533 +:100560004095509594E0220F331F441F551F9A95D4 +:10057000D1F760E074E284EF90E00E944505CA0183 +:10058000B9012FEF30E040E050E00E94F104A401F7 +:1005900093010E944505C90181509F4F1816190605 +:1005A0001CF4522E5A9403C055245394521A60E0FE +:1005B00079E08DE390E0A40193010E94450521506C +:1005C000304040405040CA01B90122E030E040E0F4 +:1005D00050E00E944505209530954095509583E068 +:1005E000220F331F441F551F8A95D1F760E074E234 +:1005F00084EF90E00E944505CA01B9012FEF30E079 +:1006000040E050E00E94F104A40193010E944505DE +:10061000C90181509F4F181619061CF4822F815072 +:1006200002C081E0821B851500F5E885F98581E02F +:1006300090E00A8802C0880F991F0A94E2F780832D +:1006400060E079E08DE390E0A40193010E9445050C +:100650002150304040405040CA01B90122E030E012 +:1006600040E050E00E94450504C0E885F98510820D +:100670009501EC81FD813083EE81FF812083EA8545 +:10068000FB85208141E050E0CA010E8402C0880F42 +:10069000991F0A94E2F7282B2083EA85FB852081A5 +:1006A000CA010F8402C0880F991F0A94E2F7282B11 +:1006B0002083EA85FB858081088802C0440F551F8E +:1006C0000A94E2F7842B8083DF91CF911F910F91E1 +:1006D000FF90EF90DF90CF90BF90AF909F908F9062 +:1006E0007F906F905F900895FC01A085B18521896E +:1006F0008C9190E0022E02C0959587950A94E2F7BE +:1007000080FFF6CF0484F585E02D608308958EE7A1 +:1007100091E090931202809311028DE891E0909302 +:1007200014028093130285EC90E09093160280935C +:10073000150284EC90E0909318028093170280ECED +:1007400090E090931A028093190281EC90E09093CC +:100750001C0280931B0286EC90E090931E02809313 +:100760001D0284E080931F0283E08093200287E0D3 +:100770008093210285E08093220281E0809323020E +:1007800008950F931F93CF93DF938C01EB0109C062 +:100790002196D801ED91FC910190F081E02DC801E6 +:1007A000099568816623A1F7DF91CF911F910F9181 +:1007B0000895EF92FF920F931F93CF93DF938C01D5 +:1007C0007B01EA010CC0D7016D917D01D801ED914B +:1007D000FC910190F081E02DC801099521972097A7 +:1007E00091F7DF91CF911F910F91FF90EF900895B6 +:1007F000DC01ED91FC910280F381E02D09950895D3 +:100800000F931F938C01DC01ED91FC910190F0811D +:10081000E02D6DE00995D801ED91FC910190F081FA +:10082000E02DC8016AE009951F910F9108950F937B +:100830001F938C010E94F803C8010E9400041F91BD +:100840000F9108952F923F924F925F926F927F92F5 +:100850008F929F92AF92BF92CF92DF92EF92FF92D0 +:100860000F931F93DF93CF93CDB7DEB7A0970FB64B +:10087000F894DEBF0FBECDBF1C016A017B0141159C +:1008800051056105710549F4DC01ED91FC91019080 +:10089000F081E02D60E3099554C088249924540127 +:1008A000422E55246624772401E010E00C0F1D1F12 +:1008B000080D191DC701B601A30192010E9423056D +:1008C000F80160830894811C911CA11CB11CC70114 +:1008D000B601A30192010E942305C901DA016C014E +:1008E0007D01C114D104E104F104F1F681E0E82EA8 +:1008F000F12CEC0EFD1EE80CF91C3E010894611C65 +:10090000711CD501C4010197A109B1096C01C81876 +:10091000D90814C0F601EE0DFF1D60816A3010F495 +:10092000605D01C0695CD101ED91FC910190F081A5 +:10093000E02DC10109950894E108F1086E147F04C7 +:1009400049F7A0960FB6F894DEBF0FBECDBFCF918A +:10095000DF911F910F91FF90EF90DF90CF90BF90AC +:10096000AF909F908F907F906F905F904F903F904F +:100970002F900895EF92FF920F931F93CF93DF93E1 +:10098000EC017A018B0177FF0FC0E881F9810190BA +:10099000F081E02D6DE2099510950095F094E094BA +:1009A000E11CF11C011D111DCE01B801A7012AE0B7 +:1009B0000E942204DF91CF911F910F91FF90EF9041 +:1009C00008950F931F938C01AB01662757FD609527 +:1009D000762F0E94BA04C8010E9400041F910F9153 +:1009E0000895629FD001739FF001829FE00DF11D79 +:1009F000649FE00DF11D929FF00D839FF00D749F99 +:100A0000F00D659FF00D9927729FB00DE11DF91F44 +:100A1000639FB00DE11DF91FBD01CF0111240895A1 +:100A200097FB092E07260AD077FD04D049D006D0BF +:100A300000201AF4709561957F4F0895F6F7909510 +:100A400081959F4F0895A1E21A2EAA1BBB1BFD01A1 +:100A50000DC0AA1FBB1FEE1FFF1FA217B307E4079D +:100A6000F50720F0A21BB30BE40BF50B661F771FF5 +:100A7000881F991F1A9469F76095709580959095D5 +:100A80009B01AC01BD01CF01089597FB092E0526FE +:100A90000ED057FD04D0D7DF0AD0001C38F4509593 +:100AA0004095309521953F4F4F4F5F4F0895F6F792 +:100AB00090958095709561957F4F8F4F9F4F0895CA +:100AC000AA1BBB1B51E107C0AA1FBB1FA617B70774 +:100AD00010F0A61BB70B881F991F5A95A9F7809590 +:100AE0009095BC01CD010895EE0FFF1F0590F49184 +:080AF000E02D0994F894FFCFFA +:100AF8000056616C6F7220416E616C6F6769636F3D +:100B080020646F20466F746F5265636570746F72EE +:100B180020636F6D206C6564206170616761646F2C +:100B28003A200056616C6F7220416E616C6F676984 +:100B3800636F20646F20466F746F526563657074CD +:100B48006F7220636F6D206C656420616365736FDD +:100B58003A20000E0001000200030004000500080E +:100B68000007000D000900120001000000007403D6 +:040B7800C103D903D9 +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.o new file mode 100644 index 0000000..749c140 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Lab_Capitulo_3_Item_3_FotoDiodo.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Print.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/core.a b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/core.a new file mode 100644 index 0000000..96ebf14 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_3_FotoDiodo/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.pde b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.pde new file mode 100644 index 0000000..09d0367 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.pde @@ -0,0 +1,93 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = AP4; + +void setup() { + int i; + pinMode(A3, INPUT); + pinMode(LED, OUTPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura_analogica = 0; + int leitura_digital = 0; + + Serial.println(""); + digitalWrite(LED, LOW); // Desliga o LED + delay (100); + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led apagado: "); + Serial.println(leitura_analogica); + digitalWrite(LED, HIGH); // Liga o LED 1 + delay(100); // Espera + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led aceso: "); + Serial.println(leitura_analogica); + delay (2000); +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp new file mode 100644 index 0000000..2ef516d --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp @@ -0,0 +1,109 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +#include "WProgram.h" +void setup(); +void loop(); +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = AP4; + +void setup() { + int i; + pinMode(A3, INPUT); + pinMode(LED, OUTPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura_analogica = 0; + int leitura_digital = 0; + + Serial.println(""); + digitalWrite(LED, LOW); // Desliga o LED + delay (100); + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led apagado: "); + Serial.println(leitura_analogica); + digitalWrite(LED, HIGH); // Liga o LED 1 + delay(100); // Espera + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo Fotodiodo + Serial.print("Valor Analogico do FotoReceptor com led aceso: "); + Serial.println(leitura_analogica); + delay (2000); +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.eep b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.elf b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.elf new file mode 100644 index 0000000..e1ea89f Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.elf differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.hex b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.hex new file mode 100644 index 0000000..bd2ecd0 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.hex @@ -0,0 +1,186 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C9407010C948A000C943E020C948A00D4 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000870311241FBECFEFD8E0DEBFCDBFF5 +:1000D00011E0A0E0B1E0E8EFFAE002C005900D9277 +:1000E000A438B107D9F712E0A4E8B1E001C01D922D +:1000F000A432B107E1F710E0C4ECD0E004C02297CD +:10010000FE010E947605C23CD107C9F70E9400019A +:100110000C947A050C940000EF92FF920F931F93BA +:1001200001E112E0C80160E071E00E9417048091D3 +:10013000770160E00E94F10164E670E080E090E009 +:100140000E944F0183E00E94B3017C01C80161E07D +:1001500071E00E94F803C801B7010E94E104809198 +:10016000770161E00E94F10164E670E080E090E0D8 +:100170000E944F0183E00E94B3017C01C80163E348 +:1001800071E00E94F803C801B7010E94E10460ED2C +:1001900077E080E090E00E944F011F910F91FF9067 +:1001A000EF9008950F931F93CF93DF9383E060E068 +:1001B0000E94D1018091770161E00E94D10103E6A4 +:1001C00011E0C0E0D0E008C0F801808161E00E9449 +:1001D000D10121960E5F1F4F80917501909176019C +:1001E000C817D9078CF381E192E040E855E260E05E +:1001F00070E00E947B02DF91CF911F910F910895D3 +:100200000E9479010E94D2000E948C00FDCF1F92B3 +:100210000F920FB60F9211242F933F938F939F93BA +:10022000AF93BF938091880190918901A0918A0139 +:10023000B0918B0130918C010196A11DB11D232F2E +:100240002D5F2D3720F02D570196A11DB11D209354 +:100250008C018093880190938901A0938A01B093C7 +:100260008B018091840190918501A0918601B091CC +:1002700087010196A11DB11D809384019093850192 +:10028000A0938601B0938701BF91AF919F918F9109 +:100290003F912F910F900FBE0F901F901895EF92E6 +:1002A000FF920F931F937B018C018FB7F8944091BD +:1002B00088015091890160918A0170918B018FBFF3 +:1002C0002FB7F8948091880190918901A0918A01BB +:1002D000B0918B012FBF841B950BA60BB70BE816B3 +:1002E000F9060A071B0760F71F910F91FF90EF9027 +:1002F0000895789484B5826084BD84B5816084BD9E +:1003000085B5826085BD85B5816085BDEEE6F0E08E +:10031000808181608083E1E8F0E080818260808379 +:10032000808181608083E0E8F0E08081816080836B +:10033000E1EBF0E0808184608083E0EBF0E080819D +:1003400081608083EAE7F0E080818460808380813F +:1003500082608083808181608083808180688083E7 +:100360001092C10008958F70909179019295990F24 +:10037000990F907C982B90937C0080917A008064F8 +:1003800080937A0080917A0086FDFCCF20917800DE +:1003900040917900942F80E030E0282B392BC9015F +:1003A0000895282F30E0C90186569F4FFC01949193 +:1003B0002A573F4FF9018491882391F0E82FF0E00C +:1003C000EE0FFF1FE859FF4FA591B491662329F462 +:1003D0008C91909589238C9308958C91892B8C9383 +:1003E0000895482F50E0CA0182559F4FFC01249187 +:1003F000CA0186569F4FFC0194914A575F4FFA01FC +:1004000034913323D1F1222331F1233021F480912F +:1004100080008F7705C0243031F4809180008F7D7B +:100420008093800018C0213019F484B58F7704C000 +:10043000223021F484B58F7D84BD0DC0263021F497 +:100440008091B0008F7705C0273029F48091B000EB +:100450008F7D8093B000E32FF0E0EE0FFF1FEE588A +:10046000FF4FA591B491662329F48C91909589232F +:100470008C9308958C91892B8C9308951F920F92E1 +:100480000FB60F9211242F933F934F935F936F9367 +:100490007F938F939F93AF93BF93EF93FF9340917D +:1004A000C600E0910D02F0910E02CF01019660E8C6 +:1004B00070E00E9410059C0180910F029091100243 +:1004C0002817390739F0E357FE4F408330930E0267 +:1004D00020930D02FF91EF91BF91AF919F918F916A +:1004E0007F916F915F914F913F912F910F900FBE30 +:1004F0000F901F9018955F926F927F928F929F92AC +:10050000AF92BF92CF92DF92EF92FF920F931F9321 +:10051000CF93DF93EC013A014B01413482E4580759 +:100520008FE0680780E078070CF07FC060E874E82F +:100530008EE190E0A40193010E94450521503040D6 +:1005400040405040CA01B90122E030E040E050E0B4 +:100550000E94450559016A01A60195012095309533 +:100560004095509594E0220F331F441F551F9A95D4 +:10057000D1F760E074E284EF90E00E944505CA0183 +:10058000B9012FEF30E040E050E00E94F104A401F7 +:1005900093010E944505C90181509F4F1816190605 +:1005A0001CF4522E5A9403C055245394521A60E0FE +:1005B00079E08DE390E0A40193010E94450521506C +:1005C000304040405040CA01B90122E030E040E0F4 +:1005D00050E00E944505209530954095509583E068 +:1005E000220F331F441F551F8A95D1F760E074E234 +:1005F00084EF90E00E944505CA01B9012FEF30E079 +:1006000040E050E00E94F104A40193010E944505DE +:10061000C90181509F4F181619061CF4822F815072 +:1006200002C081E0821B851500F5E885F98581E02F +:1006300090E00A8802C0880F991F0A94E2F780832D +:1006400060E079E08DE390E0A40193010E9445050C +:100650002150304040405040CA01B90122E030E012 +:1006600040E050E00E94450504C0E885F98510820D +:100670009501EC81FD813083EE81FF812083EA8545 +:10068000FB85208141E050E0CA010E8402C0880F42 +:10069000991F0A94E2F7282B2083EA85FB852081A5 +:1006A000CA010F8402C0880F991F0A94E2F7282B11 +:1006B0002083EA85FB858081088802C0440F551F8E +:1006C0000A94E2F7842B8083DF91CF911F910F91E1 +:1006D000FF90EF90DF90CF90BF90AF909F908F9062 +:1006E0007F906F905F900895FC01A085B18521896E +:1006F0008C9190E0022E02C0959587950A94E2F7BE +:1007000080FFF6CF0484F585E02D608308958EE7A1 +:1007100091E090931202809311028DE891E0909302 +:1007200014028093130285EC90E09093160280935C +:10073000150284EC90E0909318028093170280ECED +:1007400090E090931A028093190281EC90E09093CC +:100750001C0280931B0286EC90E090931E02809313 +:100760001D0284E080931F0283E08093200287E0D3 +:100770008093210285E08093220281E0809323020E +:1007800008950F931F93CF93DF938C01EB0109C062 +:100790002196D801ED91FC910190F081E02DC801E6 +:1007A000099568816623A1F7DF91CF911F910F9181 +:1007B0000895EF92FF920F931F93CF93DF938C01D5 +:1007C0007B01EA010CC0D7016D917D01D801ED914B +:1007D000FC910190F081E02DC801099521972097A7 +:1007E00091F7DF91CF911F910F91FF90EF900895B6 +:1007F000DC01ED91FC910280F381E02D09950895D3 +:100800000F931F938C01DC01ED91FC910190F0811D +:10081000E02D6DE00995D801ED91FC910190F081FA +:10082000E02DC8016AE009951F910F9108950F937B +:100830001F938C010E94F803C8010E9400041F91BD +:100840000F9108952F923F924F925F926F927F92F5 +:100850008F929F92AF92BF92CF92DF92EF92FF92D0 +:100860000F931F93DF93CF93CDB7DEB7A0970FB64B +:10087000F894DEBF0FBECDBF1C016A017B0141159C +:1008800051056105710549F4DC01ED91FC91019080 +:10089000F081E02D60E3099554C088249924540127 +:1008A000422E55246624772401E010E00C0F1D1F12 +:1008B000080D191DC701B601A30192010E9423056D +:1008C000F80160830894811C911CA11CB11CC70114 +:1008D000B601A30192010E942305C901DA016C014E +:1008E0007D01C114D104E104F104F1F681E0E82EA8 +:1008F000F12CEC0EFD1EE80CF91C3E010894611C65 +:10090000711CD501C4010197A109B1096C01C81876 +:10091000D90814C0F601EE0DFF1D60816A3010F495 +:10092000605D01C0695CD101ED91FC910190F081A5 +:10093000E02DC10109950894E108F1086E147F04C7 +:1009400049F7A0960FB6F894DEBF0FBECDBFCF918A +:10095000DF911F910F91FF90EF90DF90CF90BF90AC +:10096000AF909F908F907F906F905F904F903F904F +:100970002F900895EF92FF920F931F93CF93DF93E1 +:10098000EC017A018B0177FF0FC0E881F9810190BA +:10099000F081E02D6DE2099510950095F094E094BA +:1009A000E11CF11C011D111DCE01B801A7012AE0B7 +:1009B0000E942204DF91CF911F910F91FF90EF9041 +:1009C00008950F931F938C01AB01662757FD609527 +:1009D000762F0E94BA04C8010E9400041F910F9153 +:1009E0000895629FD001739FF001829FE00DF11D79 +:1009F000649FE00DF11D929FF00D839FF00D749F99 +:100A0000F00D659FF00D9927729FB00DE11DF91F44 +:100A1000639FB00DE11DF91FBD01CF0111240895A1 +:100A200097FB092E07260AD077FD04D049D006D0BF +:100A300000201AF4709561957F4F0895F6F7909510 +:100A400081959F4F0895A1E21A2EAA1BBB1BFD01A1 +:100A50000DC0AA1FBB1FEE1FFF1FA217B307E4079D +:100A6000F50720F0A21BB30BE40BF50B661F771FF5 +:100A7000881F991F1A9469F76095709580959095D5 +:100A80009B01AC01BD01CF01089597FB092E0526FE +:100A90000ED057FD04D0D7DF0AD0001C38F4509593 +:100AA0004095309521953F4F4F4F5F4F0895F6F792 +:100AB00090958095709561957F4F8F4F9F4F0895CA +:100AC000AA1BBB1B51E107C0AA1FBB1FA617B70774 +:100AD00010F0A61BB70B881F991F5A95A9F7809590 +:100AE0009095BC01CD010895EE0FFF1F0590F49184 +:080AF000E02D0994F894FFCFFA +:100AF8000056616C6F7220416E616C6F6769636F3D +:100B080020646F20466F746F5265636570746F72EE +:100B180020636F6D206C6564206170616761646F2C +:100B28003A200056616C6F7220416E616C6F676984 +:100B3800636F20646F20466F746F526563657074CD +:100B48006F7220636F6D206C656420616365736FDD +:100B58003A20000E0001000200030004000500080E +:100B68000007000D000900120001000000007403D6 +:040B7800C103D903D9 +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.o new file mode 100644 index 0000000..4f019e3 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Print.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/core.a b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/core.a new file mode 100644 index 0000000..9d840eb Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_4_CNY70_FotoTransistor_Proximidade/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/Lab_Capitulo_3_Item_5_Sensor_Temperatura.pde b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/Lab_Capitulo_3_Item_5_Sensor_Temperatura.pde new file mode 100644 index 0000000..db9430d --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/Lab_Capitulo_3_Item_5_Sensor_Temperatura.pde @@ -0,0 +1,87 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = AP4; + +void setup() { + int i; + pinMode(A3, INPUT); + pinMode(LED, OUTPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura_analogica = 0; + int leitura_digital = 0; + + //Serial.println(""); + //delay (200); + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo NTC + Serial.print("Valor Analogico do Sensor de Temperatura: "); + Serial.println(leitura_analogica); + delay (500); +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp new file mode 100644 index 0000000..adbe1d3 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp @@ -0,0 +1,103 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +#include "WProgram.h" +void setup(); +void loop(); +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array +int LED = AP4; + +void setup() { + int i; + pinMode(A3, INPUT); + pinMode(LED, OUTPUT); + + for (i = 0; i < num_pins; i++){ + pinMode(led[i], OUTPUT); + } + Serial.begin(9600); // Inicializa a comunicacao serial com o PC + //Serial.println("Iniciando Debug"); +} + +void loop() { + int leitura_analogica = 0; + int leitura_digital = 0; + + //Serial.println(""); + //delay (200); + leitura_analogica = analogRead(A3); // Le o valor analogico da entrada com o divisor resistivo NTC + Serial.print("Valor Analogico do Sensor de Temperatura: "); + Serial.println(leitura_analogica); + delay (500); +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.eep b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.elf b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.elf new file mode 100644 index 0000000..cc3f21a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.elf differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.hex b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.hex new file mode 100644 index 0000000..e3073af --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.hex @@ -0,0 +1,166 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C94DF000C948A000C94C9010C948A0073 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000120311241FBECFEFD8E0DEBFCDBF6A +:1000D00011E0A0E0B1E0E8EFF9E002C005900D9278 +:1000E000AC34B107D9F711E0ACE4B1E001C01D9226 +:1000F000AC3EB107E1F710E0C4ECD0E004C02297B9 +:10010000FE010E94F604C23CD107C9F70E94D80044 +:100110000C94FA040C940000EF92FF920F931F933B +:1001200083E00E948B017C0109ED11E0C80160E0D1 +:1001300071E00E948303C801B7010E94610464EF6B +:1001400071E080E090E00E9427011F910F91FF90E5 +:10015000EF9008950F931F93CF93DF9383E060E0B8 +:100160000E94A90180913F0161E00E94A9010BE278 +:1001700011E0C0E0D0E008C0F801808161E00E9499 +:10018000A90121960E5F1F4F80913D0190913E0184 +:10019000C817D9078CF389ED91E040E855E260E09B +:1001A00070E00E940602DF91CF911F910F91089598 +:1001B0000E9451010E94AA000E948C00FDCF1F9254 +:1001C0000F920FB60F9211242F933F938F939F930B +:1001D000AF93BF938091500190915101A091520132 +:1001E000B0915301309154010196A11DB11D232FEF +:1001F0002D5F2D3720F02D570196A11DB11D2093A5 +:1002000054018093500190935101A0935201B093F7 +:10021000530180914C0190914D01A0914E01B091FC +:100220004F010196A11DB11D80934C0190934D018A +:10023000A0934E01B0934F01BF91AF919F918F91C9 +:100240003F912F910F900FBE0F901F901895EF9236 +:10025000FF920F931F937B018C018FB7F89440910D +:1002600050015091510160915201709153018FBF23 +:100270002FB7F8948091500190915101A0915201B3 +:10028000B09153012FBF841B950BA60BB70BE8163B +:10029000F9060A071B0760F71F910F91FF90EF9077 +:1002A0000895789484B5826084BD84B5816084BDEE +:1002B00085B5826085BD85B5816085BDEEE6F0E0DF +:1002C000808181608083E1E8F0E0808182608083CA +:1002D000808181608083E0E8F0E0808181608083BC +:1002E000E1EBF0E0808184608083E0EBF0E08081EE +:1002F00081608083EAE7F0E0808184608083808190 +:100300008260808380818160808380818068808337 +:100310001092C10008958F70909141019295990FAC +:10032000990F907C982B90937C0080917A00806448 +:1003300080937A0080917A0086FDFCCF209178002E +:1003400040917900942F80E030E0282B392BC901AF +:100350000895282F30E0C90186569F4FFC019491E3 +:100360002A573F4FF9018491882391F0E82FF0E05C +:10037000EE0FFF1FE859FF4FA591B491662329F4B2 +:100380008C91909589238C9308958C91892B8C93D3 +:1003900008951F920F920FB60F9211242F933F933F +:1003A0004F935F936F937F938F939F93AF93BF937D +:1003B000EF93FF934091C600E091D501F091D601F3 +:1003C000CF01019660E870E00E9490049C0180914A +:1003D000D7019091D8012817390739F0EB5AFE4F11 +:1003E00040833093D6012093D501FF91EF91BF91C7 +:1003F000AF919F918F917F916F915F914F913F91BD +:100400002F910F900FBE0F901F9018955F926F92D3 +:100410007F928F929F92AF92BF92CF92DF92EF9294 +:10042000FF920F931F93CF93DF93EC013A014B019F +:10043000413482E458078FE0680780E078070CF0C9 +:100440007FC060E874E88EE190E0A40193010E940F +:10045000C5042150304040405040CA01B90122E05B +:1004600030E040E050E00E94C50459016A01A60155 +:100470009501209530954095509594E0220F331FBB +:10048000441F551F9A95D1F760E074E284EF90E025 +:100490000E94C504CA01B9012FEF30E040E050E0EE +:1004A0000E947104A40193010E94C504C9018150F6 +:1004B0009F4F181619061CF4522E5A9403C0552447 +:1004C0005394521A60E079E08DE390E0A401930127 +:1004D0000E94C5042150304040405040CA01B9013B +:1004E00022E030E040E050E00E94C50420953095C5 +:1004F0004095509583E0220F331F441F551F8A9566 +:10050000D1F760E074E284EF90E00E94C504CA0174 +:10051000B9012FEF30E040E050E00E947104A401E7 +:1005200093010E94C504C90181509F4F18161906F6 +:100530001CF4822F815002C081E0821B851500F5DA +:10054000E885F98581E090E00A8802C0880F991F4C +:100550000A94E2F7808360E079E08DE390E0A40103 +:1005600093010E94C5042150304040405040CA01D0 +:10057000B90122E030E040E050E00E94C50404C030 +:10058000E885F98510829501EC81FD813083EE814B +:10059000FF812083EA85FB85208141E050E0CA018C +:1005A0000E8402C0880F991F0A94E2F7282B20833B +:1005B000EA85FB852081CA010F8402C0880F991F3C +:1005C0000A94E2F7282B2083EA85FB85808108883E +:1005D00002C0440F551F0A94E2F7842B8083DF91F9 +:1005E000CF911F910F91FF90EF90DF90CF90BF9030 +:1005F000AF909F908F907F906F905F900895FC01D7 +:10060000A085B18521898C9190E0022E02C095953C +:1006100087950A94E2F780FFF6CF0484F585E02DF4 +:100620006083089586E491E09093DA018093D90184 +:1006300085E591E09093DC018093DB0185EC90E00F +:100640009093DE018093DD0184EC90E09093E001D3 +:100650008093DF0180EC90E09093E2018093E101D0 +:1006600081EC90E09093E4018093E30186EC90E0CC +:100670009093E6018093E50184E08093E70183E0B5 +:100680008093E80187E08093E90185E08093EA01A7 +:1006900081E08093EB0108950F931F93CF93DF9335 +:1006A0008C01EB0109C02196D801ED91FC910190DC +:1006B000F081E02DC801099568816623A1F7DF91DB +:1006C000CF911F910F910895EF92FF920F931F9377 +:1006D000CF93DF938C017B01EA010CC0D7016D91B0 +:1006E0007D01D801ED91FC910190F081E02DC801D0 +:1006F00009952197209791F7DF91CF911F910F9145 +:10070000FF90EF900895DC01ED91FC910280F38160 +:10071000E02D099508950F931F938C01DC01ED9155 +:10072000FC910190F081E02D6DE00995D801ED91EB +:10073000FC910190F081E02DC8016AE009951F91BC +:100740000F9108952F923F924F925F926F927F92F6 +:100750008F929F92AF92BF92CF92DF92EF92FF92D1 +:100760000F931F93DF93CF93CDB7DEB7A0970FB64C +:10077000F894DEBF0FBECDBF1C016A017B0141159D +:1007800051056105710549F4DC01ED91FC91019081 +:10079000F081E02D60E3099554C088249924540128 +:1007A000422E55246624772401E010E00C0F1D1F13 +:1007B000080D191DC701B601A30192010E94A304EF +:1007C000F80160830894811C911CA11CB11CC70115 +:1007D000B601A30192010E94A304C901DA016C01D0 +:1007E0007D01C114D104E104F104F1F681E0E82EA9 +:1007F000F12CEC0EFD1EE80CF91C3E010894611C66 +:10080000711CD501C4010197A109B1096C01C81877 +:10081000D90814C0F601EE0DFF1D60816A3010F496 +:10082000605D01C0695CD101ED91FC910190F081A6 +:10083000E02DC10109950894E108F1086E147F04C8 +:1008400049F7A0960FB6F894DEBF0FBECDBFCF918B +:10085000DF911F910F91FF90EF90DF90CF90BF90AD +:10086000AF909F908F907F906F905F904F903F9050 +:100870002F900895EF92FF920F931F93CF93DF93E2 +:10088000EC017A018B0177FF0FC0E881F9810190BB +:10089000F081E02D6DE2099510950095F094E094BB +:1008A000E11CF11C011D111DCE01B801A7012AE0B8 +:1008B0000E94A203DF91CF911F910F91FF90EF90C3 +:1008C00008950F931F938C01AB01662757FD609528 +:1008D000762F0E943A04C8010E948B031F910F914A +:1008E0000895629FD001739FF001829FE00DF11D7A +:1008F000649FE00DF11D929FF00D839FF00D749F9A +:10090000F00D659FF00D9927729FB00DE11DF91F45 +:10091000639FB00DE11DF91FBD01CF0111240895A2 +:1009200097FB092E07260AD077FD04D049D006D0C0 +:1009300000201AF4709561957F4F0895F6F7909511 +:1009400081959F4F0895A1E21A2EAA1BBB1BFD01A2 +:100950000DC0AA1FBB1FEE1FFF1FA217B307E4079E +:10096000F50720F0A21BB30BE40BF50B661F771FF6 +:10097000881F991F1A9469F76095709580959095D6 +:100980009B01AC01BD01CF01089597FB092E0526FF +:100990000ED057FD04D0D7DF0AD0001C38F4509594 +:1009A0004095309521953F4F4F4F5F4F0895F6F793 +:1009B00090958095709561957F4F8F4F9F4F0895CB +:1009C000AA1BBB1B51E107C0AA1FBB1FA617B70775 +:1009D00010F0A61BB70B881F991F5A95A9F7809591 +:1009E0009095BC01CD010895EE0FFF1F0590F49185 +:0809F000E02D0994F894FFCFFB +:1009F80056616C6F7220416E616C6F6769636F201E +:100A0800646F2053656E736F722064652054656D42 +:100A180070657261747572613A20000E00010002FF +:100A280000030004000500080007000D000900127B +:0C0A3800000100000000FF024C036403FA +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.o new file mode 100644 index 0000000..f8019d6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Lab_Capitulo_3_Item_5_Sensor_Temperatura.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Print.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/core.a b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/core.a new file mode 100644 index 0000000..6a817b2 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_5_Sensor_Temperatura/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/Lab_Capitulo_3_Item_6_UltraSom_Ping.pde b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/Lab_Capitulo_3_Item_6_UltraSom_Ping.pde new file mode 100644 index 0000000..9b0b60e --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/Lab_Capitulo_3_Item_6_UltraSom_Ping.pde @@ -0,0 +1,122 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + + +const int pingPin = 7; + + void setup() { + // initialize serial communication: + Serial.begin(9600); + } + + void loop() + { + // establish variables for duration of the ping, + // and the distance result in inches and centimeters: + long duration, inches, cm; + + // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. + // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: + pinMode(pingPin, OUTPUT); + digitalWrite(pingPin, LOW); + delayMicroseconds(2); + digitalWrite(pingPin, HIGH); + delayMicroseconds(5); + digitalWrite(pingPin, LOW); + + // The same pin is used to read the signal from the PING))): a HIGH + // pulse whose duration is the time (in microseconds) from the sending + // of the ping to the reception of its echo off of an object. + pinMode(pingPin, INPUT); + duration = pulseIn(pingPin, HIGH); + + // convert the time into a distance + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + + Serial.print(inches); + Serial.print("in, "); + Serial.print(cm); + Serial.print("cm"); + Serial.println(); + + delay(100); + } + + long microsecondsToInches(long microseconds) + { + // According to Parallax's datasheet for the PING))), there are + // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per + // second). This gives the distance travelled by the ping, outbound + // and return, so we divide by 2 to get the distance of the obstacle. + // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf + return microseconds / 74 / 2; + } + + long microsecondsToCentimeters(long microseconds) + { + // The speed of sound is 340 m/s or 29 microseconds per centimeter. + // The ping travels out and back, so to find the distance of the + // object we take half of the distance travelled. + return microseconds / 29 / 2; + } + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp new file mode 100644 index 0000000..50047bc --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp @@ -0,0 +1,140 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +#include "WProgram.h" +void setup(); +void loop(); +long microsecondsToInches(long microseconds); +long microsecondsToCentimeters(long microseconds); +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + + +const int pingPin = 7; + + void setup() { + // initialize serial communication: + Serial.begin(9600); + } + + void loop() + { + // establish variables for duration of the ping, + // and the distance result in inches and centimeters: + long duration, inches, cm; + + // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. + // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: + pinMode(pingPin, OUTPUT); + digitalWrite(pingPin, LOW); + delayMicroseconds(2); + digitalWrite(pingPin, HIGH); + delayMicroseconds(5); + digitalWrite(pingPin, LOW); + + // The same pin is used to read the signal from the PING))): a HIGH + // pulse whose duration is the time (in microseconds) from the sending + // of the ping to the reception of its echo off of an object. + pinMode(pingPin, INPUT); + duration = pulseIn(pingPin, HIGH); + + // convert the time into a distance + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + + Serial.print(inches); + Serial.print("in, "); + Serial.print(cm); + Serial.print("cm"); + Serial.println(); + + delay(100); + } + + long microsecondsToInches(long microseconds) + { + // According to Parallax's datasheet for the PING))), there are + // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per + // second). This gives the distance travelled by the ping, outbound + // and return, so we divide by 2 to get the distance of the obstacle. + // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf + return microseconds / 74 / 2; + } + + long microsecondsToCentimeters(long microseconds) + { + // The speed of sound is 340 m/s or 29 microseconds per centimeter. + // The ping travels out and back, so to find the distance of the + // object we take half of the distance travelled. + return microseconds / 29 / 2; + } + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.eep b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.elf b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.elf new file mode 100644 index 0000000..ecbe4a6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.elf differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.hex b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.hex new file mode 100644 index 0000000..9a58a16 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.hex @@ -0,0 +1,189 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C9400010C948A000C94A8020C948A0071 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C0000000F10311241FBECFEFD8E0DEBFCDBF8B +:1000D00011E0A0E0B1E0E6E9FBE002C005900D927E +:1000E000A231B107D9F711E0A2E1B1E001C01D9240 +:1000F000A23BB107E1F710E0C4ECD0E004C02297C6 +:10010000FE010E94C505C23CD107C9F70E94F90053 +:100110000C94C9050C940000CF92DF92EF92FF92ED +:100120000F931F9387E061E00E94BA0187E060E0CF +:100130000E94DA0182E090E00E94720187E061E0B3 +:100140000E94DA0185E090E00E94720187E060E0A1 +:100150000E94DA0187E060E00E94BA0187E061E076 +:1001600020E432E44FE050E00E942702F62EE72E12 +:10017000D82EC92E0FE911E024E930E040E050E02C +:100180000E949405C801BA01A9010E941905C8017D +:1001900060E071E00E9462046F2D7E2D8D2D9C2DFC +:1001A0002AE330E040E050E00E949405C801BA0123 +:1001B000A9010E941905C80165E071E00E9462046E +:1001C000C8010E946A0464E670E080E090E00E944A +:1001D00048011F910F91FF90EF90DF90CF9008950D +:1001E0008FE991E040E855E260E070E00E94E502AE +:1001F00008950E9480010E94F0000E948C00FDCFB3 +:100200001F920F920FB60F9211242F933F938F934B +:100210009F93AF93BF938091160190911701A09186 +:100220001801B091190130911A010196A11DB11D5B +:10023000232F2D5F2D3720F02D570196A11DB11DC5 +:1002400020931A018093160190931701A09318012F +:10025000B09319018091120190911301A0911401A2 +:10026000B09115010196A11DB11D809312019093CB +:100270001301A0931401B0931501BF91AF919F9109 +:100280008F913F912F910F900FBE0F901F90189557 +:10029000EF92FF920F931F937B018C018FB7F8941D +:1002A0004091160150911701609118017091190148 +:1002B0008FBF2FB7F8948091160190911701A091EC +:1002C0001801B09119012FBF841B950BA60BB70B1A +:1002D000E816F9060A071B0760F71F910F91FF90B8 +:1002E000EF900895019759F0FC01EE0FFF1FEE0FFC +:1002F000FF1F32978FB7F8943197F1F78FBF0895AA +:10030000789484B5826084BD84B5816084BD85B5F0 +:10031000826085BD85B5816085BDEEE6F0E08081B7 +:1003200081608083E1E8F0E0808182608083808169 +:1003300081608083E0E8F0E0808181608083E1EB90 +:10034000F0E0808184608083E0EBF0E08081816078 +:100350008083EAE7F0E0808184608083808182602E +:100360008083808181608083808180688083109217 +:10037000C1000895282F30E0C90186569F4FFC0127 +:1003800094912A573F4FF9018491882391F0E82FE7 +:10039000F0E0EE0FFF1FE859FF4FA591B4916623DF +:1003A00029F48C91909589238C9308958C91892BB5 +:1003B0008C930895482F50E0CA0182559F4FFC014D +:1003C0002491CA0186569F4FFC0194914A575F4F72 +:1003D000FA0134913323D1F1222331F1233021F476 +:1003E000809180008F7705C0243031F480918000A7 +:1003F0008F7D8093800018C0213019F484B58F77E9 +:1004000004C0223021F484B58F7D84BD0DC0263018 +:1004100021F48091B0008F7705C0273029F48091B6 +:10042000B0008F7D8093B000E32FF0E0EE0FFF1F50 +:10043000EE58FF4FA591B491662329F48C919095C5 +:1004400089238C9308958C91892B8C930895DF9246 +:10045000EF92FF920F931F93A82FB0E0CD01865625 +:100460009F4FFC01D490AA57BF4FFD018491662392 +:1004700011F490E001C09D2D6FEFE62E6FEFF62E88 +:100480006FEF062F6FE0162FE222F32204231523CD +:10049000682F70E0660F771F64587F4F20E030E0D0 +:1004A00040E050E0FB01A591B4910AC02E153F0534 +:1004B0004007510709F440C02F5F3F4F4F4F5F4F38 +:1004C0008C918D21891791F30AC02E153F054007A5 +:1004D000510791F12F5F3F4F4F4F5F4F03C0FB011B +:1004E000A591B4918C918D21891779F720E030E0A6 +:1004F00040E050E0FB01A591B49104C02F5F3F4F55 +:100500004F4F5F4F8C918D218917C1F3CA01B901FB +:100510002AE030E040E050E00E9440059B01AC0141 +:10052000205F3F4F4F4F5F4F84E05695479537957B +:1005300027958A95D1F704C020E030E040E050E0F4 +:10054000B901CA011F910F91FF90EF90DF900895BC +:100550001F920F920FB60F9211242F933F934F9338 +:100560005F936F937F938F939F93AF93BF93EF931B +:10057000FF934091C600E0919B01F0919C01CF0157 +:10058000019660E870E00E945F059C0180919D01EA +:1005900090919E012817390739F0E55EFE4F4083A0 +:1005A00030939C0120939B01FF91EF91BF91AF91FC +:1005B0009F918F917F916F915F914F913F912F917B +:1005C0000F900FBE0F901F9018955F926F927F92C1 +:1005D0008F929F92AF92BF92CF92DF92EF92FF9253 +:1005E0000F931F93CF93DF93EC013A014B014134FA +:1005F00082E458078FE0680780E078070CF07FC03E +:1006000060E874E88EE190E0A40193010E949405F3 +:100610002150304040405040CA01B90122E030E052 +:1006200040E050E00E94940559016A01A60195013D +:10063000209530954095509594E0220F331F441F2C +:10064000551F9A95D1F760E074E284EF90E00E9424 +:100650009405CA01B9012FEF30E040E050E00E945C +:100660004005A40193010E949405C90181509F4F48 +:10067000181619061CF4522E5A9403C0552453948C +:10068000521A60E079E08DE390E0A40193010E94AA +:1006900094052150304040405040CA01B90122E049 +:1006A00030E040E050E00E94940520953095409560 +:1006B000509583E0220F331F441F551F8A95D1F7B1 +:1006C00060E074E284EF90E00E949405CA01B901F1 +:1006D0002FEF30E040E050E00E944005A40193017C +:1006E0000E949405C90181509F4F181619061CF4E9 +:1006F000822F815002C081E0821B851500F5E885BC +:10070000F98581E090E00A8802C0880F991F0A9459 +:10071000E2F7808360E079E08DE390E0A40193014B +:100720000E9494052150304040405040CA01B90118 +:1007300022E030E040E050E00E94940504C0E885EB +:10074000F98510829501EC81FD813083EE81FF8176 +:100750002083EA85FB85208141E050E0CA010E84B8 +:1007600002C0880F991F0A94E2F7282B2083EA859C +:10077000FB852081CA010F8402C0880F991F0A944B +:10078000E2F7282B2083EA85FB858081088802C058 +:10079000440F551F0A94E2F7842B8083DF91CF9199 +:1007A0001F910F91FF90EF90DF90CF90BF90AF908F +:1007B0009F908F907F906F905F900895FC01A0852F +:1007C000B18521898C9190E0022E02C09595879584 +:1007D0000A94E2F780FFF6CF0484F585E02D60836C +:1007E00008958CE091E09093A00180939F018BE1AC +:1007F00091E09093A2018093A10185EC90E0909309 +:10080000A4018093A30184EC90E09093A6018093CF +:10081000A50180EC90E09093A8018093A70181EC62 +:1008200090E09093AA018093A90186EC90E09093C8 +:10083000AC018093AB0184E08093AD0183E08093B1 +:10084000AE0187E08093AF0185E08093B00181E045 +:100850008093B10108950F931F93CF93DF938C0181 +:10086000EB0109C02196D801ED91FC910190F08136 +:10087000E02DC801099568816623A1F7DF91CF912A +:100880001F910F910895EF92FF920F931F93CF93B3 +:10089000DF938C017B01EA010CC0D7016D917D01D2 +:1008A000D801ED91FC910190F081E02DC8010995EE +:1008B0002197209791F7DF91CF911F910F91FF9092 +:1008C000EF900895DC01ED91FC910280F381E02D21 +:1008D000099508950F931F938C01DC01ED91FC9114 +:1008E0000190F081E02D6DE00995D801ED91FC912A +:1008F0000190F081E02DC8016AE009951F910F91E8 +:1009000008952F923F924F925F926F927F928F92B3 +:100910009F92AF92BF92CF92DF92EF92FF920F938E +:100920001F93DF93CF93CDB7DEB7A0970FB6F894A0 +:10093000DEBF0FBECDBF1C016A017B014115510511 +:100940006105710549F4DC01ED91FC910190F081A4 +:10095000E02D60E3099554C0882499245401422E67 +:1009600055246624772401E010E00C0F1D1F080DAC +:10097000191DC701B601A30192010E947205F80179 +:1009800060830894811C911CA11CB11CC701B60195 +:10099000A30192010E947205C901DA016C017D0177 +:1009A000C114D104E104F104F1F681E0E82EF12C48 +:1009B000EC0EFD1EE80CF91C3E010894611C711C34 +:1009C000D501C4010197A109B1096C01C818D90862 +:1009D00014C0F601EE0DFF1D60816A3010F4605DF9 +:1009E00001C0695CD101ED91FC910190F081E02D95 +:1009F000C10109950894E108F1086E147F0449F7D4 +:100A0000A0960FB6F894DEBF0FBECDBFCF91DF9199 +:100A10001F910F91FF90EF90DF90CF90BF90AF901C +:100A20009F908F907F906F905F904F903F902F900E +:100A30000895EF92FF920F931F93CF93DF93EC01F2 +:100A40007A018B0177FF0FC0E881F9810190F08175 +:100A5000E02D6DE2099510950095F094E094E11C6D +:100A6000F11C011D111DCE01B801A7012AE00E9451 +:100A70008104DF91CF911F910F91FF90EF90089526 +:100A8000629FD001739FF001829FE00DF11D649F72 +:100A9000E00DF11D929FF00D839FF00D749FF00DFE +:100AA000659FF00D9927729FB00DE11DF91F639F9F +:100AB000B00DE11DF91FBD01CF011124089597FB71 +:100AC000092E07260AD077FD04D049D006D0002091 +:100AD0001AF4709561957F4F0895F6F7909581957A +:100AE0009F4F0895A1E21A2EAA1BBB1BFD010DC04A +:100AF000AA1FBB1FEE1FFF1FA217B307E407F507CE +:100B000020F0A21BB30BE40BF50B661F771F881FA9 +:100B1000991F1A9469F760957095809590959B013F +:100B2000AC01BD01CF01089597FB092E05260ED01B +:100B300057FD04D0D7DF0AD0001C38F450954095FB +:100B4000309521953F4F4F4F5F4F0895F6F79095A1 +:100B50008095709561957F4F8F4F9F4F0895AA1B89 +:100B6000BB1B51E107C0AA1FBB1FA617B70710F098 +:100B7000A61BB70B881F991F5A95A9F780959095CA +:100B8000BC01CD010895EE0FFF1F0590F491E02DFB +:060B90000994F894FFCF68 +:100B9600696E2C2000636D0000000000DE032B044C +:020BA600430406 +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.o new file mode 100644 index 0000000..1a3d3d0 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Lab_Capitulo_3_Item_6_UltraSom_Ping.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Print.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/core.a b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/core.a new file mode 100644 index 0000000..2605c28 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_6_UltraSom_Ping/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.pde b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.pde new file mode 100644 index 0000000..7901b4d --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.pde @@ -0,0 +1,127 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + + + /* + Memsic2125 + + Read the Memsic 2125 two-axis accelerometer. Converts the + pulses output by the 2125 into milli-g's (1/1000 of earth's + gravity) and prints them over the serial connection to the + computer. + + The circuit: + * X output of accelerometer to digital pin 2 + * Y output of accelerometer to digital pin 3 + * +V of accelerometer to +5V + * GND of accelerometer to ground + + http://www.arduino.cc/en/Tutorial/Memsic2125 + + created 6 Nov 2008 + by David A. Mellis + modified 30 Jun 2009 + by Tom Igoe + + */ + + // these constants won't change: + const int xPin = 2; // X output of the accelerometer + const int yPin = 3; // Y output of the accelerometer + + void setup() { + // initialize serial communications: + Serial.begin(9600); + // initialize the pins connected to the accelerometer + // as inputs: + pinMode(xPin, INPUT); + pinMode(yPin, INPUT); + } + + void loop() { + // variables to read the pulse widths: + int pulseX, pulseY; + // variables to contain the resulting accelerations + int accelerationX, accelerationY; + + // read pulse from x- and y-axes: + pulseX = pulseIn(xPin,HIGH); + pulseY = pulseIn(yPin,HIGH); + + // convert the pulse width into acceleration + // accelerationX and accelerationY are in milli-g's: + // earth's gravity is 1000 milli-g's, or 1g. + accelerationX = ((pulseX / 10) - 500) * 8; + accelerationY = ((pulseY / 10) - 500) * 8; + + // print the acceleration + Serial.print("X= "); + Serial.print(accelerationX); + // print a tab character: + Serial.print("\t"); + Serial.print("Y= "); + Serial.print(accelerationY); + Serial.println(); + + delay(100); + } + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp new file mode 100644 index 0000000..63b3051 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp @@ -0,0 +1,143 @@ + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +#include "WProgram.h" +void setup(); +void loop(); +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + + + /* + Memsic2125 + + Read the Memsic 2125 two-axis accelerometer. Converts the + pulses output by the 2125 into milli-g's (1/1000 of earth's + gravity) and prints them over the serial connection to the + computer. + + The circuit: + * X output of accelerometer to digital pin 2 + * Y output of accelerometer to digital pin 3 + * +V of accelerometer to +5V + * GND of accelerometer to ground + + http://www.arduino.cc/en/Tutorial/Memsic2125 + + created 6 Nov 2008 + by David A. Mellis + modified 30 Jun 2009 + by Tom Igoe + + */ + + // these constants won't change: + const int xPin = 2; // X output of the accelerometer + const int yPin = 3; // Y output of the accelerometer + + void setup() { + // initialize serial communications: + Serial.begin(9600); + // initialize the pins connected to the accelerometer + // as inputs: + pinMode(xPin, INPUT); + pinMode(yPin, INPUT); + } + + void loop() { + // variables to read the pulse widths: + int pulseX, pulseY; + // variables to contain the resulting accelerations + int accelerationX, accelerationY; + + // read pulse from x- and y-axes: + pulseX = pulseIn(xPin,HIGH); + pulseY = pulseIn(yPin,HIGH); + + // convert the pulse width into acceleration + // accelerationX and accelerationY are in milli-g's: + // earth's gravity is 1000 milli-g's, or 1g. + accelerationX = ((pulseX / 10) - 500) * 8; + accelerationY = ((pulseY / 10) - 500) * 8; + + // print the acceleration + Serial.print("X= "); + Serial.print(accelerationX); + // print a tab character: + Serial.print("\t"); + Serial.print("Y= "); + Serial.print(accelerationY); + Serial.println(); + + delay(100); + } + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.eep b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.elf b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.elf new file mode 100644 index 0000000..799e868 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.elf differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.hex b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.hex new file mode 100644 index 0000000..37535af --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.hex @@ -0,0 +1,179 @@ +:100000000C9462000C948A000C948A000C948A0070 +:100010000C948A000C948A000C948A000C948A0038 +:100020000C948A000C948A000C948A000C948A0028 +:100030000C948A000C948A000C948A000C948A0018 +:100040000C9405010C948A000C9452020C948A00C2 +:100050000C948A000C948A000C948A000C948A00F8 +:100060000C948A000C948A000000000024002700F1 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C00000009B0311241FBECFEFD8E0DEBFCDBFE1 +:1000D00011E0A0E0B1E0EAEFFAE002C005900D9275 +:1000E000A431B107D9F711E0A4E1B1E001C01D923C +:1000F000A43BB107E1F710E0C4ECD0E004C02297C4 +:10010000FE010E947705C23CD107C9F70E94FE009C +:100110000C947B050C9400008F929F92AF92BF923B +:10012000CF92DF92EF92FF920F931F9382E061E0F4 +:1001300020E432E44FE050E00E94D1016B017C01E9 +:1001400083E061E020E432E44FE050E00E94D1011E +:100150004B015C0101EA11E0C80160E071E00E941E +:100160000C04C6016AE070E00E941105645F7140F2 +:1001700093E0660F771F9A95E1F7C8010E94EA04A1 +:10018000C80164E071E00E940C04C80166E071E0FF +:100190000E940C04C4016AE070E00E941105645FD3 +:1001A000714083E0660F771F8A95E1F7C8010E94CE +:1001B000EA04C8010E94140464E670E080E090E064 +:1001C0000E944D011F910F91FF90EF90DF90CF9013 +:1001D000BF90AF909F908F90089581EA91E040E8A2 +:1001E00055E260E070E00E948F0282E060E00E94D1 +:1001F000B10183E060E00E94B10108950E9477019F +:100200000E94ED000E948C00FDCF1F920F920FB64E +:100210000F9211242F933F938F939F93AF93BF938C +:100220008091180190911901A0911A01B0911B01C0 +:1002300030911C010196A11DB11D232F2D5F2D377B +:1002400020F02D570196A11DB11D20931C01809314 +:10025000180190931901A0931A01B0931B0180918A +:10026000140190911501A0911601B091170101960A +:10027000A11DB11D8093140190931501A093160147 +:10028000B0931701BF91AF919F918F913F912F91A3 +:100290000F900FBE0F901F901895EF92FF920F9343 +:1002A0001F937B018C018FB7F894409118015091F6 +:1002B000190160911A0170911B018FBF2FB7F8943B +:1002C0008091180190911901A0911A01B0911B0120 +:1002D0002FBF841B950BA60BB70BE816F9060A0770 +:1002E0001B0760F71F910F91FF90EF90089578948E +:1002F00084B5826084BD84B5816084BD85B582602B +:1003000085BD85B5816085BDEEE6F0E080818160C8 +:100310008083E1E8F0E08081826080838081816079 +:100320008083E0E8F0E0808181608083E1EBF0E0B1 +:10033000808184608083E0EBF0E080818160808355 +:10034000EAE7F0E08081846080838081826080833E +:100350008081816080838081806880831092C10069 +:100360000895282F30E0C90186569F4FFC019491D3 +:100370002A573F4FF9018491882391F0E82FF0E04C +:10038000EE0FFF1FE859FF4FA591B491662329F4A2 +:100390008C91909589238C9308958C91892B8C93C3 +:1003A0000895DF92EF92FF920F931F93A82FB0E072 +:1003B000CD0186569F4FFC01D490AA57BF4FFD0137 +:1003C0008491662311F490E001C09D2D6FEFE62E1D +:1003D0006FEFF62E6FEF062F6FE0162FE222F3225B +:1003E00004231523682F70E0660F771F64587F4F32 +:1003F00020E030E040E050E0FB01A591B4910AC05C +:100400002E153F054007510709F440C02F5F3F4FAD +:100410004F4F5F4F8C918D21891791F30AC02E1594 +:100420003F054007510791F12F5F3F4F4F4F5F4FFF +:1004300003C0FB01A591B4918C918D21891779F7A7 +:1004400020E030E040E050E0FB01A591B49104C011 +:100450002F5F3F4F4F4F5F4F8C918D218917C1F315 +:10046000CA01B9012AE030E040E050E00E94F20405 +:100470009B01AC01205F3F4F4F4F5F4F84E056958B +:100480004795379527958A95D1F704C020E030E04D +:1004900040E050E0B901CA011F910F91FF90EF9029 +:1004A000DF9008951F920F920FB60F9211242F9391 +:1004B0003F934F935F936F937F938F939F93AF93EC +:1004C000BF93EF93FF934091C600E0919D01F0919F +:1004D0009E01CF01019660E870E00E9411059C0129 +:1004E00080919F019091A0012817390739F0E35EB0 +:1004F000FE4F408330939E0120939D01FF91EF9129 +:10050000BF91AF919F918F917F916F915F914F912B +:100510003F912F910F900FBE0F901F9018955F92F3 +:100520006F927F928F929F92AF92BF92CF92DF9203 +:10053000EF92FF920F931F93CF93DF93EC013A0159 +:100540004B01413482E458078FE0680780E0780768 +:100550000CF07FC060E874E88EE190E0A4019301A4 +:100560000E9446052150304040405040CA01B90128 +:1005700022E030E040E050E00E94460559016A0167 +:10058000A6019501209530954095509594E0220F55 +:10059000331F441F551F9A95D1F760E074E284EF32 +:1005A00090E00E944605CA01B9012FEF30E040E01B +:1005B00050E00E94F204A40193010E944605C90183 +:1005C00081509F4F181619061CF4522E5A9403C0DE +:1005D00055245394521A60E079E08DE390E0A40131 +:1005E00093010E9446052150304040405040CA01CE +:1005F000B90122E030E040E050E00E94460520953D +:1006000030954095509583E0220F331F441F551FAE +:100610008A95D1F760E074E284EF90E00E9446058D +:10062000CA01B9012FEF30E040E050E00E94F2042F +:10063000A40193010E944605C90181509F4F1816DD +:1006400019061CF4822F815002C081E0821B85159F +:1006500000F5E885F98581E090E00A8802C0880FFE +:10066000991F0A94E2F7808360E079E08DE390E0DF +:10067000A40193010E944605215030404040504063 +:10068000CA01B90122E030E040E050E00E94460596 +:1006900004C0E885F98510829501EC81FD813083E5 +:1006A000EE81FF812083EA85FB85208141E050E0D7 +:1006B000CA010E8402C0880F991F0A94E2F7282B02 +:1006C0002083EA85FB852081CA010F8402C0880F40 +:1006D000991F0A94E2F7282B2083EA85FB85808105 +:1006E000088802C0440F551F0A94E2F7842B8083C8 +:1006F000DF91CF911F910F91FF90EF90DF90CF90FE +:10070000BF90AF909F908F907F906F905F90089573 +:10071000FC01A085B18521898C9190E0022E02C058 +:10072000959587950A94E2F780FFF6CF0484F585C6 +:10073000E02D608308958EE091E09093A201809374 +:10074000A1018DE191E09093A4018093A30185EC38 +:1007500090E09093A6018093A50184EC90E09093A3 +:10076000A8018093A70180EC90E09093AA01809368 +:10077000A90181EC90E09093AC018093AB0186ECF1 +:1007800090E09093AE018093AD0184E08093AF013F +:1007900083E08093B00187E08093B10185E080938E +:1007A000B20181E08093B30108950F931F93CF931B +:1007B000DF938C01EB0109C02196D801ED91FC91EA +:1007C0000190F081E02DC801099568816623A1F7A9 +:1007D000DF91CF911F910F910895EF92FF920F93A8 +:1007E0001F93CF93DF938C017B01EA010CC0D701EB +:1007F0006D917D01D801ED91FC910190F081E02D8A +:10080000C80109952197209791F7DF91CF911F910A +:100810000F91FF90EF900895DC01ED91FC91028023 +:10082000F381E02D099508950F931F938C01DC014E +:10083000ED91FC910190F081E02D6DE00995D801DA +:10084000ED91FC910190F081E02DC8016AE00995DD +:100850001F910F9108952F923F924F925F926F9246 +:100860007F928F929F92AF92BF92CF92DF92EF9240 +:10087000FF920F931F93DF93CF93CDB7DEB7A0976F +:100880000FB6F894DEBF0FBECDBF1C016A017B011D +:10089000411551056105710549F4DC01ED91FC91AB +:1008A0000190F081E02D60E3099554C088249924DB +:1008B0005401422E55246624772401E010E00C0FE9 +:1008C0001D1F080D191DC701B601A30192010E9449 +:1008D0002405F80160830894811C911CA11CB11CA3 +:1008E000C701B601A30192010E942405C901DA01E2 +:1008F0006C017D01C114D104E104F104F1F681E041 +:10090000E82EF12CEC0EFD1EE80CF91C3E010894BB +:10091000611C711CD501C4010197A109B1096C01C9 +:10092000C818D90814C0F601EE0DFF1D60816A30A9 +:1009300010F4605D01C0695CD101ED91FC91019002 +:10094000F081E02DC10109950894E108F1086E14C9 +:100950007F0449F7A0960FB6F894DEBF0FBECDBF57 +:10096000CF91DF911F910F91FF90EF90DF90CF908B +:10097000BF90AF909F908F907F906F905F904F90BF +:100980003F902F900895EF92FF920F931F93CF9374 +:10099000DF93EC017A018B0177FF0FC0E881F981C9 +:1009A0000190F081E02D6DE2099510950095F0948D +:1009B000E094E11CF11C011D111DCE01B801A7013D +:1009C0002AE00E942B04DF91CF911F910F91FF909D +:1009D000EF900895AB01662757FD6095762F0E9432 +:1009E000C3040895629FD001739FF001829FE00DC0 +:1009F000F11D649FE00DF11D929FF00D839FF00D9E +:100A0000749FF00D659FF00D9927729FB00DE11D49 +:100A1000F91F639FB00DE11DF91FBD01CF01112426 +:100A2000089597FB092E07260AD077FD04D049D0F8 +:100A300006D000201AF4709561957F4F0895F6F75F +:100A4000909581959F4F0895A1E21A2EAA1BBB1B7A +:100A5000FD010DC0AA1FBB1FEE1FFF1FA217B3078A +:100A6000E407F50720F0A21BB30BE40BF50B661FA0 +:100A7000771F881F991F1A9469F760957095809564 +:100A800090959B01AC01BD01CF01089597FB092E04 +:100A900005260ED057FD04D0D7DF0AD0001C38F44D +:100AA00050954095309521953F4F4F4F5F4F08959A +:100AB000F6F790958095709561957F4F8F4F9F4F7A +:100AC0000895AA1BBB1B51E107C0AA1FBB1FA61795 +:100AD000B70710F0A61BB70B881F991F5A95A9F7E7 +:100AE00080959095BC01CD010895EE0FFF1F0590F4 +:0A0AF000F491E02D0994F894FFCF73 +:100AFA00583D20000900593D2000000000008803ED +:040B0A00D503ED031F +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.o new file mode 100644 index 0000000..207d759 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Print.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/core.a b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/core.a new file mode 100644 index 0000000..ebeaca4 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_7_Acelerometro_Memsic_2125/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/Lab_Capitulo_3_Item_8_Bussula_HM55B.pde b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/Lab_Capitulo_3_Item_8_Bussula_HM55B.pde new file mode 100644 index 0000000..17a6f51 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/Lab_Capitulo_3_Item_8_Bussula_HM55B.pde @@ -0,0 +1,194 @@ +/* #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + +*/ +/* +///////////////////////////////// +Htachi HM55B Compass +parallax (#) + +AUTHOR: kiilo kiilo@kiilo.org +License: http://creativecommons.org/licenses/by-nc-sa/2.5/ch/ + +http://parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/hm55b/List/1/ProductID/98/Default.aspx?SortField=ProductName%2cProductName +http://sage.medienkunst.ch/tiki-index.php?page=HowTo_Arduino_Parallax_HM55B_Kompass +http://arduino.cc/playground/HM55B + +///////////////////////////////// +*/ +#include // (no semicolon) +//// VARS +byte CLK_pin = 8; +byte EN_pin = 9; +byte DIO_pin = 10; + +int X_Data = 0; +int Y_Data = 0; +int angle; + +//// FUNCTIONS + +void ShiftOut(int Value, int BitsCount) { + for(int i = BitsCount; i >= 0; i--) { + digitalWrite(CLK_pin, LOW); // pino de clock vai para 0 + if ((Value & 1 << i) == ( 1 << i)) { //testa o bit a ser enviado + digitalWrite(DIO_pin, HIGH); + //Serial.print("1"); + } + else { + digitalWrite(DIO_pin, LOW); + //Serial.print("0"); + } + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + } +//Serial.print(" "); +} + +int ShiftIn(int BitsCount) { + int ShiftIn_result; + ShiftIn_result = 0; + pinMode(DIO_pin, INPUT); + for(int i = BitsCount; i >= 0; i--) { + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + if (digitalRead(DIO_pin) == HIGH) { + ShiftIn_result = (ShiftIn_result << 1) + 1; + //Serial.print("x"); + } + else { + ShiftIn_result = (ShiftIn_result << 1) + 0; + //Serial.print("_"); + } + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + } + //Serial.print(":"); + +// below is difficult to understand: +// if bit 11 is Set the value is negative +// the representation of negative values you +// have to add B11111000 in the upper Byte of +// the integer. +// see: http://en.wikipedia.org/wiki/Two%27s_complement + if ((ShiftIn_result & 1 << 11) == 1 << 11) { + ShiftIn_result = (B11111000 << 8) | ShiftIn_result; + } + + + return ShiftIn_result; +} + +void HM55B_Reset() { + pinMode(DIO_pin, OUTPUT); + digitalWrite(EN_pin, LOW); + ShiftOut(B0000, 3); + digitalWrite(EN_pin, HIGH); +} + +void HM55B_StartMeasurementCommand() { + pinMode(DIO_pin, OUTPUT); + digitalWrite(EN_pin, LOW); + ShiftOut(B1000, 3); + digitalWrite(EN_pin, HIGH); +} + +int HM55B_ReadCommand() { + int result = 0; + pinMode(DIO_pin, OUTPUT); + digitalWrite(EN_pin, LOW); + ShiftOut(B1100, 3); + result = ShiftIn(3); + return result; +} + + +void setup() { + Serial.begin(115200); + //Serial.begin(9600); + pinMode(EN_pin, OUTPUT); + pinMode(CLK_pin, OUTPUT); + pinMode(DIO_pin, INPUT); + + HM55B_Reset(); +} + +void loop() { + HM55B_StartMeasurementCommand(); // necessary!! + delay(40); // the data is 40ms later ready + Serial.print(HM55B_ReadCommand()); // read data and print Status + Serial.print(" "); + X_Data = ShiftIn(11); // Field strength in X + Y_Data = ShiftIn(11); // and Y direction + Serial.print(X_Data); // print X strength + Serial.print(" "); + Serial.print(Y_Data); // print Y strength + Serial.print(" "); + digitalWrite(EN_pin, HIGH); // ok deselect chip + angle = 180 * (atan2(-1 * Y_Data , X_Data) / M_PI); // angle is atan( -y/x) !!! + Serial.print(angle); // print angle + Serial.println(""); + +} + + + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp new file mode 100644 index 0000000..35dd736 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp @@ -0,0 +1,215 @@ +/* #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + +*/ +/* +///////////////////////////////// +Htachi HM55B Compass +parallax (#) + +AUTHOR: kiilo kiilo@kiilo.org +License: http://creativecommons.org/licenses/by-nc-sa/2.5/ch/ + +http://parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/hm55b/List/1/ProductID/98/Default.aspx?SortField=ProductName%2cProductName +http://sage.medienkunst.ch/tiki-index.php?page=HowTo_Arduino_Parallax_HM55B_Kompass +http://arduino.cc/playground/HM55B + +///////////////////////////////// +*/ +#include // (no semicolon) +//// VARS +#include "WProgram.h" +void ShiftOut(int Value, int BitsCount); +int ShiftIn(int BitsCount); +void HM55B_Reset(); +void HM55B_StartMeasurementCommand(); +int HM55B_ReadCommand(); +void setup(); +void loop(); +byte CLK_pin = 8; +byte EN_pin = 9; +byte DIO_pin = 10; + +int X_Data = 0; +int Y_Data = 0; +int angle; + +//// FUNCTIONS + +void ShiftOut(int Value, int BitsCount) { + for(int i = BitsCount; i >= 0; i--) { + digitalWrite(CLK_pin, LOW); + if ((Value & 1 << i) == ( 1 << i)) { + digitalWrite(DIO_pin, HIGH); + //Serial.print("1"); + } + else { + digitalWrite(DIO_pin, LOW); + //Serial.print("0"); + } + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + } +//Serial.print(" "); +} + +int ShiftIn(int BitsCount) { + int ShiftIn_result; + ShiftIn_result = 0; + pinMode(DIO_pin, INPUT); + for(int i = BitsCount; i >= 0; i--) { + digitalWrite(CLK_pin, HIGH); + delayMicroseconds(1); + if (digitalRead(DIO_pin) == HIGH) { + ShiftIn_result = (ShiftIn_result << 1) + 1; + //Serial.print("x"); + } + else { + ShiftIn_result = (ShiftIn_result << 1) + 0; + //Serial.print("_"); + } + digitalWrite(CLK_pin, LOW); + delayMicroseconds(1); + } + //Serial.print(":"); + +// below is difficult to understand: +// if bit 11 is Set the value is negative +// the representation of negative values you +// have to add B11111000 in the upper Byte of +// the integer. +// see: http://en.wikipedia.org/wiki/Two%27s_complement + if ((ShiftIn_result & 1 << 11) == 1 << 11) { + ShiftIn_result = (B11111000 << 8) | ShiftIn_result; + } + + + return ShiftIn_result; +} + +void HM55B_Reset() { + pinMode(DIO_pin, OUTPUT); + digitalWrite(EN_pin, LOW); + ShiftOut(B0000, 3); + digitalWrite(EN_pin, HIGH); +} + +void HM55B_StartMeasurementCommand() { + pinMode(DIO_pin, OUTPUT); + digitalWrite(EN_pin, LOW); + ShiftOut(B1000, 3); + digitalWrite(EN_pin, HIGH); +} + +int HM55B_ReadCommand() { + int result = 0; + pinMode(DIO_pin, OUTPUT); + digitalWrite(EN_pin, LOW); + ShiftOut(B1100, 3); + result = ShiftIn(3); + return result; +} + + +void setup() { + Serial.begin(115200); + //Serial.begin(9600); + pinMode(EN_pin, OUTPUT); + pinMode(CLK_pin, OUTPUT); + pinMode(DIO_pin, INPUT); + + HM55B_Reset(); +} + +void loop() { + HM55B_StartMeasurementCommand(); // necessary!! + delay(40); // the data is 40ms later ready + Serial.print(HM55B_ReadCommand()); // read data and print Status + Serial.print(" "); + X_Data = ShiftIn(11); // Field strength in X + Y_Data = ShiftIn(11); // and Y direction + Serial.print(X_Data); // print X strength + Serial.print(" "); + Serial.print(Y_Data); // print Y strength + Serial.print(" "); + digitalWrite(EN_pin, HIGH); // ok deselect chip + angle = 180 * (atan2(-1 * Y_Data , X_Data) / M_PI); // angle is atan( -y/x) !!! + Serial.print(angle); // print angle + Serial.println(""); + +} + + + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.eep b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.elf b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.elf new file mode 100644 index 0000000..4160f6e Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.elf differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.hex b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.hex new file mode 100644 index 0000000..b90414c --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.hex @@ -0,0 +1,297 @@ +:100000000C9479000C94A1000C94A1000C94A10014 +:100010000C94A1000C94A1000C94A1000C94A100DC +:100020000C94A1000C94A1000C94A1000C94A100CC +:100030000C94A1000C94A1000C94A1000C94A100BC +:100040000C9408020C94A1000C947E030C94A10063 +:100050000C94A1000C94A1000C94A1000C94A1009C +:100060000C94A1000C94A100084AD73B3BCE016E32 +:1000700084BCBFFDC12F3D6C74319ABD56833DDAFF +:100080003D00C77F11BED9E4BB4C3E916BAAAABE0E +:10009000000000803F00000000240027002A00002C +:1000A000000000250028002B00000000002300268F +:1000B00000290004040404040404040202020202ED +:1000C000020303030303030102040810204080011C +:1000D000020408102001020408102000000007009C +:1000E0000201000003040600000000000000000000 +:1000F000C70411241FBECFEFD8E0DEBFCDBF11E093 +:10010000A0E0B1E0E8E6F2E102C005900D92A03176 +:10011000B107D9F711E0A0E1B1E001C01D92A63B03 +:10012000B107E1F710E0C2EFD0E004C02297FE0172 +:100130000E942E09C03FD107C9F70E9401020C940A +:1001400032090C940000EF92FF920F931F93CF930C +:10015000DF938C01EB0181E0E82EF12C25C080912A +:10016000030160E00E94E20297010C2E02C0220F00 +:10017000331F0A94E2F7C901802391238217930762 +:1001800021F48091050161E003C08091050160E0E8 +:100190000E94E2028091030161E00E94E20281E09C +:1001A00090E00E947A022197D7FFD9CFDF91CF91BB +:1001B0001F910F91FF90EF9008958091050161E0EC +:1001C0000E94C2028091040160E00E94E20288E085 +:1001D00090E063E070E00E94A3008091040161E080 +:1001E0000E94E20208958091050161E00E94C2022E +:1001F0008091040160E00E94E20280E090E063E010 +:1002000070E00E94A3008091040161E00E94E2027C +:10021000089583EA91E040E052EC61E070E00E94D2 +:10022000BB038091040161E00E94C202809103013E +:1002300061E00E94C2028091050160E00E94C2025A +:100240000E94F30008950F931F93CF93DF93182F0D +:10025000092F8091050160E00E94C202212F302FFA +:10026000C901EC0100E010E021C08091030161E0D0 +:100270000E94E20281E090E00E947A0280910501F2 +:100280000E942F039801220F331F019721F4890147 +:100290000F5F1F4F01C089018091030160E00E9440 +:1002A000E20281E090E00E947A022197D7FFDDCF41 +:1002B00013FD186FC801DF91CF911F910F91089521 +:1002C0008091050161E00E94C2028091040160E01A +:1002D0000E94E2028CE090E063E070E00E94A300E4 +:1002E00083E090E00E9423010895CF92DF92EF9285 +:1002F000FF920F931F930E94DD0068E270E080E0A0 +:1003000090E00E9450020E946001BC0153EAC52E99 +:1003100051E0D52EC6010E94210600E011E0C60181 +:10032000B8010E9438058BE090E00E942301909371 +:100330001101809310018BE090E00E9423019093C3 +:100340001301809312016091100170911101C60197 +:100350000E942106C601B8010E9438056091120171 +:1003600070911301C6010E942106C601B8010E94C6 +:1003700038058091040161E00E94E202609112015F +:1003800070911301709561957F4F882777FD809557 +:10039000982F0E948B077B018C0160911001709156 +:1003A0001101882777FD8095982F0E948B079B016C +:1003B000AC01C801B7010E949D062BED3FE049E466 +:1003C00050E40E94F00620E030E044E353E40E9451 +:1003D00043080E9458079B01AC017093150160937C +:1003E0001401C601B9010E942106C60162E071E054 +:1003F0000E9457051F910F91FF90EF90DF90CF90D3 +:1004000008950E9488020E9409010E947501FDCF93 +:100410001F920F920FB60F9211242F933F938F9339 +:100420009F93AF93BF9380911A0190911B01A0916C +:100430001C01B0911D0130911E010196A11DB11D3D +:10044000232F2D5F2D3720F02D570196A11DB11DB3 +:1004500020931E0180931A0190931B01A0931C010D +:10046000B0931D018091160190911701A091180180 +:10047000B09119010196A11DB11D809316019093B1 +:100480001701A0931801B0931901BF91AF919F91EB +:100490008F913F912F910F900FBE0F901F90189545 +:1004A000EF92FF920F931F937B018C018FB7F8940B +:1004B00040911A0150911B0160911C0170911D0126 +:1004C0008FBF2FB7F89480911A0190911B01A091D2 +:1004D0001C01B0911D012FBF841B950BA60BB70B00 +:1004E000E816F9060A071B0760F71F910F91FF90A6 +:1004F000EF900895019759F0FC01EE0FFF1FEE0FEA +:10050000FF1F32978FB7F8943197F1F78FBF089597 +:10051000789484B5826084BD84B5816084BD85B5DE +:10052000826085BD85B5816085BDEEE6F0E08081A5 +:1005300081608083E1E8F0E0808182608083808157 +:1005400081608083E0E8F0E0808181608083E1EB7E +:10055000F0E0808184608083E0EBF0E08081816066 +:100560008083EAE7F0E0808184608083808182601C +:100570008083808181608083808180688083109205 +:10058000C1000895282F30E0C90189539F4FFC0115 +:1005900094912D543F4FF9018491882391F0E82FD5 +:1005A000F0E0EE0FFF1FEB56FF4FA591B4916623CD +:1005B00029F48C91909589238C9308958C91892BA3 +:1005C0008C930895482F50E0CA0185529F4FFC013B +:1005D0002491CA0189539F4FFC0194914D545F4F60 +:1005E000FA0134913323D1F1222331F1233021F464 +:1005F000809180008F7705C0243031F48091800095 +:100600008F7D8093800018C0213019F484B58F77D6 +:1006100004C0223021F484B58F7D84BD0DC0263006 +:1006200021F48091B0008F7705C0273029F48091A4 +:10063000B0008F7D8093B000E32FF0E0EE0FFF1F3E +:10064000E156FF4FA591B491662329F48C919095C2 +:1006500089238C9308958C91892B8C930895682F0E +:1006600070E0CB0185529F4FFC012491CB0189534F +:100670009F4FFC0144916D547F4FFB01949199234E +:1006800019F420E030E038C0222331F1233021F486 +:10069000809180008F7705C0243031F480918000F4 +:1006A0008F7D8093800018C0213019F484B58F7736 +:1006B00004C0223021F484B58F7D84BD0DC0263066 +:1006C00021F48091B0008F7705C0273029F4809104 +:1006D000B0008F7D8093B000892F90E0880F991F24 +:1006E00087559F4FFC01A591B4918C9120E030E09B +:1006F000842311F021E030E0C90108951F920F9288 +:100700000FB60F9211242F933F934F935F936F93E4 +:100710007F938F939F93AF93BF93EF93FF934091FA +:10072000C600E0919F01F091A001CF01019660E821 +:1007300070E00E94C8089C018091A1019091A201E3 +:100740002817390739F0E15EFE4F40833093A0014E +:1007500020939F01FF91EF91BF91AF919F918F9156 +:100760007F916F915F914F913F912F910F900FBEAD +:100770000F901F9018955F926F927F928F929F9229 +:10078000AF92BF92CF92DF92EF92FF920F931F939F +:10079000CF93DF93EC013A014B01413482E45807D7 +:1007A0008FE0680780E078070CF07FC060E874E8AD +:1007B0008EE190E0A40193010E94FD082150304099 +:1007C00040405040CA01B90122E030E040E050E032 +:1007D0000E94FD0859016A01A601950120953095F6 +:1007E0004095509594E0220F331F441F551F9A9552 +:1007F000D1F760E074E284EF90E00E94FD08CA0146 +:10080000B9012FEF30E040E050E00E94A908A401B8 +:1008100093010E94FD08C90181509F4F18161906C7 +:100820001CF4522E5A9403C055245394521A60E07B +:1008300079E08DE390E0A40193010E94FD0821502E +:10084000304040405040CA01B90122E030E040E071 +:1008500050E00E94FD08209530954095509583E02A +:10086000220F331F441F551F8A95D1F760E074E2B1 +:1008700084EF90E00E94FD08CA01B9012FEF30E03B +:1008800040E050E00E94A908A40193010E94FD08E5 +:10089000C90181509F4F181619061CF4822F8150F0 +:1008A00002C081E0821B851500F5E885F98581E0AD +:1008B00090E00A8802C0880F991F0A94E2F78083AB +:1008C00060E079E08DE390E0A40193010E94FD08CF +:1008D0002150304040405040CA01B90122E030E090 +:1008E00040E050E00E94FD0804C0E885F9851082D0 +:1008F0009501EC81FD813083EE81FF812083EA85C3 +:10090000FB85208141E050E0CA010E8402C0880FBF +:10091000991F0A94E2F7282B2083EA85FB85208122 +:10092000CA010F8402C0880F991F0A94E2F7282B8E +:100930002083EA85FB858081088802C0440F551F0B +:100940000A94E2F7842B8083DF91CF911F910F915E +:10095000FF90EF90DF90CF90BF90AF909F908F90DF +:100960007F906F905F900895FC01A085B1852189EB +:100970008C9190E0022E02C0959587950A94E2F73B +:1009800080FFF6CF0484F585E02D608308958AE02A +:1009900091E09093A4018093A3018FE191E0909363 +:1009A000A6018093A50185EC90E09093A801809327 +:1009B000A70184EC90E09093AA018093A90180ECB8 +:1009C00090E09093AC018093AB0181EC90E0909328 +:1009D000AE018093AD0186EC90E09093B0018093DE +:1009E000AF0184E08093B10183E08093B20187E09E +:1009F0008093B30185E08093B40181E08093B501D9 +:100A000008950F931F93CF93DF938C01EB0109C0DF +:100A10002196D801ED91FC910190F081E02DC80163 +:100A2000099568816623A1F7DF91CF911F910F91FE +:100A30000895EF92FF920F931F93CF93DF938C0152 +:100A40007B01EA010CC0D7016D917D01D801ED91C8 +:100A5000FC910190F081E02DC80109952197209724 +:100A600091F7DF91CF911F910F91FF90EF90089533 +:100A7000DC01ED91FC910280F381E02D0995089550 +:100A80000F931F938C01DC01ED91FC910190F0819B +:100A9000E02D6DE00995D801ED91FC910190F08178 +:100AA000E02DC8016AE009951F910F9108950F93F9 +:100AB0001F938C010E943805C8010E9440051F91B8 +:100AC0000F9108952F923F924F925F926F927F9273 +:100AD0008F929F92AF92BF92CF92DF92EF92FF924E +:100AE0000F931F93DF93CF93CDB7DEB7A0970FB6C9 +:100AF000F894DEBF0FBECDBF1C016A017B0141151A +:100B000051056105710549F4DC01ED91FC910190FD +:100B1000F081E02D60E3099554C0882499245401A4 +:100B2000422E55246624772401E010E00C0F1D1F8F +:100B3000080D191DC701B601A30192010E94DB082F +:100B4000F80160830894811C911CA11CB11CC70191 +:100B5000B601A30192010E94DB08C901DA016C0110 +:100B60007D01C114D104E104F104F1F681E0E82E25 +:100B7000F12CEC0EFD1EE80CF91C3E010894611CE2 +:100B8000711CD501C4010197A109B1096C01C818F4 +:100B9000D90814C0F601EE0DFF1D60816A3010F413 +:100BA000605D01C0695CD101ED91FC910190F08123 +:100BB000E02DC10109950894E108F1086E147F0445 +:100BC00049F7A0960FB6F894DEBF0FBECDBFCF9108 +:100BD000DF911F910F91FF90EF90DF90CF90BF902A +:100BE000AF909F908F907F906F905F904F903F90CD +:100BF0002F900895EF92FF920F931F93CF93DF935F +:100C0000EC017A018B0177FF0FC0E881F981019037 +:100C1000F081E02D6DE2099510950095F094E09437 +:100C2000E11CF11C011D111DCE01B801A7012AE034 +:100C30000E946205DF91CF911F910F91FF90EF907D +:100C40000895AB01662757FD6095762F0E94FA053F +:100C500008955058BB27AA270ED0D4C1C5D130F073 +:100C6000CAD120F031F49F3F11F41EF495C10EF467 +:100C7000E095E7FB8BC1E92FD6D180F3BA17620765 +:100C800073078407950718F071F49EF5EEC10EF412 +:100C9000E0950B2EBA2FA02D0B01B90190010C018C +:100CA000CA01A0011124FF27591B99F0593F50F4A4 +:100CB000503E68F11A16F040A22F232F342F4427FC +:100CC000585FF3CF469537952795A795F0405395F4 +:100CD000C9F77EF41F16BA0B620B730B840BBAF0C4 +:100CE0009150A1F0FF0FBB1F661F771F881FC2F72F +:100CF0000EC0BA0F621F731F841F48F48795779543 +:100D00006795B795F7959E3F08F0B3CF9395880FF9 +:100D100008F09927EE0F97958795089565D158F0BB +:100D200080E891E009F49EEF66D128F040E851E0B8 +:100D300059F45EEF09C030C198C1E92FE07873D152 +:100D400068F3092E052AC1F3261737074807590704 +:100D500038F00E2E07F8E02569F0E025E0640AC0BF +:100D6000EF6307F8009407FADB01B9019D01DC018C +:100D7000CA01AD01EF9343D045D10AD05F9155230D +:100D800031F02BED3FE049E450FD49EC63CF08958D +:100D9000DF93DD27B92FBF7740E85FE3161617060C +:100DA00048075B0710F4D92F67D19F938F937F93E8 +:100DB0006F93CCD1E8E6F0E0F2D024D12F913F91AF +:100DC0004F915F916CD1DD2349F09058A2EA2AED52 +:100DD0003FE049EC5FE3D0785D274DDFDF9112C142 +:100DE0000CD010C108D140F0FFD030F021F45F3FAB +:100DF00019F0CCC051113AC1CFC015D198F3992345 +:100E0000C9F35523B1F3951B550BBB27AA276217CE +:100E10007307840738F09F5F5F4F220F331F441F13 +:100E2000AA1FA9F333D00E2E3AF0E0E830D091504B +:100E30005040E695001CCAF729D0FE2F27D0660F38 +:100E4000771F881FBB1F261737074807AB07B0E877 +:100E500009F0BB0B802DBF01FF2793585F4F2AF08D +:100E60009E3F510568F092C001C15F3FECF3983E90 +:100E7000DCF3869577956795B795F7959F5FC9F7EA +:100E8000880F911D9695879597F90895E1E0660F73 +:100E9000771F881FBB1F621773078407BA0720F0EC +:100EA000621B730B840BBA0BEE1F88F7E095089555 +:100EB00004D06894B111DAC00895BDD088F09F576E +:100EC00090F0B92F9927B751A0F0D1F0660F771F96 +:100ED000881F991F1AF0BA95C9F712C0B13081F076 +:100EE000C4D0B1E00895C1C0672F782F8827B85FBC +:100EF00039F0B93FCCF3869577956795B395D9F7D7 +:100F00003EF490958095709561957F4F8F4F9F4FE0 +:100F10000895E89409C097FB3EF4909580957095EC +:100F200061957F4F8F4F9F4F9923A9F0F92F96E935 +:100F3000BB279395F695879577956795B795F111AA +:100F4000F8CFFAF4BB0F11F460FF1BC06F5F7F4F47 +:100F50008F4F9F4F16C0882311F096E911C0772359 +:100F600021F09EE8872F762F05C0662371F096E862 +:100F7000862F70E060E02AF09A95660F771F881F31 +:100F8000DAF7880F9695879597F9089597F99F67EF +:100F900080E870E060E008959FEF80EC0895DF93B3 +:100FA000CF931F930F93FF92EF92DF927B018C01FF +:100FB000689405C0DA2EEF0172D0FE01E894A59185 +:100FC0002591359145915591AEF3EF0154DEFE0127 +:100FD0009701A801DA9479F7DF90EF90FF900F91D5 +:100FE0001F91CF91DF91089500240A9416161706D9 +:100FF00018060906089500240A941216130614060A +:1010000005060895092E0394000C11F4882352F06C +:10101000BB0F40F4BF2B11F460FF04C06F5F7F4F24 +:101020008F4F9F4F089557FD9058440F551F59F00B +:101030005F3F71F04795880F97FB991F61F09F3FC5 +:1010400079F087950895121613061406551FF2CFEE +:101050004695F1DF08C0161617061806991FF1CF3E +:1010600086957105610508940895E894BB27662765 +:101070007727CB0197F908959B01AC0160E070E000 +:1010800080E89FE3ADCE0BD0BDCFAEDF28F0B3DF5D +:1010900018F0952309F07ACF7FCF1124E7CFC3DF73 +:1010A000A0F3959FD1F3950F50E0551F629FF0017B +:1010B000729FBB27F00DB11D639FAA27F00DB11DD4 +:1010C000AA1F649F6627B00DA11D661F829F22275D +:1010D000B00DA11D621F739FB00DA11D621F839FE4 +:1010E000A00D611D221F749F3327A00D611D231FBA +:1010F000849F600D211D822F762F6A2F11249F5708 +:1011000050408AF0E1F088234AF0EE0FFF1FBB1F2A +:10111000661F771F881F91505040A9F79E3F5105C9 +:1011200070F034CFA3CF5F3FECF3983EDCF38695AD +:1011300077956795B795F795E7959F5FC1F7FE2B74 +:10114000880F911D9695879597F908959B01AC019D +:101150009ACF629FD001739FF001829FE00DF11D35 +:10116000649FE00DF11D929FF00D839FF00D749F21 +:10117000F00D659FF00D9927729FB00DE11DF91FCD +:10118000639FB00DE11DF91FBD01CF01112408952A +:1011900097FB092E07260AD077FD04D049D006D048 +:1011A00000201AF4709561957F4F0895F6F7909599 +:1011B00081959F4F0895A1E21A2EAA1BBB1BFD012A +:1011C0000DC0AA1FBB1FEE1FFF1FA217B307E40726 +:1011D000F50720F0A21BB30BE40BF50B661F771F7E +:1011E000881F991F1A9469F760957095809590955E +:1011F0009B01AC01BD01CF01089597FB092E052687 +:101200000ED057FD04D0D7DF0AD0001C38F450951B +:101210004095309521953F4F4F4F5F4F0895F6F71A +:1012200090958095709561957F4F8F4F9F4F089552 +:10123000AA1BBB1B51E107C0AA1FBB1FA617B707FC +:1012400010F0A61BB70B881F991F5A95A9F7809518 +:101250009095BC01CD010895EE0FFF1F0590F4910C +:08126000E02D0994F894FFCF82 +:1012680020000008090A00000000B404010519055F +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.o new file mode 100644 index 0000000..75d2e80 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Lab_Capitulo_3_Item_8_Bussula_HM55B.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Print.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/core.a b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/core.a new file mode 100644 index 0000000..adf85b9 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_3_Item_8_Bussula_HM55B/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/Lab_Capitulo_4_Item_1_Buzzer.pde b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/Lab_Capitulo_4_Item_1_Buzzer.pde new file mode 100644 index 0000000..34a83aa --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/Lab_Capitulo_4_Item_1_Buzzer.pde @@ -0,0 +1,114 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +//Incluir na solucao +#include + +int pino_leitura = P6; +int limpa = CHAVE; +int pino_escrita = P14; +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + +int speakerPin = 12; + +int length = 15; // the number of notes +char notes[] = "ccggaagffeeddc "; // a space represents a rest +int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 }; +int tempo = 300; + +void playTone(int tone, int duration) { + for (long i = 0; i < duration * 1000L; i += tone * 2) { + digitalWrite(speakerPin, HIGH); + delayMicroseconds(tone); + digitalWrite(speakerPin, LOW); + delayMicroseconds(tone); + } +} + +void playNote(char note, int duration) { + char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' }; + int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 }; + + // play the tone corresponding to the note name + for (int i = 0; i < 8; i++) { + if (names[i] == note) { + playTone(tones[i], duration); + } + } +} + +void setup() { + pinMode(speakerPin, OUTPUT); +} + +void loop() { + for (int i = 0; i < length; i++) { + if (notes[i] == ' ') { + delay(beats[i] * tempo); // rest + } else { + playNote(notes[i], beats[i] * tempo); + } + // pause between notes + delay(tempo / 2); + } +} + + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Debounce/Debounce.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Debounce/Debounce.cpp.o new file mode 100644 index 0000000..9889c84 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Debounce/Debounce.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp new file mode 100644 index 0000000..081e182 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp @@ -0,0 +1,132 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + +//Incluir na solucao +#include + +#include "WProgram.h" +void playTone(int tone, int duration); +void playNote(char note, int duration); +void setup(); +void loop(); +int pino_leitura = P6; +int limpa = CHAVE; +int pino_escrita = P14; +int led[] = { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LED_9 }; // array com a sequencia dos leds +int num_pins = 9; // tamanho do array + +int speakerPin = 12; + +int length = 15; // the number of notes +char notes[] = "ccggaagffeeddc "; // a space represents a rest +int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 }; +int tempo = 300; + +void playTone(int tone, int duration) { + for (long i = 0; i < duration * 1000L; i += tone * 2) { + digitalWrite(speakerPin, HIGH); + delayMicroseconds(tone); + digitalWrite(speakerPin, LOW); + delayMicroseconds(tone); + } +} + +void playNote(char note, int duration) { + char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' }; + int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 }; + + // play the tone corresponding to the note name + for (int i = 0; i < 8; i++) { + if (names[i] == note) { + playTone(tones[i], duration); + } + } +} + +void setup() { + pinMode(speakerPin, OUTPUT); +} + +void loop() { + for (int i = 0; i < length; i++) { + if (notes[i] == ' ') { + delay(beats[i] * tempo); // rest + } else { + playNote(notes[i], beats[i] * tempo); + } + // pause between notes + delay(tempo / 2); + } +} + + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.eep b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.elf b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.elf new file mode 100644 index 0000000..509c9ba Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.elf differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.hex b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.hex new file mode 100644 index 0000000..1ad805a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.hex @@ -0,0 +1,99 @@ +:100000000C9461000C947E000C947E000C947E0095 +:100010000C947E000C947E000C947E000C947E0068 +:100020000C947E000C947E000C947E000C947E0058 +:100030000C947E000C947E000C947E000C947E0048 +:100040000C9479010C947E000C947E000C947E003C +:100050000C947E000C947E000C947E000C947E0028 +:100060000C947E000C947E00000000002400270009 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C000000011241FBECFEFD8E0DEBFCDBF11E08E +:1000D000A0E0B1E0E0EDF5E002C005900D92AC3497 +:1000E000B107D9F711E0ACE4B1E001C01D92A5352C +:1000F000B107E1F70E9472010C94E6020C94000033 +:100100008091000161E00E94330208956F927F9216 +:100110008F929F92AF92BF92CF92DF92EF92FF9217 +:100120000F931F93CF93DF93EC01882777FD809582 +:10013000982F28EE33E040E050E00E94A0023B01FF +:100140004C01CE01880F991F5C01CC24B7FCC094F0 +:10015000DC2CEE24FF24870114C08091000161E0B3 +:100160000E945302CE010E94EB018091000160E0E9 +:100170000E945302CE010E94EB01EA0CFB1C0C1DF5 +:100180001D1DE614F704080519053CF3DF91CF9116 +:100190001F910F91FF90EF90DF90CF90BF90AF90A5 +:1001A0009F908F907F906F9008959F92AF92BF9293 +:1001B000CF92DF92EF92FF920F931F93DF93CF9333 +:1001C000CDB7DEB768970FB6F894DEBF0FBECDBFD0 +:1001D000982E5B01DE011196E4E4F1E088E00190E5 +:1001E0000D928150E1F7DE011996E4E3F1E080E140 +:1001F00001900D928150E1F77E010894E11CF11C01 +:100200008E01075F1F4F6801F7018081891531F466 +:10021000F80180819181B5010E9486000894E11C5B +:10022000F11C0E5F1F4FEC14FD0471F768960FB6BA +:10023000F894DEBF0FBECDBFCF91DF911F910F911C +:10024000FF90EF90DF90CF90BF90AF909F90089578 +:100250000F931F93CF93DF9304E111E0C0E0D0E050 +:1002600035C0FE01EC5FFE4F80814091320150911C +:100270003301F80120813181803271F4429FB00155 +:10028000439F700D529F700D1124882777FD809534 +:10029000982F0E94C10109C0429FB001439F700D79 +:1002A000529F700D11240E94D500809132019091CF +:1002B000330162E070E00E94BF02882777FD8095DD +:1002C000982F0E94C10121960E5F1F4F809102015D +:1002D00090910301C817D90724F2DF91CF911F91A4 +:1002E0000F9108950E94F9010E9480000E94280148 +:1002F000FDCF1F920F920FB60F9211242F933F93B1 +:100300008F939F93AF93BF93809150019091510130 +:10031000A0915201B0915301309154010196A11D59 +:10032000B11D232F2D5F2D3720F02D570196A11DD4 +:10033000B11D209354018093500190935101A093DB +:100340005201B093530180914C0190914D01A091C5 +:100350004E01B0914F010196A11DB11D80934C013A +:1003600090934D01A0934E01B0934F01BF91AF9177 +:100370009F918F913F912F910F900FBE0F901F90E3 +:100380001895EF92FF920F931F937B018C018FB70B +:10039000F894409150015091510160915201709137 +:1003A00053018FBF2FB7F894809150019091510164 +:1003B000A0915201B09153012FBF841B950BA60B46 +:1003C000B70BE816F9060A071B0760F71F910F9194 +:1003D000FF90EF900895019759F0FC01EE0FFF1F79 +:1003E000EE0FFF1F32978FB7F8943197F1F78FBF59 +:1003F0000895789484B5826084BD84B5816084BD9D +:1004000085B5826085BD85B5816085BDEEE6F0E08D +:10041000808181608083E1E8F0E080818260808378 +:10042000808181608083E0E8F0E08081816080836A +:10043000E1EBF0E0808184608083E0EBF0E080819C +:1004400081608083EAE7F0E080818460808380813E +:1004500082608083808181608083808180688083E6 +:100460001092C1000895282F30E0C90186569F4F91 +:10047000FC0194912A573F4FF9018491882391F010 +:10048000E82FF0E0EE0FFF1FE859FF4FA591B49160 +:10049000662329F48C91909589238C9308958C91EF +:1004A000892B8C930895482F50E0CA0182559F4FA5 +:1004B000FC012491CA0186569F4FFC0194914A5732 +:1004C0005F4FFA0134913323D1F1222331F12330EC +:1004D00021F4809180008F7705C0243031F4809121 +:1004E00080008F7D8093800018C0213019F484B57E +:1004F0008F7704C0223021F484B58F7D84BD0DC078 +:10050000263021F48091B0008F7705C0273029F480 +:100510008091B0008F7D8093B000E32FF0E0EE0F6C +:10052000FF1FEE58FF4FA591B491662329F48C91DB +:10053000909589238C9308958C91892B8C930895A1 +:10054000629FD001739FF001829FE00DF11D649FB7 +:10055000E00DF11D929FF00D839FF00D749FF00D43 +:10056000659FF00D9927729FB00DE11DF91F639FE4 +:10057000B00DE11DF91FBD01CF011124089597FBB6 +:10058000092E07260AD077FD04D00CD006D0002013 +:100590001AF4709561957F4F0895F6F790958195BF +:1005A0009F4F0895AA1BBB1B51E107C0AA1FBB1F89 +:1005B000A617B70710F0A61BB70B881F991F5A95EF +:1005C000A9F780959095BC01CD010895F894FFCFCF +:1005D0000C000F0063636767616167666665656449 +:1005E000646320000100010001000100010001001E +:1005F00002000100010001000100010001000200F1 +:1006000004002C017B07A406EF059805FB04700489 +:0C061000F603BC03636465666761624327 +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.o new file mode 100644 index 0000000..e6b47e5 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Lab_Capitulo_4_Item_1_Buzzer.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Print.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/core.a b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/core.a new file mode 100644 index 0000000..b5bb42d Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_1_Buzzer/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/Lab_Capitulo_4_Item_2_Solenoide.pde b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/Lab_Capitulo_4_Item_2_Solenoide.pde new file mode 100644 index 0000000..5498c14 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/Lab_Capitulo_4_Item_2_Solenoide.pde @@ -0,0 +1,102 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + + #define TEMPO_ATIVADO 1000 + +int ja_ativou = 0; +int contando_tempo = 0; +unsigned long inicio = 0; +unsigned long agora = 0; + +void setup () { + + pinMode(CHAVE, INPUT); // configura o pino como entrada + pinMode(Q4, OUTPUT); + pinMode(LED_9, OUTPUT); +} + + +void loop () { + + int leitura = digitalRead(CHAVE); + + if (leitura == LOW && ja_ativou == 0 && contando_tempo == 0) { + digitalWrite(LED_9, HIGH); + digitalWrite(Q4, HIGH); + ja_ativou = 1; + contando_tempo = 1; + inicio = millis(); + //delay (1000); + } else { + if (leitura == HIGH){ + ja_ativou = 0; + } + } + + if (contando_tempo == 1) { + agora = millis(); + if ( (agora - inicio) > TEMPO_ATIVADO ){ + contando_tempo = 0; + digitalWrite(LED_9, LOW); + digitalWrite(Q4, LOW); + } + } +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp new file mode 100644 index 0000000..d730099 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp @@ -0,0 +1,118 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + + #define TEMPO_ATIVADO 1000 + +#include "WProgram.h" +void setup (); +void loop (); +int ja_ativou = 0; +int contando_tempo = 0; +unsigned long inicio = 0; +unsigned long agora = 0; + +void setup () { + + pinMode(CHAVE, INPUT); // configura o pino como entrada + pinMode(Q4, OUTPUT); + pinMode(LED_9, OUTPUT); +} + + +void loop () { + + int leitura = digitalRead(CHAVE); + + if (leitura == LOW && ja_ativou == 0 && contando_tempo == 0) { + digitalWrite(LED_9, HIGH); + digitalWrite(Q4, HIGH); + ja_ativou = 1; + contando_tempo = 1; + inicio = millis(); + //delay (1000); + } else { + if (leitura == HIGH){ + ja_ativou = 0; + } + } + + if (contando_tempo == 1) { + agora = millis(); + if ( (agora - inicio) > TEMPO_ATIVADO ){ + contando_tempo = 0; + digitalWrite(LED_9, LOW); + digitalWrite(Q4, LOW); + } + } +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.eep b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.elf b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.elf new file mode 100644 index 0000000..ad5f31d Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.elf differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.hex b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.hex new file mode 100644 index 0000000..3b1a4d2 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.hex @@ -0,0 +1,74 @@ +:100000000C9461000C947E000C947E000C947E0095 +:100010000C947E000C947E000C947E000C947E0068 +:100020000C947E000C947E000C947E000C947E0058 +:100030000C947E000C947E000C947E000C947E0048 +:100040000C94F8000C947E000C947E000C947E00BE +:100050000C947E000C947E000C947E000C947E0028 +:100060000C947E000C947E00000000002400270009 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C000000011241FBECFEFD8E0DEBFCDBF11E08E +:1000D000A0E0B1E0ECE8F4E002C005900D92A030A1 +:1000E000B107D9F711E0A0E0B1E001C01D92A53140 +:1000F000B107E1F70E94F1000C9444020C94000057 +:1001000080E00E94F5019C01009749F58091000173 +:1001100090910101892B19F58091020190910301C1 +:10012000892B21F58DE061E00E94A80182E161E068 +:100130000E94A80181E090E090930101809300016A +:1001400090930301809302010E9440016093040197 +:1001500070930501809306019093070107C0213039 +:10016000310521F4109201011092000180910201E9 +:1001700090910301019739F50E94400160930801B5 +:100180007093090180930A0190930B01209104015F +:10019000309105014091060150910701621B730BDC +:1001A000840B950B695E73408040904060F0109224 +:1001B0000301109202018DE060E00E94A80182E13B +:1001C00060E00E94A801089580E060E00E9488013C +:1001D00082E161E00E9488018DE061E00E94880177 +:1001E00008950E944E010E94E4000E948000FDCF0D +:1001F0001F920F920FB60F9211242F933F938F935C +:100200009F93AF93BF938091100190911101A091A2 +:100210001201B0911301309114010196A11DB11D7D +:10022000232F2D5F2D3720F02D570196A11DB11DD5 +:10023000209314018093100190931101A093120157 +:10024000B093130180910C0190910D01A0910E01CA +:10025000B0910F010196A11DB11D80930C019093E7 +:100260000D01A0930E01B0930F01BF91AF919F912B +:100270008F913F912F910F900FBE0F901F90189567 +:100280008FB7F89420911001309111014091120123 +:10029000509113018FBFB901CA010895789484B5B4 +:1002A000826084BD84B5816084BD85B5826085BD72 +:1002B00085B5816085BDEEE6F0E080818160808358 +:1002C000E1E8F0E0808182608083808181608083CA +:1002D000E0E8F0E0808181608083E1EBF0E0808104 +:1002E00084608083E0EBF0E0808181608083EAE7D6 +:1002F000F0E080818460808380818260808380815F +:10030000816080838081806880831092C10008951D +:10031000282F30E0C90186569F4FFC0194912A573F +:100320003F4FF9018491882391F0E82FF0E0EE0F20 +:10033000FF1FE859FF4FA591B491662329F48C91D2 +:10034000909589238C9308958C91892B8C93089593 +:10035000482F50E0CA0182559F4FFC012491CA01E9 +:1003600086569F4FFC0194914A575F4FFA01349192 +:100370003323D1F1222331F1233021F48091800005 +:100380008F7705C0243031F4809180008F7D809379 +:10039000800018C0213019F484B58F7704C0223052 +:1003A00021F484B58F7D84BD0DC0263021F4809169 +:1003B000B0008F7705C0273029F48091B0008F7D81 +:1003C0008093B000E32FF0E0EE0FFF1FEE58FF4FD9 +:1003D000A591B491662329F48C91909589238C93EF +:1003E00008958C91892B8C930895682F70E0CB0130 +:1003F00082559F4FFC012491CB0186569F4FFC01F3 +:1004000044916A577F4FFB019491992319F420E09E +:1004100030E038C0222331F1233021F48091800074 +:100420008F7705C0243031F4809180008F7D8093D8 +:10043000800018C0213019F484B58F7704C02230B1 +:1004400021F484B58F7D84BD0DC0263021F48091C8 +:10045000B0008F7705C0273029F48091B0008F7DE0 +:100460008093B000892F90E0880F991F84589F4F88 +:10047000FC01A591B4918C9120E030E0842311F02F +:0C04800021E030E0C9010895F894FFCF9E +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.o new file mode 100644 index 0000000..9618a06 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Lab_Capitulo_4_Item_2_Solenoide.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Print.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/core.a b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/core.a new file mode 100644 index 0000000..6e8077a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_2_Solenoide/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_5_ServoMotor_2/Lab_Capitulo_4_Item_5_ServoMotor_2.pde b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_5_ServoMotor_2/Lab_Capitulo_4_Item_5_ServoMotor_2.pde new file mode 100644 index 0000000..2968478 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_5_ServoMotor_2/Lab_Capitulo_4_Item_5_ServoMotor_2.pde @@ -0,0 +1,41 @@ +/* +0.5 - 2.5 milisegundos funcionou bem para o servo. +Tente valores diferentes de acordo com o seu servo +*/ +int servoPino = 10; // Pino de controle para o servo1 +int tempoMinimo = 500; // Posição mínima do servomotor +int tempoMaximo = 2500; // Posição máxima do servomotor +int posicao_servo = 0; // posição do servo +int valor_posicao = tempoMinimo; +int i = 0; + +long ultimoControle = 0; // tempo em milisegundos em que ocorreu o último controle +long ultima_atualizacao = 0; + +int intervaloControle = 20; // intervalo de tempo entre os pulsos de controle +int tempo_movimentacao = 500; + +void setup() { + pinMode(servoPino, OUTPUT); + posicao_servo = 0; // Coloca o servo na posicao minima +} + +void loop() { + + if (millis() - ultima_atualizacao >= tempo_movimentacao) { + i+=5; + i = i % 180; + posicao_servo = i; + ultima_atualizacao = millis(); + } + valor_posicao = map(posicao_servo,0, 180, tempoMinimo, tempoMaximo); // mapeia o valor de 0 a 180 + // para a faixa entre tempo Minimo e Maximo +// atualiza o servo se o intervalo de tempo para controle passou + if (millis() - ultimoControle >= intervaloControle) { + digitalWrite(servoPino, HIGH); // Liga o sinal de controle + delayMicroseconds(valor_posicao); // Tempo em que mantem o sinal alto para controlar o servo + digitalWrite(servoPino, LOW); // Desliga o sinal de controle do servo + ultimoControle = millis(); // atualiza o momento do ultimo controle (em milissegundos) + } +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/Lab_Capitulo_4_Item_6_Motor_Passo.pde b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/Lab_Capitulo_4_Item_6_Motor_Passo.pde new file mode 100644 index 0000000..3d1eb49 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/Lab_Capitulo_4_Item_6_Motor_Passo.pde @@ -0,0 +1,203 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + + #define TEMPO_ATIVADO 100 + #define NUM_PASSOS 4 +int ja_ativou = 0; +int contando_tempo = 0; +unsigned long inicio = 0; + +int passo = 0; +int anda = 0; + +void setup () { + + pinMode(CHAVE, INPUT); // configura o pino como entrada + pinMode(Q2, OUTPUT); + pinMode(Q3, OUTPUT); + pinMode(Q4, OUTPUT); + pinMode(Q5, OUTPUT); + pinMode(LED_9, OUTPUT); +} + +void escreve_motor (boolean b_q2, boolean b_q3, boolean b_q4, boolean b_q5) { + + digitalWrite(Q2, b_q2); + digitalWrite(Q3, b_q3); + digitalWrite(Q4, b_q4); + digitalWrite(Q5, b_q5); + +} + + +void seleciona_passo (){ + + boolean b_q2, b_q3, b_q4, b_q5; + +/* + black brown orange yellow + A A/ B B/ + Q2 Q3 Q4 Q5 +1 1 0 0 1 +2 1 0 1 0 +3 0 1 1 0 +4 0 1 0 1 + +Q2 = A +Q3 = A/ +Q4 = B +Q5 = B/ + +*/ + switch (passo) { + case 0: + b_q2 = true; + b_q3 = false; + b_q4 = false; + b_q5 = true; + break; + case 1: + b_q2 = true; + b_q3 = false; + b_q4 = true; + b_q5 = false; + break; + case 2: + b_q2 = false; + b_q3 = true; + b_q4 = true; + b_q5 = false; + break; + case 3: + b_q2 = false; + b_q3 = true; + b_q4 = false; + b_q5 = true; + break; + } + escreve_motor (b_q2, b_q3, b_q4, b_q5); +} + +void avanca_passo(){ + + passo++; + passo = passo % NUM_PASSOS; + seleciona_passo(); +} + +void recua_passo(){ + passo--; + if (passo < 0) { + passo = 3; + } + //passo = passo % NUM_PASSOS; + seleciona_passo(); +} + + +void loop () { + + int leitura = digitalRead(CHAVE); + if (leitura == LOW) { + anda = !anda; + delay (300); + } + /*else { + delay (100); + if (leitura == HIGH){ + //anda = 0; + } + }*/ + + if (anda == 1) { + if (inicio == 0) { + inicio = millis(); + } + if ((millis() - inicio) > 100) { + avanca_passo(); + //delay(100); + inicio = millis(); + } + } + + + /*if (leitura == LOW && ja_ativou == 0 && contando_tempo == 0) { + digitalWrite(LED_9, HIGH); + //digitalWrite(Q4, HIGH); + avanca_passo(); + ja_ativou = 1; + contando_tempo = 1; + inicio = millis(); + //delay (1000); + } else { + if (leitura == HIGH){ + ja_ativou = 0; + } + } + + if (contando_tempo == 1) { + if ( (millis() - inicio) > TEMPO_ATIVADO ){ + contando_tempo = 0; + digitalWrite(LED_9, LOW); + //digitalWrite(Q4, LOW); + } + }*/ +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/HardwareSerial.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..100cb98 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/HardwareSerial.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp new file mode 100644 index 0000000..a1abead --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp @@ -0,0 +1,223 @@ + + #define P0 0 // Porta Digital 0 - Chave + #define P1 1 // Porta Digital 1 - Led 2 + #define P2 2 // Porta Digital 2 - Led 3 + #define P3 3 // Porta Digital 3 - Led 4 - PWM + #define P4 4 // Porta Digital 4 - Led 5 + #define P5 5 // Porta Digital 5 - Led 6 - PWM + #define P6 6 // Porta Digital 6 - Transistor Q3 - PWM + #define P7 7 // Porta Digital 7 - Led 8 + #define P8 8 // Porta Digital 8 - Led 7 + #define P9 9 // Porta Digital 9 - Transistor Q2 - PWM + #define P10 10 // Porta Digital 10 - Servo1 - PWM + #define P11 11 // Porta Digital 11 - Servo2 - PWM + #define P12 12 // Porta Digital 12 - Buzzer + #define P13 13 // Porta Digital 13 - Led 9 + #define P14 14 // Porta Analogica 0 - Led 1 + #define P15 15 // Porta Analogica 1 - JP6 - POT 1 + #define P16 16 // Porta Analogica 2 - JP7 - POT 2 + #define P17 17 // Porta Analogica 3 - Transistor Q5 + #define P18 18 // Porta Analogica 4 - Transistor Q4 + #define P19 19 // Porta Analogica 5 - LDR + + #define AP0 14 // Porta Analogica 0 Usando como digital - Led 1 + #define AP1 15 // Porta Analogica 1 Usando como digital - JP6 - POT 1 + #define AP2 16 // Porta Analogica 2 Usando como digital - JP7 - POT 2 + #define AP3 17 // Porta Analogica 3 Usando como digital - Transistor Q5 + #define AP4 18 // Porta Analogica 4 Usando como digital - Transistor Q4 + #define AP5 19 // Porta Analogica 5 Usando como digital - LDR + + #define A0 0 // Porta Analogica 0 - Led 1 + #define A1 1 // Porta Analogica 1 - JP6 - POT 1 + #define A2 2 // Porta Analogica 2 - JP7 - POT 2 + #define A3 3 // Porta Analogica 3 - Transistor Q5 + #define A4 4 // Porta Analogica 4 - Transistor Q4 + #define A5 5 // Porta Analogica 3 - LDR + + #define LED_1 14 + #define LED_2 1 + #define LED_3 2 + #define LED_4 3 + #define LED_5 4 + #define LED_6 5 + #define LED_7 8 + #define LED_8 7 + #define LED_9 13 + + #define Q2 9 //PWM + #define Q3 6 //PWM + #define Q4 18 + #define Q5 17 + + #define LDR 5 + #define JP6 1 + #define JP7 2 + #define CHAVE 0 + #define BOTAO 0 + #define BUZZER 12 + #define SERVO_1 10 + #define SERVO_2 11 + + #define TEMPO_ATIVADO 100 + #define NUM_PASSOS 4 +#include "WProgram.h" +void setup (); +void escreve_motor (boolean b_q2, boolean b_q3, boolean b_q4, boolean b_q5); +void seleciona_passo (); +void avanca_passo(); +void recua_passo(); +void loop (); +int ja_ativou = 0; +int contando_tempo = 0; +unsigned long inicio = 0; + +int passo = 0; +int anda = 0; + +void setup () { + + pinMode(CHAVE, INPUT); // configura o pino como entrada + pinMode(Q2, OUTPUT); + pinMode(Q3, OUTPUT); + pinMode(Q4, OUTPUT); + pinMode(Q5, OUTPUT); + pinMode(LED_9, OUTPUT); +} + +void escreve_motor (boolean b_q2, boolean b_q3, boolean b_q4, boolean b_q5) { + + digitalWrite(Q2, b_q2); + digitalWrite(Q3, b_q3); + digitalWrite(Q4, b_q4); + digitalWrite(Q5, b_q5); + +} + + +void seleciona_passo (){ + + boolean b_q2, b_q3, b_q4, b_q5; + +/* + black brown orange yellow + A A/ B B/ + Q2 Q3 Q4 Q5 +1 1 0 0 1 +2 1 0 1 0 +3 0 1 1 0 +4 0 1 0 1 + +Q2 = A +Q3 = A/ +Q4 = B +Q5 = B/ + +*/ + switch (passo) { + case 0: + b_q2 = true; + b_q3 = false; + b_q4 = false; + b_q5 = true; + break; + case 1: + b_q2 = true; + b_q3 = false; + b_q4 = true; + b_q5 = false; + break; + case 2: + b_q2 = false; + b_q3 = true; + b_q4 = true; + b_q5 = false; + break; + case 3: + b_q2 = false; + b_q3 = true; + b_q4 = false; + b_q5 = true; + break; + } + escreve_motor (b_q2, b_q3, b_q4, b_q5); +} + +void avanca_passo(){ + + passo++; + passo = passo % NUM_PASSOS; + seleciona_passo(); +} + +void recua_passo(){ + passo--; + if (passo < 0) { + passo = 3; + } + //passo = passo % NUM_PASSOS; + seleciona_passo(); +} + + +void loop () { + + int leitura = digitalRead(CHAVE); + if (leitura == LOW) { + anda = !anda; + delay (300); + } + /*else { + delay (100); + if (leitura == HIGH){ + //anda = 0; + } + }*/ + + if (anda == 1) { + if (inicio == 0) { + inicio = millis(); + } + if ((millis() - inicio) > 100) { + avanca_passo(); + //delay(100); + inicio = millis(); + } + } + + + /*if (leitura == LOW && ja_ativou == 0 && contando_tempo == 0) { + digitalWrite(LED_9, HIGH); + //digitalWrite(Q4, HIGH); + avanca_passo(); + ja_ativou = 1; + contando_tempo = 1; + inicio = millis(); + //delay (1000); + } else { + if (leitura == HIGH){ + ja_ativou = 0; + } + } + + if (contando_tempo == 1) { + if ( (millis() - inicio) > TEMPO_ATIVADO ){ + contando_tempo = 0; + digitalWrite(LED_9, LOW); + //digitalWrite(Q4, LOW); + } + }*/ +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.eep b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.elf b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.elf new file mode 100644 index 0000000..2c040da Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.elf differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.hex b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.hex new file mode 100644 index 0000000..3e4d75c --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.hex @@ -0,0 +1,94 @@ +:100000000C9461000C947E000C947E000C947E0095 +:100010000C947E000C947E000C947E000C947E0068 +:100020000C947E000C947E000C947E000C947E0058 +:100030000C947E000C947E000C947E000C947E0048 +:100040000C9446010C947E000C947E000C947E006F +:100050000C947E000C947E000C947E000C947E0028 +:100060000C947E000C947E00000000002400270009 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C000000011241FBECFEFD8E0DEBFCDBF11E08E +:1000D000A0E0B1E0EAECF5E002C005900D92A0309E +:1000E000B107D9F711E0A0E0B1E001C01D92A13144 +:1000F000B107E1F70E943F010C94E3020C94000069 +:10010000FF920F931F93982F162F042FF22E89E042 +:10011000692F0E94200286E0612F0E94200282E166 +:10012000602F0E94200281E16F2D0E9420021F910A +:100130000F91FF9008958091040190910501813005 +:10014000910581F0823091051CF4009741F016C0B2 +:100150008230910551F08330910581F40BC081E02C +:1001600060E00AC081E060E002C080E061E041E060 +:1001700020E004C080E061E040E021E00E948000D7 +:1001800008958091040190910501019664E070E06A +:100190000E94BC0290930501809304010E949B0081 +:1001A000089580E00E946D02892BA1F420E030E0E8 +:1001B0008091060190910701892B11F421E030E034 +:1001C00030930701209306016CE271E080E090E03B +:1001D0000E949C0180910601909107010197A9F569 +:1001E0008091000190910101A0910201B091030161 +:1001F0000097A105B10551F40E948E0160930001A2 +:100200007093010180930201909303010E948E017B +:1002100020910001309101014091020150910301B0 +:10022000621B730B840B950B653671058105910577 +:1002300060F00E94C1000E948E01609300017093E3 +:1002400001018093020190930301089580E060E032 +:100250000E94000289E061E00E94000286E061E005 +:100260000E94000282E161E00E94000281E161E0FF +:100270000E9400028DE061E00E94000208950E9449 +:10028000C6010E9426010E94D100FDCF1F920F924D +:100290000FB60F9211242F933F938F939F93AF9399 +:1002A000BF9380910C0190910D01A0910E01B0912E +:1002B0000F01309110010196A11DB11D232F2D5F5B +:1002C0002D3720F02D570196A11DB11D209310014F +:1002D00080930C0190930D01A0930E01B0930F0138 +:1002E0008091080190910901A0910A01B0910B0140 +:1002F0000196A11DB11D8093080190930901A0935F +:100300000A01B0930B01BF91AF919F918F913F91E3 +:100310002F910F900FBE0F901F9018958FB7F894E4 +:1003200020910C0130910D0140910E0150910F016F +:100330008FBFB901CA010895EF92FF920F931F93E7 +:100340007B018C018FB7F89440910C0150910D0105 +:1003500060910E0170910F018FBF2FB7F8948091BB +:100360000C0190910D01A0910E01B0910F012FBFD2 +:10037000841B950BA60BB70BE816F9060A071B079B +:1003800060F71F910F91FF90EF900895789484B5D6 +:10039000826084BD84B5816084BD85B5826085BD81 +:1003A00085B5816085BDEEE6F0E080818160808367 +:1003B000E1E8F0E0808182608083808181608083D9 +:1003C000E0E8F0E0808181608083E1EBF0E0808113 +:1003D00084608083E0EBF0E0808181608083EAE7E5 +:1003E000F0E080818460808380818260808380816E +:1003F000816080838081806880831092C10008952D +:10040000282F30E0C90186569F4FFC0194912A574E +:100410003F4FF9018491882391F0E82FF0E0EE0F2F +:10042000FF1FE859FF4FA591B491662329F48C91E1 +:10043000909589238C9308958C91892B8C930895A2 +:10044000482F50E0CA0182559F4FFC012491CA01F8 +:1004500086569F4FFC0194914A575F4FFA013491A1 +:100460003323D1F1222331F1233021F48091800014 +:100470008F7705C0243031F4809180008F7D809388 +:10048000800018C0213019F484B58F7704C0223061 +:1004900021F484B58F7D84BD0DC0263021F4809178 +:1004A000B0008F7705C0273029F48091B0008F7D90 +:1004B0008093B000E32FF0E0EE0FFF1FEE58FF4FE8 +:1004C000A591B491662329F48C91909589238C93FE +:1004D00008958C91892B8C930895682F70E0CB013F +:1004E00082559F4FFC012491CB0186569F4FFC0102 +:1004F00044916A577F4FFB019491992319F420E0AE +:1005000030E038C0222331F1233021F48091800083 +:100510008F7705C0243031F4809180008F7D8093E7 +:10052000800018C0213019F484B58F7704C02230C0 +:1005300021F484B58F7D84BD0DC0263021F48091D7 +:10054000B0008F7705C0273029F48091B0008F7DEF +:100550008093B000892F90E0880F991F84589F4F97 +:10056000FC01A591B4918C9120E030E0842311F03E +:1005700021E030E0C901089597FB092E07260AD033 +:1005800077FD04D00CD006D000201AF47095619548 +:100590007F4F0895F6F7909581959F4F0895AA1B78 +:1005A000BB1B51E107C0AA1FBB1FA617B70710F05E +:1005B000A61BB70B881F991F5A95A9F78095909590 +:0A05C000BC01CD010895F894FFCFAF +:00000001FF diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.o new file mode 100644 index 0000000..97acb30 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Lab_Capitulo_4_Item_6_Motor_Passo.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Print.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Print.cpp.o new file mode 100644 index 0000000..1a8528b Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/Print.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/WInterrupts.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/WInterrupts.c.o new file mode 100644 index 0000000..c144c88 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/WInterrupts.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/WMath.cpp.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/WMath.cpp.o new file mode 100644 index 0000000..9800f21 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/WMath.cpp.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/core.a b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/core.a new file mode 100644 index 0000000..9539deb Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/core.a differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/pins_arduino.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/pins_arduino.c.o new file mode 100644 index 0000000..5f7d096 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/pins_arduino.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring.c.o new file mode 100644 index 0000000..09dff37 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_analog.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_analog.c.o new file mode 100644 index 0000000..b57a635 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_analog.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_digital.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_digital.c.o new file mode 100644 index 0000000..0ccb89a Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_digital.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_pulse.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_pulse.c.o new file mode 100644 index 0000000..79f27c6 Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_pulse.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_shift.c.o b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_shift.c.o new file mode 100644 index 0000000..015cdba Binary files /dev/null and b/arduino/all the sketchs of my life/Robotica/CursoRobotica/Lab_Capitulo_4_Item_6_Motor_Passo/applet/wiring_shift.c.o differ diff --git a/arduino/all the sketchs of my life/Robotica/GarraClient/GarraClient.pde b/arduino/all the sketchs of my life/Robotica/GarraClient/GarraClient.pde new file mode 100644 index 0000000..7b380ce --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/GarraClient/GarraClient.pde @@ -0,0 +1,53 @@ +#include +#include +LiquidCrystal_I2C lcd(0x27,16,2); + +void setup() { + lcd.init(); + lcd.backlight(); + lcd.setCursor(0, 1); + lcd.print("Program-ME v2"); + + Serial.begin(9600); + + Wire.begin(); + delay(1000); + Wire.beginTransmission(65); + Wire.send("1+"); + Wire.endTransmission(); + Wire.beginTransmission(65); + Wire.send("2-"); + Wire.endTransmission(); + + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1."); + Wire.endTransmission(); + Wire.beginTransmission(65); + Wire.send("2."); + Wire.endTransmission(); + + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1-"); + Wire.endTransmission(); + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1."); + Wire.endTransmission(); + delay(2000); + +} + +void loop() { + /*if(Serial.available()>0) Wire.beginTransmission(65); + while(Serial.available()>0) Wire.send(Serial.read()); + Wire.endTransmission(); */ + +} + + + diff --git a/arduino/all the sketchs of my life/Robotica/GarraClientLCD/GarraClientLCD.pde b/arduino/all the sketchs of my life/Robotica/GarraClientLCD/GarraClientLCD.pde new file mode 100644 index 0000000..7b380ce --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/GarraClientLCD/GarraClientLCD.pde @@ -0,0 +1,53 @@ +#include +#include +LiquidCrystal_I2C lcd(0x27,16,2); + +void setup() { + lcd.init(); + lcd.backlight(); + lcd.setCursor(0, 1); + lcd.print("Program-ME v2"); + + Serial.begin(9600); + + Wire.begin(); + delay(1000); + Wire.beginTransmission(65); + Wire.send("1+"); + Wire.endTransmission(); + Wire.beginTransmission(65); + Wire.send("2-"); + Wire.endTransmission(); + + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1."); + Wire.endTransmission(); + Wire.beginTransmission(65); + Wire.send("2."); + Wire.endTransmission(); + + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1-"); + Wire.endTransmission(); + delay(2000); + + Wire.beginTransmission(65); + Wire.send("1."); + Wire.endTransmission(); + delay(2000); + +} + +void loop() { + /*if(Serial.available()>0) Wire.beginTransmission(65); + while(Serial.available()>0) Wire.send(Serial.read()); + Wire.endTransmission(); */ + +} + + + diff --git a/arduino/all the sketchs of my life/Robotica/GarraCompleta/GarraCompleta.pde b/arduino/all the sketchs of my life/Robotica/GarraCompleta/GarraCompleta.pde new file mode 100644 index 0000000..f8bd96f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/GarraCompleta/GarraCompleta.pde @@ -0,0 +1,52 @@ +#include +#include + +MotorDC motorBase1(5, 6, 7); //branco +MotorDC motorBase2(3, 2, 4); //amarelo +MotorDC motorBase3(11, 12, 13); //azul +MotorDC motorGarra(10, 9, 8); //preto +MotorDC motor= motorBase1; //motor para trabalhar via I2C + +void setup(){ + Serial.begin(9600); + Wire.begin(65); + Wire.onReceive(receiveEvent); + motorBase1.andarParaFrente(255); + delay(2000); + motorBase1.parar(); +} + +void loop() { + Serial.println("nir"); + delay(2000); + +} + +void receiveEvent(int howMany) { + char comando[16]; + int counter=0; + while(Wire.available()>0) + { + comando[counter++]=Wire.receive(); + } + + Serial.print("Evento: "); + Serial.println(comando); + Serial.print("N Motor: "); + Serial.println(comando[0]); + Serial.print("Comando: "); + Serial.println(comando[1]=='+' ? "avançar" : comando[1]=='.' ? "parar" : "retroceder"); + if(comando[0]=='1') motor = motorBase1; + else if(comando[0]=='2') motor = motorBase2; + else if(comando[0]=='3') motor = motorBase3; + else if(comando[0]=='4') motor = motorGarra; + else return; + //Serial.println("agora vai"); + if(comando[1]=='+') motor.andarParaFrente(255); + else if(comando[1]=='-') motor.andarParaTras(255); + else if(comando[1]=='.') motor.parar(); + //delay(500); + //motor.parar(); + +} + diff --git a/arduino/all the sketchs of my life/Robotica/RF_ReceptorComandos/RF_ReceptorComandos.pde b/arduino/all the sketchs of my life/Robotica/RF_ReceptorComandos/RF_ReceptorComandos.pde new file mode 100644 index 0000000..4d0fb95 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/RF_ReceptorComandos/RF_ReceptorComandos.pde @@ -0,0 +1,114 @@ +#include +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 + +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 5 + +#define SPEAKER 12 + +#define TX 0 +#define RX 1 + +#define PING 15 + +#define LCD_RS 14 +#define LCD_EN 17 +#define LCD_D4 4 +#define LCD_D5 3 +#define LCD_D6 2 +#define LCD_D7 18 + +#define COMANDO_TAMANHO 16 +char comando[16]; +uint8_t buf[VW_MAX_MESSAGE_LEN]; +uint8_t buflen = VW_MAX_MESSAGE_LEN; +char string[16]; + +LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7); + +const char FRENTE[COMANDO_TAMANHO] = "FRENTE "; +const char RE[COMANDO_TAMANHO] = "RE "; +const char ESQUERDA[COMANDO_TAMANHO] = "ESQUERDA "; +const char DIREITA[COMANDO_TAMANHO] = "DIREITA "; + +void setup() { + setupEngines(); + setupLCD(); + setupReceptorRF(); + pinMode(SPEAKER, OUTPUT); +} +void setupReceptorRF() { + pinMode(RX,INPUT); + vw_set_rx_pin (RX); //Pino que recebe os dados + vw_setup(2000); // Bits per sec + vw_rx_start(); // Start the receiver PLL running +} + +void setupLCD() { + lcd.begin(16, 2); + initLCD(); +} +void initLCD() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("BRoBot:"); + lcd.setCursor(0, 1); + lcd.print("Aguardando...."); +} +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + parar(); +} + +void loop(){ + uint8_t buf[VW_MAX_MESSAGE_LEN]; + uint8_t buflen = VW_MAX_MESSAGE_LEN; + if (vw_get_message(buf, &buflen)) // Non-blocking + { + int i; + lcd.setCursor(0, 1); + lcd.clear(); + limpaComando(); + for (i = 0; i < buflen; i++) + { + comando[i]=buf[i]; + } + lcd.print(comando); + if(strcmp(comando, FRENTE)==0) { + andarFrente(2000,5); + parar(); + } + else if(strcmp(comando, RE)==0) { + andarTraz(2000,5); + parar(); + } + if(strcmp(comando, DIREITA)==0) { + virarDireita(2000,5); + parar(); + } + if(strcmp(comando, ESQUERDA)==0) { + virarEsquerda(2000,5); + parar(); + } + } +} + +void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } +} + +/* +*/ + diff --git a/arduino/all the sketchs of my life/Robotica/RF_ReceptorComandos/Walk.pde b/arduino/all the sketchs of my life/Robotica/RF_ReceptorComandos/Walk.pde new file mode 100644 index 0000000..7e22f25 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/RF_ReceptorComandos/Walk.pde @@ -0,0 +1,58 @@ +int sentido; + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + diff --git a/arduino/all the sketchs of my life/Robotica/RF_TransmissorComandos/RF_TransmissorComandos.pde b/arduino/all the sketchs of my life/Robotica/RF_TransmissorComandos/RF_TransmissorComandos.pde new file mode 100644 index 0000000..8ba23ce --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/RF_TransmissorComandos/RF_TransmissorComandos.pde @@ -0,0 +1,22 @@ +#include + +void setup() +{ + Serial.begin(9600); + pinMode(3, OUTPUT); + vw_set_tx_pin(3); + vw_setup(2000); +} + +void loop() +{ + char c[3]; + int counter = 0; + for(int x=0;x<300;x++) { + itoa(x,c,10); + Serial.println(c); + vw_send((uint8_t *) c,strlen(c)); + delay(500); + } +} + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android/AtualizarDisplay.ino b/arduino/all the sketchs of my life/Robotica/Robo_Android/AtualizarDisplay.ino new file mode 100644 index 0000000..51b700a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android/AtualizarDisplay.ino @@ -0,0 +1,46 @@ +/*void atualizaDisplay() { + lcd.clear(); + + //atualiza temperatura + //lcd.setCursor(col,row); + lcd.setCursor(8,1); + lcd.print(analogRead(SensorTemperatura)/2); + lcd.print("oC"); + + Serial.print("Temperatura= "); + Serial.println(analogRead(SensorTemperatura)/2); + + //atualiza luminosidade + //lcd.setCursor(col,row); + lcd.setCursor(0,1); + lcd.print(map((analogRead(LDR)), 0, 1023, 100,0)); + lcd.print(" %"); + + Serial.print("Luminosidade= "); + Serial.println(map((analogRead(LDR)), 0, 1023, 100,0)); + Serial.println(" "); + + + //lcd.setCursor(col,row); + lcd.setCursor(0,0); + lcd.print(DistanciaEsquerda); + lcd.print(" cms"); + + //atualiza distancia esquerda + Serial.print("Distancia Esquerda= "); + Serial.println(DistanciaEsquerda); + + //atualiza distancia direita + //lcd.setCursor(col,row); + lcd.setCursor(8,0); + lcd.print(DistanciaDireita); + lcd.print(" cms"); + + Serial.print("Distancia Direita= "); + Serial.println(DistanciaDireita); + + + +} +*/ + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android/Robo_Android.ino b/arduino/all the sketchs of my life/Robotica/Robo_Android/Robo_Android.ino new file mode 100644 index 0000000..832d25f --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android/Robo_Android.ino @@ -0,0 +1,453 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +#define MOTOR1_P 7 +#define MOTOR1_N 8 +#define MOTOR1_PWM 10 +#define MOTOR2_P 12 +#define MOTOR2_N 13 +#define MOTOR2_PWM 11 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int SensorTemperatura = 1 ; +int LDR = 5; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo servoV; +Servo servoH; +int modo = 1; +int sentido; + + +void setup() { + Serial.begin(115200); + //servoH.attach(10); + //servoV.attach(11); + //meetAndroid.setSerial(&Serial); + meetAndroid.registerFunction(dedoDuro, 'A'); + meetAndroid.registerFunction(acelera, 'C'); + meetAndroid.registerFunction(encontraNorte, 'B'); + meetAndroid.registerFunction(andar, 'W'); + meetAndroid.registerFunction(leds, 'L'); + meetAndroid.registerFunction(mudarModo, 'M'); + + /* set up the LCD's number of rows and columns: + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Aguardando");*/ + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + pinMode(LED_RED, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + testeLeds(); + +} + +void loop() { + meetAndroid.receive(); + delay(50); + //meetAndroid.send(analogRead(1)); + //testeLeds(); +} +void leds(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + + if(comando[0]=='R') { + pinMode(LED_RED,INPUT); + int ligado = digitalRead(LED_RED); + pinMode(LED_RED,OUTPUT); + digitalWrite(LED_RED,!ligado); + + } + else if(comando[0]=='G') { + pinMode(LED_GREEN,INPUT); + int ligado = digitalRead(LED_GREEN); + pinMode(LED_GREEN,OUTPUT); + digitalWrite(LED_GREEN,!ligado); + } + else if(comando[0]=='B') { + pinMode(LED_BLUE,INPUT); + int ligado = digitalRead(LED_BLUE); + pinMode(LED_BLUE,OUTPUT); + digitalWrite(LED_BLUE,!ligado); + } + +} +void testeLeds() { + digitalWrite(LED_RED, HIGH); + delay(200); + digitalWrite(LED_RED, LOW); + delay(200); + digitalWrite(LED_BLUE, HIGH); + delay(200); + digitalWrite(LED_BLUE, LOW); + delay(200); + digitalWrite(LED_GREEN, HIGH); + delay(200); + digitalWrite(LED_GREEN, LOW); + delay(200); +} +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + testeLeds(); +} + +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + if(modo==4) { + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarTraz(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarFrente(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + } + else if(modo==6){ + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + delay(200); + } +} + + + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=3) return; + + if(comando[0]=='F') { + dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + dance(); + } +} + +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=1) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + testeLeds(); + } + } +} + +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=2) return; + if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + +/*void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } + }*/ + +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + + 28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ +int led_status=0; +void changeServo(int a) { + + digitalWrite(LED_RED, led_status); + led_status = led_status==0 ? 1 : 0; +} + +void dance() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + /*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android/Wask.ino b/arduino/all the sketchs of my life/Robotica/Robo_Android/Wask.ino new file mode 100644 index 0000000..19a2ed2 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android/Wask.ino @@ -0,0 +1,273 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 +long duration, inches, cm; +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServoOK(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_n2/AtualizarDisplay.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_n2/AtualizarDisplay.pde new file mode 100644 index 0000000..51b700a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_n2/AtualizarDisplay.pde @@ -0,0 +1,46 @@ +/*void atualizaDisplay() { + lcd.clear(); + + //atualiza temperatura + //lcd.setCursor(col,row); + lcd.setCursor(8,1); + lcd.print(analogRead(SensorTemperatura)/2); + lcd.print("oC"); + + Serial.print("Temperatura= "); + Serial.println(analogRead(SensorTemperatura)/2); + + //atualiza luminosidade + //lcd.setCursor(col,row); + lcd.setCursor(0,1); + lcd.print(map((analogRead(LDR)), 0, 1023, 100,0)); + lcd.print(" %"); + + Serial.print("Luminosidade= "); + Serial.println(map((analogRead(LDR)), 0, 1023, 100,0)); + Serial.println(" "); + + + //lcd.setCursor(col,row); + lcd.setCursor(0,0); + lcd.print(DistanciaEsquerda); + lcd.print(" cms"); + + //atualiza distancia esquerda + Serial.print("Distancia Esquerda= "); + Serial.println(DistanciaEsquerda); + + //atualiza distancia direita + //lcd.setCursor(col,row); + lcd.setCursor(8,0); + lcd.print(DistanciaDireita); + lcd.print(" cms"); + + Serial.print("Distancia Direita= "); + Serial.println(DistanciaDireita); + + + +} +*/ + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_n2/Robo_Android_n2.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_n2/Robo_Android_n2.pde new file mode 100644 index 0000000..e2ea7c8 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_n2/Robo_Android_n2.pde @@ -0,0 +1,460 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int SensorTemperatura = 1 ; +int LDR = 5; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo servoV; +Servo servoH; +int modo = 1; +int sentido; + + +void setup() { + Serial.begin(115200); + servoH.attach(10); + servoV.attach(11); + meetAndroid.registerFunction(dedoDuro, 'A'); + meetAndroid.registerFunction(acelera, 'C'); + meetAndroid.registerFunction(encontraNorte, 'B'); + meetAndroid.registerFunction(andar, 'W'); + meetAndroid.registerFunction(leds, 'L'); + meetAndroid.registerFunction(mudarModo, 'M'); + + /* set up the LCD's number of rows and columns: + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Aguardando");*/ + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + pinMode(LED_RED, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + testeLeds(); + andarFrente(2000,5); + parar(); + andarTraz(2000,5); + parar(); + girarNoEixo(2000,5,0); + parar(); + girarNoEixo(2000,5,1); + parar(); + +} + +void loop() { + //meetAndroid.receive(); + //delay(50); + //meetAndroid.send(analogRead(1)); + //testeLeds(); +} +void leds(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + + if(comando[0]=='R') { + pinMode(LED_RED,INPUT); + int ligado = digitalRead(LED_RED); + pinMode(LED_RED,OUTPUT); + digitalWrite(LED_RED,!ligado); + + } + else if(comando[0]=='G') { + pinMode(LED_GREEN,INPUT); + int ligado = digitalRead(LED_GREEN); + pinMode(LED_GREEN,OUTPUT); + digitalWrite(LED_GREEN,!ligado); + } + else if(comando[0]=='B') { + pinMode(LED_BLUE,INPUT); + int ligado = digitalRead(LED_BLUE); + pinMode(LED_BLUE,OUTPUT); + digitalWrite(LED_BLUE,!ligado); + } + +} +void testeLeds() { + digitalWrite(LED_RED, HIGH); + delay(200); + digitalWrite(LED_RED, LOW); + delay(200); + digitalWrite(LED_BLUE, HIGH); + delay(200); + digitalWrite(LED_BLUE, LOW); + delay(200); + digitalWrite(LED_GREEN, HIGH); + delay(200); + digitalWrite(LED_GREEN, LOW); + delay(200); +} +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + testeLeds(); +} + +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + if(modo==4) { + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarTraz(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarFrente(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + } + else if(modo==6){ + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + delay(200); + } +} + + + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=3) return; + + if(comando[0]=='F') { + dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + dance(); + } +} + +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=1) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + testeLeds(); + } + } +} + +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=2) return; + if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + +/*void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } + }*/ + +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + + 28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ +int led_status=0; +void changeServo(int a) { + + digitalWrite(LED_RED, led_status); + led_status = led_status==0 ? 1 : 0; +} + +void dance() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + /*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_n2/Wask.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_n2/Wask.pde new file mode 100644 index 0000000..19a2ed2 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_n2/Wask.pde @@ -0,0 +1,273 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 +long duration, inches, cm; +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServoOK(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_n3/AtualizarDisplay.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_n3/AtualizarDisplay.pde new file mode 100644 index 0000000..51b700a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_n3/AtualizarDisplay.pde @@ -0,0 +1,46 @@ +/*void atualizaDisplay() { + lcd.clear(); + + //atualiza temperatura + //lcd.setCursor(col,row); + lcd.setCursor(8,1); + lcd.print(analogRead(SensorTemperatura)/2); + lcd.print("oC"); + + Serial.print("Temperatura= "); + Serial.println(analogRead(SensorTemperatura)/2); + + //atualiza luminosidade + //lcd.setCursor(col,row); + lcd.setCursor(0,1); + lcd.print(map((analogRead(LDR)), 0, 1023, 100,0)); + lcd.print(" %"); + + Serial.print("Luminosidade= "); + Serial.println(map((analogRead(LDR)), 0, 1023, 100,0)); + Serial.println(" "); + + + //lcd.setCursor(col,row); + lcd.setCursor(0,0); + lcd.print(DistanciaEsquerda); + lcd.print(" cms"); + + //atualiza distancia esquerda + Serial.print("Distancia Esquerda= "); + Serial.println(DistanciaEsquerda); + + //atualiza distancia direita + //lcd.setCursor(col,row); + lcd.setCursor(8,0); + lcd.print(DistanciaDireita); + lcd.print(" cms"); + + Serial.print("Distancia Direita= "); + Serial.println(DistanciaDireita); + + + +} +*/ + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_n3/Robo_Android_n3.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_n3/Robo_Android_n3.pde new file mode 100644 index 0000000..eeb151e --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_n3/Robo_Android_n3.pde @@ -0,0 +1,453 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +#define MOTOR1_P 13 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 +#define MOTOR2_P 7 +#define MOTOR2_N 8 +#define MOTOR2_PWM 5 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int SensorTemperatura = 1 ; +int LDR = 5; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo servoV; +Servo servoH; +int modo = 1; +int sentido; + + +void setup() { + Serial.begin(115200); + servoH.attach(10); + servoV.attach(11); + /* set up the LCD's number of rows and columns: + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Aguardando");*/ + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + pinMode(LED_RED, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + //testeLeds(); + andarFrente(2000,5); + parar(); + andarTraz(2000,5); + parar(); + girarNoEixo(2000,5,0); + parar(); + girarNoEixo(2000,5,1); + parar(); + +} + +void loop() { + //meetAndroid.receive(); + //delay(50); + //meetAndroid.send(analogRead(1)); + //testeLeds(); +} +void leds(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + + if(comando[0]=='R') { + pinMode(LED_RED,INPUT); + int ligado = digitalRead(LED_RED); + pinMode(LED_RED,OUTPUT); + digitalWrite(LED_RED,!ligado); + + } + else if(comando[0]=='G') { + pinMode(LED_GREEN,INPUT); + int ligado = digitalRead(LED_GREEN); + pinMode(LED_GREEN,OUTPUT); + digitalWrite(LED_GREEN,!ligado); + } + else if(comando[0]=='B') { + pinMode(LED_BLUE,INPUT); + int ligado = digitalRead(LED_BLUE); + pinMode(LED_BLUE,OUTPUT); + digitalWrite(LED_BLUE,!ligado); + } + +} +void testeLeds() { + digitalWrite(LED_RED, HIGH); + delay(200); + digitalWrite(LED_RED, LOW); + delay(200); + digitalWrite(LED_BLUE, HIGH); + delay(200); + digitalWrite(LED_BLUE, LOW); + delay(200); + digitalWrite(LED_GREEN, HIGH); + delay(200); + digitalWrite(LED_GREEN, LOW); + delay(200); +} +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + testeLeds(); +} + +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + if(modo==4) { + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarTraz(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarFrente(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + } + else if(modo==6){ + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + delay(200); + } +} + + + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=3) return; + + if(comando[0]=='F') { + dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + dance(); + } +} + +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=1) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + testeLeds(); + } + } +} + +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=2) return; + if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + +/*void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } + }*/ + +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + + 28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ +int led_status=0; +void changeServo(int a) { + + digitalWrite(LED_RED, led_status); + led_status = led_status==0 ? 1 : 0; +} + +void dance() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + /*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_n3/Wask.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_n3/Wask.pde new file mode 100644 index 0000000..19a2ed2 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_n3/Wask.pde @@ -0,0 +1,273 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 +long duration, inches, cm; +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServoOK(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Acelerometro.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Acelerometro.pde new file mode 100644 index 0000000..a578c2c --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Acelerometro.pde @@ -0,0 +1,37 @@ +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + if(modo==4) { + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarFrente(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarTraz(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + } +} + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/AndarSozinho.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/AndarSozinho.pde new file mode 100644 index 0000000..32fa0ba --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/AndarSozinho.pde @@ -0,0 +1,62 @@ +int lerPingComMedia() { + int d1,d2,d3; + d1 = analogRead(1); + delay(5); + d2 = analogRead(1); + delay(5); + d3 = analogRead(1); + delay(5); + return (d1 + d2 + d3)/3; +} + +void lerPing() { + distancia = lerPingComMedia(); +} +void lerPingFull() { + servoH.write(30); + delay(200); + distanciaEsquerda = lerPingComMedia(); + servoH.write(100); + delay(200); + distancia = lerPingComMedia(); + servoH.write(150); + delay(200); + distanciaDireita = lerPingComMedia(); + servoH.write(85); +} + +void andarSozinho() { + lerPing(); + + while(distancia>25) { + andarFrente(100,3); + lerPing(); + if(modo!=6) return; + } + while(distancia>15 && distancia<25) { + if(modo!=6) return; + parar(); + delay(200); + lerPingFull(); + if(distanciaEsquerda>distancia && distanciaEsquerda>distanciaDireita) { + girarNoEixo(300,2,1); + } + if(distanciaDireita>distancia && distanciaDireita>distanciaEsquerda) { + girarNoEixo(300,2,0); + } + lerPing(); + if(modo!=6) return; + } + while(distancia>5 && distancia<15) { + parar(); + andarTraz(500,2); + girarNoEixo(500,2, random(10)%2==0); + lerPing(); + if(modo!=6) return; + } + +} + + + + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Bussola.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Bussola.pde new file mode 100644 index 0000000..8d02c58 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Bussola.pde @@ -0,0 +1,27 @@ +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=2) return; + if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Dance.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Dance.pde new file mode 100644 index 0000000..4afc6d9 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Dance.pde @@ -0,0 +1,171 @@ + +void dance() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + /*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + + + + + + + + + + + + + + + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/DedoDuro.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/DedoDuro.pde new file mode 100644 index 0000000..8bdb320 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/DedoDuro.pde @@ -0,0 +1,16 @@ +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=1) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + testeLeds(); + } + } +} + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Leds.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Leds.pde new file mode 100644 index 0000000..3b723d9 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Leds.pde @@ -0,0 +1,42 @@ +void leds(byte flag, byte numOfValues) { + if(modo!=5) return; + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + + if(comando[0]=='R') { + pinMode(LED_RED,INPUT); + int ligado = digitalRead(LED_RED); + pinMode(LED_RED,OUTPUT); + digitalWrite(LED_RED,!ligado); + + } + else if(comando[0]=='G') { + pinMode(LED_GREEN,INPUT); + int ligado = digitalRead(LED_GREEN); + pinMode(LED_GREEN,OUTPUT); + digitalWrite(LED_GREEN,!ligado); + } + else if(comando[0]=='B') { + pinMode(LED_BLUE,INPUT); + int ligado = digitalRead(LED_BLUE); + pinMode(LED_BLUE,OUTPUT); + digitalWrite(LED_BLUE,!ligado); + } + +} +void testeLeds() { + digitalWrite(LED_RED, HIGH); + delay(200); + digitalWrite(LED_RED, LOW); + delay(200); + digitalWrite(LED_BLUE, HIGH); + delay(200); + digitalWrite(LED_BLUE, LOW); + delay(200); + digitalWrite(LED_GREEN, HIGH); + delay(200); + digitalWrite(LED_GREEN, LOW); + delay(200); +} + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Robo_Android_v2.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Robo_Android_v2.pde new file mode 100644 index 0000000..775fb28 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Robo_Android_v2.pde @@ -0,0 +1,114 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int SensorTemperatura = 1 ; +int LDR = 5; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long distanciaEsquerda; +long distanciaDireita; +long distancia; +Servo servoV; +Servo servoH; +int modo = 1; +int sentido; + +void setup() { + Serial.begin(115200); + servoH.attach(10); + servoV.attach(11); + meetAndroid.setSerial(&Serial); + meetAndroid.registerFunction(dedoDuro, 'A'); + meetAndroid.registerFunction(acelera, 'C'); + meetAndroid.registerFunction(encontraNorte, 'B'); + meetAndroid.registerFunction(andar, 'W'); + meetAndroid.registerFunction(leds, 'L'); + meetAndroid.registerFunction(mudarModo, 'M'); + + /* set up the LCD's number of rows and columns: + lcd.begin(16, 2); + lcd.setCursor(0, 0); + lcd.print("Aguardando");*/ + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + pinMode(LED_RED, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + testeLeds(); + +} + +void loop() { + meetAndroid.receive(); + delay(50); + if(modo==6) andarSozinho(); + //meetAndroid.send(analogRead(1)); + //testeLeds(); +} + +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + // define an array with the appropriate size which will store the string + char comando[length]; + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + testeLeds(); +} + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=3) return; + + if(comando[0]=='F') { + dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + dance(); + } +} + + +int led_status=0; +void changeServo(int a) { + + digitalWrite(LED_RED, led_status); + led_status = led_status==0 ? 1 : 0; +} + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Walk.pde b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Walk.pde new file mode 100644 index 0000000..7c7aa77 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Android_v2/Walk.pde @@ -0,0 +1,259 @@ +long duration, inches, cm; +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +void changeServoOK(int servoPos) { + //servoHorizontal.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + +void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} + +void Walk() { + changeServo(80); + + readPing(); + if(cm<35) { + parar(); + fullScan(); + if(getLongestPosition()<9) virarDireitaRe(500,3); + else virarEsquerdaRe(500,3); + readPing(); + while(cm<30) { + if(random(1,100)<=50) { + girarNoEixo(300,3,random(0,1)); + } + else { + andarTraz(400,3); + } + readPing(); + } + } + else if(cm>35 && cm<50) { + if(moveCount==0 || moveCount==10) { + fullScan(); + moveCount=1; + } + moveCount++; + if(getLongestPosition()<9) virarDireita(200,3); + else virarEsquerda(200,3); + } + else { + andarFrente(300,3); + moveCount++; + } + + +} + +void processPing() { + if(cm<20) { + contaFrente=0; + parar(); + int contaGiro=0; + while(cm<20 && contaGiro++<10) { + girarNoEixo(random(200,500),3,random(0,1)); + readPing(); + } + if(cm<20) { + andarTraz(1,3); + if(random(0,1)) { + virarDireita(random(500,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(500,random(200,400)),random(2,4)); + } + } + } + else if(cm>20 && cm<45) { + int cmAnterior=cm; + //parar(); + /*int tenta=0; + while(cmAnteriorcmAnterior) { + while(cm>cmAnterior) { + virarDireita(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + else { + virarEsquerda(random(50,120),random(2,4)); + int cmAnterior=cm; + if(cm>cmAnterior) { + while(cm>cmAnterior) { + virarEsquerda(50,2); + cmAnterior=cm; + readPing(); + } + } + + } + + } + else { + contaFrente++; + andarFrente(50,cm<100 ?2 : cm>100 && cm<150 ? 3 : 4); + } + if(contaFrente>30) { + contaFrente=0; + andarTraz(random(150,450),3); + if(random(0,1)) { + virarDireita(random(150,random(200,400)),random(2,4)); + } + else { + virarEsquerda(random(150,random(200,400)),random(2,4)); + } + + } +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + +void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Globalcode/AtualizarDisplay.pde b/arduino/all the sketchs of my life/Robotica/Robo_Globalcode/AtualizarDisplay.pde new file mode 100644 index 0000000..2d2d3b3 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Globalcode/AtualizarDisplay.pde @@ -0,0 +1,46 @@ +void atualizaDisplay() { + lcd.clear(); + + //atualiza temperatura + //lcd.setCursor(col,row); + lcd.setCursor(8,1); + lcd.print(analogRead(SensorTemperatura)/2); + lcd.print("oC"); + + Serial.print("Temperatura= "); + Serial.println(analogRead(SensorTemperatura)/2); + + //atualiza luminosidade + //lcd.setCursor(col,row); + lcd.setCursor(0,1); + lcd.print(map((analogRead(LDR)), 0, 1023, 100,0)); + lcd.print(" %"); + + Serial.print("Luminosidade= "); + Serial.println(map((analogRead(LDR)), 0, 1023, 100,0)); + Serial.println(" "); + + + //lcd.setCursor(col,row); + lcd.setCursor(0,0); + lcd.print(DistanciaEsquerda); + lcd.print(" cms"); + + //atualiza distancia esquerda + Serial.print("Distancia Esquerda= "); + Serial.println(DistanciaEsquerda); + + //atualiza distancia direita + //lcd.setCursor(col,row); + lcd.setCursor(8,0); + lcd.print(DistanciaDireita); + lcd.print(" cms"); + + Serial.print("Distancia Direita= "); + Serial.println(DistanciaDireita); + + + +} + + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Globalcode/LerDistancias.pde b/arduino/all the sketchs of my life/Robotica/Robo_Globalcode/LerDistancias.pde new file mode 100644 index 0000000..c7ae0e5 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Globalcode/LerDistancias.pde @@ -0,0 +1,31 @@ +void LerDistancias ( ){ + //posiciona cursor para leitura esquerda + ServoV.write(135); + delay(150); // waits 15ms for the servo to reach the position + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + long duration = pulseIn(PING_PIN, HIGH); + DistanciaEsquerda = duration / 29 / 2; + + + //posiciona cursor para leitura direita + ServoV.write(45); + delay(150); // waits 15ms for the servo to reach the position + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + DistanciaDireita = duration / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Globalcode/Movimentos.pde b/arduino/all the sketchs of my life/Robotica/Robo_Globalcode/Movimentos.pde new file mode 100644 index 0000000..c3dfe4e --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Globalcode/Movimentos.pde @@ -0,0 +1,62 @@ +void girarNoEixo(int intensidade) { + long sentido1 = random(0,2); + if (sentido1 < 1){ + sentido1=0; + } + else { + sentido1=1; + } + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + +void andarTraz(int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + +void virarEsquerda(int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + +void virarDireita(int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + + + + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Globalcode/Robo_Globalcode.pde b/arduino/all the sketchs of my life/Robotica/Robo_Globalcode/Robo_Globalcode.pde new file mode 100644 index 0000000..849fd72 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Globalcode/Robo_Globalcode.pde @@ -0,0 +1,65 @@ +#include +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 5 +#define PING_PIN 16 +int SensorTemperatura = 1 ; +int LDR = 5; + +//LiquidCrystal lcd(RS, EN, D4, D5, D6, D7); +LiquidCrystal lcd(14, 17, 4, 3, 2, 18); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo ServoV; +Servo ServoH; + +int sentido; + +void setup() { + Serial.begin(9600); + + // set up the LCD's number of rows and columns: + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void loop() { + LerDistancias( ); + + if (DistanciaEsquerda > 40 && DistanciaDireita > 40) { + andarFrente(2); + } + + if (DistanciaEsquerda <= 40 && DistanciaDireita > 40) { + virarDireita(2); + } + + if (DistanciaEsquerda > 40 && DistanciaDireita <= 40) { + virarEsquerda(2); + } + + if (DistanciaEsquerda <= 40 && DistanciaDireita <= 40) { + parar(); + girarNoEixo(2); + } + + atualizaDisplay(); + delay (100); + +} + + + + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Me_Tamiya/Movimentos.pde b/arduino/all the sketchs of my life/Robotica/Robo_Me_Tamiya/Movimentos.pde new file mode 100644 index 0000000..6833127 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Me_Tamiya/Movimentos.pde @@ -0,0 +1,56 @@ +void girarNoEixo(int intensidade, long sentido1) { + + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + +void andarTraz(int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + +void virarEsquerda(int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + +void virarDireita(int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); +} + + + + diff --git a/arduino/all the sketchs of my life/Robotica/Robo_Me_Tamiya/Robo_Me_Tamiya.pde b/arduino/all the sketchs of my life/Robotica/Robo_Me_Tamiya/Robo_Me_Tamiya.pde new file mode 100644 index 0000000..92ab5c7 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Robo_Me_Tamiya/Robo_Me_Tamiya.pde @@ -0,0 +1,109 @@ +#include +#include + +#define MOTOR1_P 10 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 5 +#define PING_PIN 14 +int SensorTemperatura = 1 ; +int LDR = 5; + + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo ServoV; +Servo ServoH; + +int sentido; + +void setup() { + Serial.begin(9600); + + // set up the LCD's number of rows and columns: + + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void lerPing() { + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + long duration = pulseIn(PING_PIN, HIGH); + + distancia= duration / 29 / 2; + Serial.print("Distancia: "); + Serial.println(distancia); + +} + +void loop() { + lerPing(); + + while(distancia>25) { + andarFrente(5); + delay(50); + lerPing(); + } + int delaying = 350; + while(distancia>15 && distancia<25) { + long d1 = distancia; + girarNoEixo(5,0); + delay(delaying); + lerPing(); + long d2 = distancia; + girarNoEixo(5,1); + delay(delaying*2); + parar(); + lerPing(); + long d3 = distancia; + + //voltando posiço original + girarNoEixo(5,0); + delay(delaying); + parar(); + //tomando decisao.. + + if(d1>d2 && d1>d3) { + //nem para um lado nem para outro funcionou... + delaying+=100; + } + else { + if(d2>d3) { + girarNoEixo(5,0); + delay(delaying); + } + else { + girarNoEixo(5,1); + delay(delaying); + } + andarFrente(5); + delay(250); + } + } + while(distancia>5 && distancia<15) { + girarNoEixo(5, random(10)%2==0); + delay(300 + random(200,400)); + lerPing(); + } +} + + + + + + + diff --git a/arduino/all the sketchs of my life/Robotica/ServoRobot/ServoRobot.pde b/arduino/all the sketchs of my life/Robotica/ServoRobot/ServoRobot.pde new file mode 100644 index 0000000..8c941f9 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/ServoRobot/ServoRobot.pde @@ -0,0 +1,42 @@ +// Controlling a servo position using a potentiometer (variable resistor) +// by Michal Rinott + +#include + +Servo myservo; // create servo object to control a servo +Servo myservo1; // create servo object to control a servo + +int potpin = 1; // analog pin used to connect the potentiometer +int val; // variable to read the value from the analog pin + +void setup() +{ + Serial.begin(9600); + myservo.attach(10); // attaches the servo on pin 9 to the servo object + myservo1.attach(11); // attaches the servo on pin 9 to the servo object +} + +void loop() +{ + if(Serial.available()>0) { + + while(Serial.available()>0) { + + int dado = int(Serial.read()); + Serial.println(dado,DEC); + myservo.write(dado); + int dado1 = int(Serial.read()); + Serial.println(dado1,DEC); + myservo1.write(dado1); + + } + } + + val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) + //Serial.println(val); + val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) + //myservo.write(analogRead(1)/4); // sets the servo position according to the scaled value + //myservo1.write(analogRead(2)/4); // sets the servo position according to the scaled value + delay(10); // waits for the servo to get there +} + diff --git a/arduino/all the sketchs of my life/Robotica/Shield_BRoBot/Demo.pde b/arduino/all the sketchs of my life/Robotica/Shield_BRoBot/Demo.pde new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Shield_BRoBot/Demo.pde @@ -0,0 +1 @@ + diff --git a/arduino/all the sketchs of my life/Robotica/Shield_BRoBot/Shield_BRoBot.pde b/arduino/all the sketchs of my life/Robotica/Shield_BRoBot/Shield_BRoBot.pde new file mode 100644 index 0000000..8dbe512 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Shield_BRoBot/Shield_BRoBot.pde @@ -0,0 +1,167 @@ +#include +#include +//#include +#define MOTOR1_P 11 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 + +#define MOTOR2_P 7 +#define MOTOR2_N 8 +#define MOTOR2_PWM 6 +// LCD 0, 1 ,14, 17, 18, 19 +// Trasmissor 12 +// Receptor 13 +// Motor 4, 5, 6, 7, 8 e 9 + +// Em uso 0 1 4 5 6 7 8 9 12 13 14 17 18 19 +// Livre 2 3 10 11 15 16 +int valor_anterior = -1;ds +int erro =0; +int recebidos = 0; +int i = 0; +char comando[16]; + + +uint8_t buf[VW_MAX_MESSAGE_LEN]; +uint8_t buflen = VW_MAX_MESSAGE_LEN; +char string[16]; + +LiquidCrystal lcd(14, 17, 4, 3, 2, 18); + +int estado = 0; +int sentido = 0; +long duration, inches, cm; +int reacao = 0; +int interrupt=0; +int mode=0; +//Servo myservo10; // create servo object to control a servo +#define COMANDO_TAMANHO 16 +const char FRENTE[COMANDO_TAMANHO] = "FRENTE "; +const char RE[COMANDO_TAMANHO] = "RE "; +const char ESQUERDA[COMANDO_TAMANHO] = "ESQUERDA "; +const char DIREITA[COMANDO_TAMANHO] = "DIREITA "; + +void setup() { + + setupEngines(); + //setupReceptorRF(); + setupLCD(); + + //myservo10.attach(10); // attaches the servo on pin 10 to the servo object + Serial.begin(115200); + + +} +void setupReceptorRF() { + + pinMode(3, OUTPUT); + //pinMode(11, INPUT); + digitalWrite(3, LOW); + + // Initialise the IO and ISR + + //Configura o Receptor + vw_set_rx_pin (3); //Pino que recebe os dados + vw_setup(2000); // Bits per sec + vw_rx_start(); // Start the receiver PLL running + + //Configura o Transmissor + //vw_set_tx_pin(12); //Pino de transmissao de dados + //vw_setup(2000); // Bits per sec + +} +void setupLCD() { + // set up the LCD's number of rows and columns: + lcd.begin(16, 2); + initLCD(); +} +void initLCD() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("BRoBot:"); + lcd.setCursor(0, 1); + lcd.print("Aguardando...."); +} +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + //andarFrente(2000,3); + parar(); +} + +void loop(){ + + uint8_t buf[VW_MAX_MESSAGE_LEN]; + uint8_t buflen = VW_MAX_MESSAGE_LEN; + int ii; + for(ii=0;ii0) { + while(Serial.available()>0) { + string[ii]=Serial.read(); + delay(20); + ii++; + } + lcd.clear(); + lcd.print(string); + delay(2000); + initLCD(); + + } + + + /*if (vw_get_message(buf, &buflen)) // Non-blocking + { + int i; + lcd.setCursor(0, 1); + lcd.clear(); + limpaComando(); + for (i = 0; i < buflen; i++) + { + comando[i]=buf[i]; + } + lcd.print(comando); + Serial.println(comando); + + if(strcmp(comando, FRENTE)==0) { + lcd.setCursor(0,2); + lcd.print("andando..."); + + andarFrente(2000,5); + parar(); + } + + else if(strcmp(comando, RE)==0) { + andarTraz(2000,5); + parar(); + } + if(strcmp(comando, DIREITA)==0) { + virarDireita(2000,5); + parar(); + } + if(strcmp(comando, ESQUERDA)==0) { + virarEsquerda(2000,5); + parar(); + } + + }*/ +} +void limpaComando() { + for(int x=0;x<15;x++) { + comando[x]=' '; + } +} + + + + + + + + diff --git a/arduino/all the sketchs of my life/Robotica/Shield_BRoBot/Walk.pde b/arduino/all the sketchs of my life/Robotica/Shield_BRoBot/Walk.pde new file mode 100644 index 0000000..9819fc1 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Shield_BRoBot/Walk.pde @@ -0,0 +1,147 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + +int move_history[128]; +int moveCount = 0; +int contaFrente= 0; +boolean pressEsquerda = false; +boolean pressDireita = false; +int servoPos =0; +byte distanceArray[18]; +byte pscan=0; +byte frontRead=17; +boolean initScan=false; +int longestPos=0; +int distanceLongestPos = 0; +int distanceLongestPosCorrect = 0; + +/*void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +}*/ + +/*void fullScan() { + for(byte x=0;x<18;x++){ + changeServo(x*10); + Serial.print("Servo pos:"); + Serial.println(x*10); + readPing(); + distanceArray[x]=cm; + } + changeServo(90); +} */ + +byte getLongestPosition() { + byte value = 0; + int bigValue=0; + for(byte x=0;x<18;x++) { + if(distanceArray[x]>bigValue) { + value=x; + bigValue=distanceArray[x]; + } + } + return value; +} +/*void partialScan() { + changeServo(pscan*10); + readPing(); + distanceArray[pscan]=cm; + if(++pscan==18) pscan=0; +} +*/ + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void readPress() { + pressEsquerda = !analogRead(PRESS_ESQUERDA)==0; + pressDireita = !analogRead(PRESS_DIREITA)==0; + +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + + +/*void readPing() +{ + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm); +}*/ + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/Robotica/Shield_TransmissorRF/Shield_TransmissorRF.pde b/arduino/all the sketchs of my life/Robotica/Shield_TransmissorRF/Shield_TransmissorRF.pde new file mode 100644 index 0000000..8ba23ce --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/Shield_TransmissorRF/Shield_TransmissorRF.pde @@ -0,0 +1,22 @@ +#include + +void setup() +{ + Serial.begin(9600); + pinMode(3, OUTPUT); + vw_set_tx_pin(3); + vw_setup(2000); +} + +void loop() +{ + char c[3]; + int counter = 0; + for(int x=0;x<300;x++) { + itoa(x,c,10); + Serial.println(c); + vw_send((uint8_t *) c,strlen(c)); + delay(500); + } +} + diff --git a/arduino/all the sketchs of my life/Robotica/SunSpotBot/SunSpot.pde b/arduino/all the sketchs of my life/Robotica/SunSpotBot/SunSpot.pde new file mode 100644 index 0000000..9481ff8 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/SunSpotBot/SunSpot.pde @@ -0,0 +1,110 @@ +#define SUN_SPOT 4 +#define SUN_SPOT_ACK 11 +#define SUN_SPOT_INTERRUPT 0 //PORTA digital 2 + +volatile int data; +volatile boolean bit_array[16]; +volatile int contador; +int x; +int y; + +void setupSunSpot() { + attachInterrupt(0, receiveSunSpot, RISING); + pinMode(SUN_SPOT,INPUT); + pinMode(SUN_SPOT_ACK,OUTPUT); +} + +void SunSpot() { + if(x==0 && y==0) { + analogWrite(MOTOR1_PWM,0); + analogWrite(MOTOR2_PWM,0); + return; + } + if(y>0) sentido = 0; //Para FRENTE + else if(y<0) sentido = 1;// Para Traz + //Configurando o sentido do trem.. quero dizer do robot + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + + if(y!=0 && x!=0) { //Curva frente ou traz... + int coeficientePotencia = map(x<0 ? x*-1 : x,0,30,0,255); + analogWrite(MOTOR1_PWM, x< 0 ? coeficientePotencia : coeficientePotencia/2); + analogWrite(MOTOR2_PWM, x< 0 ? coeficientePotencia/2 : coeficientePotencia); + } + else { //reto + analogWrite(MOTOR1_PWM,map(y<0 ? y*-1 : y,0,30,100,200)); + analogWrite(MOTOR2_PWM,map(y<0 ? y*-1 : y,0,30,100,200)); + } + //Girando no eixo + if(y==0 && x!=0) { + sentido = x<0; + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_N,sentido); + if(x>0) { + Serial.print("Girando x>0"); + Serial.println(map(x,0,30,40,255)); + analogWrite(MOTOR1_PWM, map(x,0,30,40,255) ); + analogWrite(MOTOR2_PWM , map(x,0,30,40,255) ); + } + else { + Serial.print("Girando <0"); + Serial.println(map(x>0 ? x : x*-1,0,30,40,255)); + + analogWrite(MOTOR2_PWM, map(x*-1,0,30,40,255) ); + analogWrite(MOTOR1_PWM, map(x*-1,0,30,40,255) ); + } + } + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + delay(200); +} + +void receiveSunSpot() { + digitalWrite(SUN_SPOT_ACK,LOW); + bit_array[contador++]=digitalRead(SUN_SPOT); + digitalWrite(SUN_SPOT_ACK,HIGH); + + if(contador==16) { + Serial.println("Chegou Novos 2 bytes"); + contador=0; + x = BtoI(0,7,bit_array); + + y = BtoI(8,15,bit_array); + Serial.print("x = "); + Serial.println(x); + Serial.print("y = "); + Serial.println(y); + + for(int clean=0;clean<16;clean++) bit_array[clean]=false; + + } +} + +int BtoI(int start,int end, volatile boolean bits[]){ + boolean negative=bits[start]; + start++; + unsigned long integer=0; + unsigned long mask=1; + int r; + for (int i = end; i >= start; i--) { + if(negative) { + if (!bits[i]) integer |= mask; + } + else { + if (bits[i]) integer |= mask; + } + mask = mask << 1; + } + r = (int) integer; + if(negative) r= ~r; + return r; +} + + diff --git a/arduino/all the sketchs of my life/Robotica/SunSpotBot/SunSpotBot.pde b/arduino/all the sketchs of my life/Robotica/SunSpotBot/SunSpotBot.pde new file mode 100644 index 0000000..a7941bd --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/SunSpotBot/SunSpotBot.pde @@ -0,0 +1,52 @@ +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 + +int sentido = 0; + +void setup() { + Serial.begin(9600); + Serial.println("Setup feito"); + + setupSunSpot(); + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + +} + +void loop() { + //Serial.println("aaa"); + SunSpot(); + //Serial.println("BBB"); + //meetAndroid.receive(); + //meetAndroid.send(analogRead(1)); + //testeLeds(); + /*andarFrente(1500,3); + parar(); + delay(1500); + andarTraz(1500,3); + parar(); + delay(1500); + girarNoEixo(1500,3,0); + parar(); + delay(1500); + girarNoEixo(1500,3,1); + parar(); + delay(1500); + */ + +} + diff --git a/arduino/all the sketchs of my life/Robotica/SunSpotBot/Walk.pde b/arduino/all the sketchs of my life/Robotica/SunSpotBot/Walk.pde new file mode 100644 index 0000000..75a8331 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/SunSpotBot/Walk.pde @@ -0,0 +1,88 @@ +#define DIRECAO_FRENTE 0 +#define DIRECAO_FRENTE_ESQUERDA 1 +#define DIRECAO_FRENTE_DIREITA 2 +#define DIRECAO_TRAZ 3 +#define DIRECAO_TRAZ_ESQUERDA 4 +#define DIRECAO_TRAZ_DIREITA 5 +#define DIRECAO_PARADO 6 +#define PRESS_ESQUERDA 0 +#define PRESS_DIREITA 2 + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,!sentido); + digitalWrite(MOTOR1_N,sentido); + digitalWrite(MOTOR2_P,!sentido); + digitalWrite(MOTOR2_N,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/Robotica/br1_danca/Demo.pde b/arduino/all the sketchs of my life/Robotica/br1_danca/Demo.pde new file mode 100644 index 0000000..541d53a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br1_danca/Demo.pde @@ -0,0 +1,194 @@ +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/Robotica/br1_danca/SunSpot.pde b/arduino/all the sketchs of my life/Robotica/br1_danca/SunSpot.pde new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br1_danca/SunSpot.pde @@ -0,0 +1 @@ + diff --git a/arduino/all the sketchs of my life/Robotica/br1_danca/Walk.pde b/arduino/all the sketchs of my life/Robotica/br1_danca/Walk.pde new file mode 100644 index 0000000..6d49a4a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br1_danca/Walk.pde @@ -0,0 +1,63 @@ +int sentido=0; + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + diff --git a/arduino/all the sketchs of my life/Robotica/br1_danca/br1_danca.pde b/arduino/all the sketchs of my life/Robotica/br1_danca/br1_danca.pde new file mode 100644 index 0000000..43ab1e6 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br1_danca/br1_danca.pde @@ -0,0 +1,33 @@ +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 9 +#define MOTOR1_PWM 6 + +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 5 +#define SERVO_1 11 + +Servo myservo10; // create servo object to control a servo + + +void setup() { + setupEngines(); + myservo10.attach(SERVO_1); // attaches the servo on pin 10 to the servo object + Serial.begin(9600); +} + +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void loop(){ + Demo(); +} + diff --git a/arduino/all the sketchs of my life/Robotica/br1_danca_ok/Demo.pde b/arduino/all the sketchs of my life/Robotica/br1_danca_ok/Demo.pde new file mode 100644 index 0000000..541d53a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br1_danca_ok/Demo.pde @@ -0,0 +1,194 @@ +/* +1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + 15' 17' 18' + Oooolha o teste, to implantando, to implantando + 19' 20.5 23' 26' + E Am E Am + Estou esperando release, vai ficar muito mais easy + 27.8' 30' + +28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36' + G F + J� estou penando aqui + 38' 41' + C E Am + Fa�o o download de um jar grand�o, mas tamb�m n�o 42' + funciona n�o + 43' 45' 48' + Chamo o arquiteto bacan�o, mas no fundo � um man�z�o + 49.5' + G F C + Olha o budget, ce ta gastando, ce gastando + Olha o prazo, ce ta furando, ce ta furando + E Am + N�o me sinto up-to-date, eu estou � �deprecate� + */ + + +void Demo() { + + /*1.5' 3.2' + C E Am + Fa�o c�digo como c�o;Maldito bug, que n�o encontro n�o; + 5.5' 8' com breque + Vem o prazo e o chef�o, o redeploy n�o da certo n�o; + */ + delay(1500); + andarFrente(1700,4); + andarTraz(2300,4); + girarNoEixo(2000,3,1); + andarTraz(1500,4); + parar(); + delay(1500); + + /* 10' 13' + G F C + Ooooolha o prazo, ta demorando, ta demorando + */ + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + andarFrente(2000,4); + parar(); + + /* 15' 17' 18' + Oooolha o teste, to implantando, to implantando + */ + changeServo(180); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + delay(1000); + + /* 19' 20.5 23' 27' + E Am E Am + Estou esperando release, vai ficar muito mais easy + */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + +/*28' 30' 31' + G F C + Se voc� come�a de novo, um bug novo, um bug novo + 32' 34' 35' + Estou implorando socorro, pro bug novo, pro bug novo + 36'*/ + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + + /* Ja estou penando aqui */ + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1500); + + /* Faco download de um jar grandao */ + andarFrente(1700,4); + /* Mas tamb�m n�o funciona n�o */ + andarTraz(2300,4); + /*Chamo o arquiteto bacanao */ + girarNoEixo(2000,3,1); + /*Mas no fundo � um manezao */ + andarTraz(2000,4); + + parar(); + delay(2000); + + /* Olha o budget */ + girarNoEixo(2000,3,0); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + delay(1000); + changeServo(90); + /* Olha o prazo */ + girarNoEixo(2000,3,1); + changeServo(180); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(1000); + + /* Nao me sinto uptodate, eu estou deprecated */ + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(1000); + changeServo(90); + delay(1000); + changeServo(0); + changeServo(90); + + + girarNoEixo(3000,3,1); + parar(); + girarNoEixo(3000,3,0); + parar(); + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(1000); + andarFrente(2000,3); + parar(); + andarTraz(2000,3); + parar(); + + changeServo(180); + delay(500); + changeServo(90); + delay(500); + changeServo(0); + delay(500); + changeServo(90); + delay(200000000); + +} + + diff --git a/arduino/all the sketchs of my life/Robotica/br1_danca_ok/SunSpot.pde b/arduino/all the sketchs of my life/Robotica/br1_danca_ok/SunSpot.pde new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br1_danca_ok/SunSpot.pde @@ -0,0 +1 @@ + diff --git a/arduino/all the sketchs of my life/Robotica/br1_danca_ok/Walk.pde b/arduino/all the sketchs of my life/Robotica/br1_danca_ok/Walk.pde new file mode 100644 index 0000000..6d49a4a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br1_danca_ok/Walk.pde @@ -0,0 +1,63 @@ +int sentido=0; + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void changeServo(int servoPos) { + myservo10.write(servoPos); // sets the servo position according to the scaled value + delay(15); +} + diff --git a/arduino/all the sketchs of my life/Robotica/br1_danca_ok/br1_danca_ok.pde b/arduino/all the sketchs of my life/Robotica/br1_danca_ok/br1_danca_ok.pde new file mode 100644 index 0000000..8254f4d --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br1_danca_ok/br1_danca_ok.pde @@ -0,0 +1,36 @@ +#include + +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +#define PING_PIN 1 +#define LED_RED 9 +#define LED_BLUE 17 +#define LED_GREEN 18 +#define SERVO_1 11 + +Servo myservo10; // create servo object to control a servo + + +void setup() { + setupEngines(); + myservo10.attach(SERVO_1); // attaches the servo on pin 10 to the servo object + Serial.begin(9600); +} + +void setupEngines() { + pinMode(MOTOR1_P, OUTPUT); + pinMode(MOTOR1_N, OUTPUT); + pinMode(MOTOR2_P, OUTPUT); + pinMode(MOTOR2_N, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void loop(){ + Demo(); +} + diff --git a/arduino/all the sketchs of my life/Robotica/br2_android/Android.pde b/arduino/all the sketchs of my life/Robotica/br2_android/Android.pde new file mode 100644 index 0000000..38464f1 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br2_android/Android.pde @@ -0,0 +1,105 @@ +void acelera(byte flag, byte numOfValues) { + meetAndroid.getFloatValues(acelerometro); + if(modo!=ACELEROMETRO) return; + servoV.write(map(acelerometro[0],-10,10,0,180)); + servoH.write(map(acelerometro[1],-10,10,0,180)); + + if(acelerometro[0]>-3 && acelerometro[0]<3) { + + if(acelerometro[1]<3) { + andarTraz(200,map(acelerometro[1],-3,-10,1,5)); + } + else if(acelerometro[1]>3) { + andarFrente(200,map(acelerometro[1],3,10,1,5)); + } + else if(acelerometro[1]>-3 && acelerometro[1]<3) { + parar(); + } + } + else if(acelerometro[0]<-3) { //para esquerda + if(acelerometro[1]>-3 && acelerometro[1]<3) { //esquerda no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),1); + } + else { + virarEsquerda(200,2); + } + } + else if(acelerometro[0]>3) { //para direita + if(acelerometro[1]>-3 && acelerometro[1]<3) { //direita no eixo + girarNoEixo(200, map(acelerometro[0],-3,-10,1,5),0); + } + else { + virarDireita(200,2); + } + } + +} + + + +void andar(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + char comando[length]; + meetAndroid.getString(comando); + if(modo!=ANDAR) return; + + if(comando[0]=='F') { + //dance(); + parar(); + } + else if(comando[0]=='R') { + andarTraz(1000,3); + parar(); + } + else if(comando[0]=='G') { + girarNoEixo(1000,3,0); + parar(); + } + else if(comando[0]=='D') { + //dance(); + } +} + +void dedoDuro(byte flag, byte numOfValues) { + state = meetAndroid.getInt(); + if(modo!=DEDO_DURO) return; + + if(state==0) { + for(int x=0;x<3;x++) { + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + girarNoEixo(200,2,0); + girarNoEixo(200,2,1); + parar(); + //testeLeds(); + } + } +} + +void encontraNorte(byte flag, byte numOfValues) { + bussola = meetAndroid.getInt(); + if(modo!=ENCONTRAR_NORTE) return; + //if(bussola>180) analogWrite(LED_RED, map(bussola, 180, 360, 0,255)); + //else analogWrite(LED_RED, map(bussola, 180, 0, 0,255)); + if(bussola>350 && bussola<360) { + girarNoEixo(80,1,1); + parar(); + } + else if(bussola>180 && bussola<350) { + girarNoEixo(200,1,1); + parar(); + } + else if(bussola>15 && bussola<180) { + girarNoEixo(200,1,0); + parar(); + } + else if(bussola>3 && bussola<15) { + girarNoEixo(80,1,0); + parar(); + } + else if(bussola>0 && bussola<3) { + parar(); + } +} + + diff --git a/arduino/all the sketchs of my life/Robotica/br2_android/Motores.pde b/arduino/all the sketchs of my life/Robotica/br2_android/Motores.pde new file mode 100644 index 0000000..30330d3 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br2_android/Motores.pde @@ -0,0 +1,95 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + + +int sentido=0; +void setupMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/Robotica/br2_android/SeguidorLinha.pde b/arduino/all the sketchs of my life/Robotica/br2_android/SeguidorLinha.pde new file mode 100644 index 0000000..1677f85 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br2_android/SeguidorLinha.pde @@ -0,0 +1,135 @@ +#include + +#define NUM_SENSORS 3 // number of sensors used +#define TIMEOUT 2500 // waits for 2500 us for sensor outputs to go low +#define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2 +unsigned int last_proportional = 0; +long integral = 0; + +// sensores 1 a 5 estao conectados nas portas digitais 5, 9, 2, 3 e 4, respectivamente +//PololuQTRSensorsRC qtrrc((unsigned char[]) {5, 9, 2, 3, 4}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); +PololuQTRSensorsRC qtrrc((unsigned char[]) {5, 9, 2}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); +unsigned int sensorValues[NUM_SENSORS]; + + +void calibrarSensorDeLinha() { + int i; + // Auto-calibration: turn right and left while calibrating the sensors. + for (i = 0; i < 155; i++) { // make the calibration take about 10 seconds + if (i < 40 || i > 110) + setSpeeds(50, -50); + else + setSpeeds(-50, 50); + qtrrc.calibrate(); // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call) + } + setSpeeds(0, 0); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMinimumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMaximumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + //Serial.println(); + calibrado=true; +} + +void seguirLinha() { + if(!calibrado) calibrarSensorDeLinha(); + if(modo!=SEGUIR_LINHA) return; + unsigned int position = qtrrc.readLine(sensorValues); // Get the position of the line. + int proportional = (int)position - 2000;// The "proportional" term should be 0 when we are on the line. + int derivative = proportional - last_proportional; // Compute the derivative (change) of the position. + integral += proportional; // Compute the integral (sum) of the position. + last_proportional = proportional; // Remember the last position. + + // Compute the difference between the two motor power settings, + // m1 - m2. If this is a positive number the robot will turn + // to the right. If it is a negative number, the robot will + // turn to the left, and the magnitude of the number determines + // the sharpness of the turn. You can adjust the constants by which + // the proportional, integral, and derivative terms are multiplied to + // improve performance. + int power_difference = proportional/20 + integral/10000 + derivative*3/2; + + // Compute the actual motor settings. We never set either motor + // to a negative value. + const int maximum = 60; + if (power_difference > maximum) + power_difference = maximum; + if (power_difference < -maximum) + power_difference = -maximum; + // Serial.print("power diference: "); + // Serial.println(power_difference); + //setSpeeds(70,70); + if (power_difference < 0){ + setSpeeds(maximum + power_difference, maximum); + // Serial.print("motores: "); + // Serial.println(maximum + power_difference); + // Serial.print(" : "); + // Serial.println(maximum); + } + else{ + setSpeeds(maximum, maximum - power_difference); + // Serial.print("motores: "); + // Serial.print(maximum); + // Serial.print(" : "); + // Serial.println(maximum - power_difference); + // Serial.println(" "); + } + if(DEBUG_LIGADO) { + Serial.print("position: "); + Serial.println(position); + delay(10); + Serial.println("sensor values: "); + for(int x=0;x 0){ + digitalWrite(MOTOR1_control_A,HIGH); + digitalWrite(MOTOR1_control_B,LOW); + } + else { + digitalWrite(MOTOR1_control_A,LOW); + digitalWrite(MOTOR1_control_B,HIGH); + } + if (M2 > 0){ + digitalWrite(MOTOR2_control_A,HIGH); + digitalWrite(MOTOR2_control_B,LOW); + } + else { + digitalWrite(MOTOR2_control_A,LOW); + digitalWrite(MOTOR2_control_B,HIGH); + } + analogWrite(MOTOR1_PWM,abs(M1) ); + analogWrite(MOTOR2_PWM,abs(M2) ); +} + + + + + diff --git a/arduino/all the sketchs of my life/Robotica/br2_android/br2_android.pde b/arduino/all the sketchs of my life/Robotica/br2_android/br2_android.pde new file mode 100644 index 0000000..49642b2 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br2_android/br2_android.pde @@ -0,0 +1,125 @@ +#include +#include +#include + +MeetAndroid meetAndroid; +boolean DEBUG_LIGADO = false; + +int modo=1; +boolean calibrado = false; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; + +Servo servoV; +Servo servoH; + +#define IDLE 0 +#define DEDO_DURO 1 +#define ENCONTRAR_NORTE 2 +#define ANDAR 3 +#define ACELEROMETRO 4 +#define SEGUIR_LINHA 5 + +void setup(){ + setupMotor(); + delay(500); + Serial.begin(115200); + meetAndroid.setSerial(&Serial); + meetAndroid.registerFunction(dedoDuro, 'A'); + meetAndroid.registerFunction(encontraNorte, 'B'); + meetAndroid.registerFunction(acelera, 'C'); + meetAndroid.registerFunction(mudarModo, 'M'); + meetAndroid.registerFunction(andar, 'W'); + modo=IDLE; +} + +void loop(){ + meetAndroid.receive(); + delay(50); + if(modo==SEGUIR_LINHA) seguirLinha2(); + if(modo==IDLE) modoZero(); + +} +int direita; +int centro; +int esquerda; + +void ler() { + direita = RCtime(5); + centro = RCtime(9); + esquerda = RCtime(2); +} +void seguirLinha2() { + andarFrente(0,2); + ler(); + while(esquerda<400 && direita<400 && centro>400) { + setSpeeds(60,60); + ler(); + } + while(esquerda>400 && direita<400 && centro<400) { //esquerda na faixa + parar(); + girarNoEixo(200, 1, 0); + parar(); + ler(); + } + while(direita>400 && esquerda<400 && centro<400) { + parar(); + girarNoEixo(200, 1, 1); + parar(); + ler(); + } + while(direita<400 && esquerda<400 && centro<400) { + parar(); + girarNoEixo(200, 1, 1); + parar(); + ler(); + } + while(direita>400 && esquerda>400 && centro>400) { + parar(); + girarNoEixo(200, 1, 1); + parar(); + ler(); + } + + +} + +long RCtime(int sensPin){ + long result = 0; + pinMode(sensPin, OUTPUT); // make pin OUTPUT + digitalWrite(sensPin, HIGH); // make pin HIGH to discharge capacitor - study the schematic + delay(1); // wait a ms to make sure cap is discharged + + pinMode(sensPin, INPUT); // turn pin into an input and time till pin goes low + digitalWrite(sensPin, LOW); // turn pullups off - or it won't work + while(digitalRead(sensPin)){ // wait for pin to go low + result++; + } + + return result; // report results +} +void modoZero() { + digitalWrite(13, HIGH); + delay(1000); + digitalWrite(13, LOW); + delay(1000); +} + +void mudarModo(byte flag, byte numOfValues) { + int length = meetAndroid.stringLength(); + + // define an array with the appropriate size which will store the string + char comando[length]; + + // tell MeetAndroid to put the string into your prepared array + meetAndroid.getString(comando); + char c[1]; + c[0]=comando[0]; + modo = atoi(c); + calibrado = false; //para recalibrar quando ligar seguidor de linha novamente +} + + diff --git a/arduino/all the sketchs of my life/Robotica/br2_seguir_bluetooth/Motores.pde b/arduino/all the sketchs of my life/Robotica/br2_seguir_bluetooth/Motores.pde new file mode 100644 index 0000000..611aec0 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br2_seguir_bluetooth/Motores.pde @@ -0,0 +1,78 @@ +int sentido=0; + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + diff --git a/arduino/all the sketchs of my life/Robotica/br2_seguir_bluetooth/SeguidorLinha.pde b/arduino/all the sketchs of my life/Robotica/br2_seguir_bluetooth/SeguidorLinha.pde new file mode 100644 index 0000000..f7bc750 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br2_seguir_bluetooth/SeguidorLinha.pde @@ -0,0 +1,117 @@ +void calibrarSensorDeLinha() { + int i; + // Auto-calibration: turn right and left while calibrating the sensors. + for (i = 0; i < 155; i++) { // make the calibration take about 10 seconds + if (i < 40 || i > 110) + setSpeeds(60, -60); + else + setSpeeds(-60, 60); + qtrrc.calibrate(); // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call) + } + setSpeeds(0, 0); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMinimumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + for (i = 0; i < NUM_SENSORS; i++){ + //Serial.print(qtrrc.calibratedMaximumOn[i]); + //Serial.print(' '); + } + //Serial.println(); + //Serial.println(); + calibrado=true; +} + +void seguirLinha() { + if(!calibrado) calibrarSensorDeLinha(); + if(modo!=9) return; + unsigned int position = qtrrc.readLine(sensorValues); // Get the position of the line. + int proportional = (int)position - 2000;// The "proportional" term should be 0 when we are on the line. + //Serial.print("proportional: "); + //Serial.println(proportional); + int derivative = proportional - last_proportional; // Compute the derivative (change) of the position. + //Serial.print("derivative: "); + //Serial.println(derivative); + integral += proportional; // Compute the integral (sum) of the position. + //Serial.print("integral: "); + //Serial.println(integral); + last_proportional = proportional; // Remember the last position. + + // Compute the difference between the two motor power settings, + // m1 - m2. If this is a positive number the robot will turn + // to the right. If it is a negative number, the robot will + // turn to the left, and the magnitude of the number determines + // the sharpness of the turn. You can adjust the constants by which + // the proportional, integral, and derivative terms are multiplied to + // improve performance. + int power_difference = proportional/20 + integral/10000 + derivative*3/2; + + // Compute the actual motor settings. We never set either motor + // to a negative value. + const int maximum = 120; + if (power_difference > maximum) + power_difference = maximum; + if (power_difference < -maximum) + power_difference = -maximum; + // Serial.print("power diference: "); + // Serial.println(power_difference); + //setSpeeds(70,70); + if (power_difference < 0){ + setSpeeds(maximum + power_difference, maximum); + // Serial.print("motores: "); + // Serial.println(maximum + power_difference); + // Serial.print(" : "); + // Serial.println(maximum); + } + else{ + setSpeeds(maximum, maximum - power_difference); + // Serial.print("motores: "); + // Serial.print(maximum); + // Serial.print(" : "); + // Serial.println(maximum - power_difference); + // Serial.println(" "); + } + //Ler sensor distancia + //Se tiver objeto na frente, parar + //Andar um pouco pra traz + //Programacao do desvio de pista + + //delay(1000); + Serial.print("position: "); + + Serial.println(position); + Serial.println("sensor values: "); + for(int x=0;x 0){ + digitalWrite(MOTOR1_control_A,HIGH); + digitalWrite(MOTOR1_control_B,LOW); + } + else { + digitalWrite(MOTOR1_control_A,LOW); + digitalWrite(MOTOR1_control_B,HIGH); + } + if (M2 > 0){ + digitalWrite(MOTOR2_control_A,HIGH); + digitalWrite(MOTOR2_control_B,LOW); + } + else { + digitalWrite(MOTOR2_control_A,LOW); + digitalWrite(MOTOR2_control_B,HIGH); + } + analogWrite(MOTOR1_PWM,abs(M1) ); + analogWrite(MOTOR2_PWM,abs(M2) ); +} + + + + diff --git a/arduino/all the sketchs of my life/Robotica/br2_seguir_bluetooth/br2_seguir_bluetooth.pde b/arduino/all the sketchs of my life/Robotica/br2_seguir_bluetooth/br2_seguir_bluetooth.pde new file mode 100644 index 0000000..7b485f7 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/br2_seguir_bluetooth/br2_seguir_bluetooth.pde @@ -0,0 +1,72 @@ +#include +#include +#include + +#define NUM_SENSORS 5 // number of sensors used +#define TIMEOUT 2500 // waits for 2500 us for sensor outputs to go low +#define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2 + + +unsigned int last_proportional = 0; +long integral = 0; + +// sensores 1 a 5 estao conectados nas portas digitais 5, 9, 2, 3 e 4, respectivamente +PololuQTRSensorsRC qtrrc((unsigned char[]) {5, 9, 2, 3, 4}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); +unsigned int sensorValues[NUM_SENSORS]; + +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + +int modo=1; +boolean calibrado = false; +int bussola=0; +int state=1; +float acelerometro[3]; + +int contador=0; +//LiquidCrystal lcd(14, 3, 16, 17, 18, 19); + +long DistanciaEsquerda; +long DistanciaDireita; +long distancia; +Servo servoV; +Servo servoH; + +void setup(){ + delay(500); + Serial.begin(115200); + Serial.println("Heelooo"); + delay(20); + //meetAndroid.setSerial(&Serial); + //meetAndroid.registerFunction(dedoDuro, 'A'); + //meetAndroid.registerFunction(encontraNorte, 'B'); + //meetAndroid.registerFunction(acelera, 'C'); + //meetAndroid.registerFunction(mudarModo, 'M'); + + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); + modo=9; +} + int x=0; +void loop(){ + //meetAndroid.receive(); + //delay(50); + //if(modo==9) seguirLinha(); + //seguirLinha(); + + Serial.println("Heelooo" + x++); + delay(2000); + + +} + + + diff --git a/arduino/all the sketchs of my life/Robotica/jHome_Robo1/Motores.pde b/arduino/all the sketchs of my life/Robotica/jHome_Robo1/Motores.pde new file mode 100644 index 0000000..e1ab492 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/jHome_Robo1/Motores.pde @@ -0,0 +1,95 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + + +int sentido=0; +void setupMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} +void andarTras(int tempo,int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/Robotica/jHome_Robo1/jHome_Robo1.pde b/arduino/all the sketchs of my life/Robotica/jHome_Robo1/jHome_Robo1.pde new file mode 100644 index 0000000..9aa2375 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/jHome_Robo1/jHome_Robo1.pde @@ -0,0 +1,70 @@ +#define LED 6 +boolean connected; + +void setup(){ + setupMotor(); + Serial.begin(115200); +} + +void loop(){ + if(Serial.available()) receiveCommand(); + +} +void handShake() { + Serial.print("ID 2|robot|4|f|frente|t|tras|d|direita|e|esquerda"); + Serial.flush(); + + long m = millis(); + while(Serial.available()<1) { + //waiting for data + if(millis()-m>2000) { + //timeout + return; + } + } + if(Serial.available()>0) { + char c=Serial.read(); + digitalWrite(LED, true); + connected= true; + } + +} +void shutdown() { + digitalWrite(LED, false); + connected=false; +} + +void receiveCommand() { + char comando[16]; + int counter=0; + while(Serial.available()>0) // loop through all but the last + { + char c = Serial.read(); // receive byte as a character + delay(5); + comando[counter++]=c; + } + if(comando[0]=='j' || comando[0]=='J') handShake(); + if(comando[0]=='f') frente(); + if(comando[0]=='t') tras(); + if(comando[0]=='d') direita(); + if(comando[0]=='e') esquerda(); + if(comando[0]=='X') shutdown(); +} + +void frente() { + andarFrente(2000, 3); + parar(); +} +void tras() { + andarTras(2000, 3); + parar(); +} +void esquerda() { + virarEsquerda(2000, 3); + parar(); +} +void direita() { + virarDireita(2000, 3); + parar(); +} + diff --git a/arduino/all the sketchs of my life/Robotica/minicurso/Motores.ino b/arduino/all the sketchs of my life/Robotica/minicurso/Motores.ino new file mode 100644 index 0000000..768f361 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/minicurso/Motores.ino @@ -0,0 +1,97 @@ +#define MOTOR1_control_A 7 +#define MOTOR1_control_B 8 +#define MOTOR1_PWM 10 +#define MOTOR2_control_A 12 +#define MOTOR2_control_B 13 +#define MOTOR2_PWM 11 + + +int sentido=0; +void configurarMotor() { + pinMode(MOTOR1_control_A, OUTPUT); + pinMode(MOTOR1_control_B, OUTPUT); + pinMode(MOTOR1_PWM, OUTPUT); + pinMode(MOTOR2_control_A, OUTPUT); + pinMode(MOTOR2_control_B, OUTPUT); + pinMode(MOTOR2_PWM, OUTPUT); +} + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido1); + digitalWrite(MOTOR1_control_B,!sentido1); + digitalWrite(MOTOR2_control_A,!sentido1); + digitalWrite(MOTOR2_control_B,sentido1); + delay(tempo); +} + +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + parar(); +} +void andarTras(int tempo,int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + parar(); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,sentido); + digitalWrite(MOTOR1_control_B,!sentido); + digitalWrite(MOTOR2_control_A,sentido); + digitalWrite(MOTOR2_control_B,!sentido); + delay(tempo); +} + +void virarEsquerdaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); + +} +void virarDireitaRe(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_control_A,!sentido); + digitalWrite(MOTOR1_control_B,sentido); + digitalWrite(MOTOR2_control_A,!sentido); + digitalWrite(MOTOR2_control_B,sentido); + delay(tempo); +} + + diff --git a/arduino/all the sketchs of my life/Robotica/minicurso/Utilitario.ino b/arduino/all the sketchs of my life/Robotica/minicurso/Utilitario.ino new file mode 100644 index 0000000..a99ee8a --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/minicurso/Utilitario.ino @@ -0,0 +1,21 @@ +void configurarComunicacao() { + Serial.begin(115200); +} + + +void imprimirLuz() { + Serial.print("Luz: "); + Serial.println(analogRead(3)); +} + +void imprimirTemperatura() { + float tempC = analogRead(2); //read the value from the sensor + tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature + Serial.print("Temperatura: "); + Serial.println((byte)tempC); +} + +void esperar(long mssegundos) { + delay(mssegundos); +} + diff --git a/arduino/all the sketchs of my life/Robotica/minicurso/minicurso.ino b/arduino/all the sketchs of my life/Robotica/minicurso/minicurso.ino new file mode 100644 index 0000000..df31163 --- /dev/null +++ b/arduino/all the sketchs of my life/Robotica/minicurso/minicurso.ino @@ -0,0 +1,17 @@ + +//setup = configurar +void setup(){ + configurarMotor(); + configurarComunicacao(); +} + +//executar para sempre no robo +void loop(){ + imprimirTemperatura(); + delay(1000); + imprimirLuz(); + delay(1000); + + +} + diff --git a/arduino/all the sketchs of my life/SparkLCD/.DS_Store b/arduino/all the sketchs of my life/SparkLCD/.DS_Store new file mode 100644 index 0000000..076cdba Binary files /dev/null and b/arduino/all the sketchs of my life/SparkLCD/.DS_Store differ diff --git a/arduino/all the sketchs of my life/SparkLCD/LCD_driver.c b/arduino/all the sketchs of my life/SparkLCD/LCD_driver.c new file mode 100644 index 0000000..684b169 --- /dev/null +++ b/arduino/all the sketchs of my life/SparkLCD/LCD_driver.c @@ -0,0 +1,416 @@ +//************************************************************************ +// +// LCD_driver.c: Interface for Nokia LCD +// +//************************************************************************ +//************************************************************************ +//* Edit History +//* = Mark Sproul msproul -at- jove.rutgers.edu +//************************************************************************ +//* Apr 2, 2010 I received my Color LCD Shield sku: LCD-09363 from sparkfun +//* Apr 2, 2010 The code was written for WinAVR, I modified it to compile under Arduino +//* Apr 3, 2010 Changed LCDSetPixel to make it "RIGHT" side up +//* Apr 3, 2010 Made LCDSetPixel public +//* Apr 3, 2010 Working on MEGA, pin defs in nokia_tester.h +//* Apr 4, 2010 Removed delays from LCDCommand & LCDCommand, increased speed by 75% +//************************************************************************ +#include "nokia_tester.h" +#include "LCD_driver.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef _USE_ARDUINO_FOR_NOKIEA_ + #include "WProgram.h" +#endif + +//************************************************************************ +// +// "Private" Function Definitions +// +//************************************************************************ + + +//************************************************************************ +// +// Global Variables for LCD driver +// +//************************************************************************ +//static char x_offset = 0; +//static char y_offset = 0; + +//The spark logo array defines the SparkFun logo that is displayed during startup on the splash screen. The array may +//be changed to display a different image at startup or removed altogether. The array is local to the LCD driver and +//can not be used outside of this file. +static char logo_spark[1120] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfb,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x3f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x3f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x7f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x20,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x00,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0f,0xe0,0x9f,0x01,0xfc,0x09,0x9e,0x1e,0x7f,0x70,0x73,0x9f,0x00,0x00,0x00,0x00, +0x3f,0xf1,0xff,0x87,0xfe,0x3f,0xde,0x3d,0xff,0x78,0xf3,0xff,0x80,0x00,0x00,0x00, +0x3c,0xf9,0xff,0xc7,0xdf,0x3f,0xde,0x79,0xff,0x78,0xf3,0xff,0xc0,0x00,0x00,0x00, +0x78,0x79,0xc3,0xcf,0x0f,0x3f,0x1c,0xf0,0x3c,0x78,0xf3,0xe3,0xc0,0x00,0x00,0x00, +0x7c,0x01,0xc1,0xe0,0x0f,0x3e,0x1f,0xe0,0x3c,0x78,0xf3,0xc3,0xc0,0x00,0x00,0x00, +0x3f,0xc1,0x81,0xe0,0x3f,0x3c,0x1f,0xe0,0x3c,0x78,0xf3,0xc1,0xc0,0x00,0x00,0x00, +0x1f,0xf1,0x81,0xe3,0xff,0x3c,0x1f,0xe0,0x3c,0x78,0xf3,0xc1,0xc0,0x00,0x00,0x00, +0x07,0xf9,0x81,0xe7,0xef,0x3c,0x1f,0xf0,0x3c,0x78,0xf3,0xc1,0xc0,0x00,0x00,0x00, +0x00,0xf9,0x81,0xef,0x07,0x3c,0x1e,0xf8,0x3c,0x78,0xf3,0xc1,0xc0,0x00,0x00,0x00, +0x78,0x79,0xc1,0xef,0x0f,0x3c,0x1e,0x78,0x3c,0x78,0xf3,0xc1,0xc0,0x00,0x00,0x00, +0x78,0x79,0xe3,0xcf,0x0f,0x3c,0x1e,0x3c,0x3c,0x7c,0xf3,0xc1,0xc0,0x00,0x00,0x00, +0x3f,0xf9,0xff,0xcf,0xff,0x3c,0x1e,0x3e,0x3c,0x7f,0xf3,0xc1,0xcf,0x00,0x00,0x00, +0x1f,0xf1,0xff,0x87,0xff,0x3c,0x1e,0x1e,0x3c,0x3f,0xf3,0xc1,0xc7,0x00,0x00,0x00, +0x07,0xc1,0x9e,0x03,0xe0,0x00,0x00,0x02,0x00,0x0e,0x20,0x00,0x00,0x00,0x00,0x00, +0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x03,0x80,0x00,0x00,0x00,0xc0,0x00,0x00,0x18,0x00,0x00,0x08,0x08,0x00,0x00, +0x00,0x01,0x87,0xc3,0x03,0xe0,0xe1,0xf0,0xf8,0x3e,0x33,0x08,0x3e,0x1e,0x00,0x00, +0x00,0x01,0x86,0x03,0x03,0x01,0xb0,0xe0,0xdc,0x66,0x3b,0x08,0x66,0x32,0x00,0x00, +0x00,0x00,0x87,0xc3,0x03,0xe1,0x80,0x40,0xd8,0x63,0x3b,0x08,0x60,0x3c,0x00,0x00, +0x00,0x00,0x87,0x83,0x03,0xc1,0x80,0x40,0xf8,0x63,0x3f,0x08,0x60,0x0e,0x00,0x00, +0x00,0x00,0x06,0x03,0x03,0x01,0xb0,0x40,0xd8,0x66,0x37,0x08,0x66,0x32,0x00,0x00, +0x00,0x00,0x07,0xc3,0xe3,0xe0,0xe0,0x40,0xc8,0x3e,0x33,0x08,0x3e,0x3e,0x00,0x00, +0x00,0x00,0x07,0xc3,0xe3,0xe0,0xe0,0x40,0x88,0x3c,0x33,0x08,0x3c,0x1e,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,}; + + +//************************************************************************ +//Usage: LCDClear(black); +//Inputs: char color: 8-bit color to be sent to the screen. +//Outputs: None +//Description: This function will clear the screen with "color" by writing the +// color to each location in the RAM of the LCD. +//************************************************************************ +void LCDClear(int color) +{ +unsigned int i; + + #ifdef EPSON + LCDCommand(PASET); + LCDData(0); + LCDData(131); + + LCDCommand(CASET); + LCDData(0); + LCDData(131); + + LCDCommand(RAMWR); + #endif + #ifdef PHILLIPS + LCDCommand(PASETP); + LCDData(0); + LCDData(131); + + LCDCommand(CASETP); + LCDData(0); + LCDData(131); + + LCDCommand(RAMWRP); + #endif + + for (i=0; i < (131*131)/2; i++) + { + LCDData((color >> 4) & 0x00FF); + LCDData(((color & 0x0F) << 4) | (color >> 8)); + LCDData(color & 0x0FF); // nop(EPSON) + } + +// x_offset = 0; +// y_offset = 0; +} + + +//************************************************************************ +void delay_us(int microSecs) +{ + delayMicroseconds(microSecs); +} + +//************************************************************************ +void delay_ms(int millisecs) +{ +// delay(millisecs); +// delayMicroseconds(millisecs * 1000); +} + + +//************************************************************************ +//Usage: LCDCommand(RAMWR); +//Inputs: char data - character command to be sent to the LCD +//Outputs: None +//************************************************************************ +void LCDCommand(unsigned char data) +{ +char jj; + cbi(LCD_PORT_CS, CS); // enable chip, p0.20 goes low + //delay_us(1); + cbi(LCD_PORT_DIO, DIO); // output low on data out (9th bit low = command), p0.19 + //delay_us(1); + + cbi(LCD_PORT_SCK, SCK); // send clock pulse + delay_us(1); + sbi(LCD_PORT_SCK, SCK); + //delay_us(1); + + for (jj = 0; jj < 8; jj++) + { + if ((data & 0x80) == 0x80) + { + sbi(LCD_PORT_DIO, DIO); + } + else + { + cbi(LCD_PORT_DIO, DIO); + } + //delay_us(1); + + cbi(LCD_PORT_SCK, SCK); // send clock pulse + //+ delay_us(1); + sbi(LCD_PORT_SCK, SCK); + + data <<= 1; + } + + sbi(LCD_PORT_CS, CS); // disable +} + +//************************************************************************ +//Usage: LCDData(RAMWR); +//Inputs: char data - character data to be sent to the LCD +//Outputs: None +//************************************************************************ +void LCDData(unsigned char data) +{ +char j; + + cbi(LCD_PORT_CS, CS); // enable chip, p0.20 goes low + //delay_us(1); + sbi(LCD_PORT_DIO, DIO); // output high on data out (9th bit high = data), p0.19 + //delay_us(1); + + cbi(LCD_PORT_SCK, SCK); // send clock pulse +//+ delay_us(1); + sbi(LCD_PORT_SCK, SCK); // send clock pulse + //delay_us(1); + + for (j = 0; j < 8; j++) + { + if ((data & 0x80) == 0x80) + { + sbi(LCD_PORT_DIO, DIO); + } + else + { + cbi(LCD_PORT_DIO, DIO); + } + //delay_us(1); + + cbi(LCD_PORT_SCK, SCK); // send clock pulse +//+ delay_us(1); + sbi(LCD_PORT_SCK, SCK); + + data <<= 1; + } + + LCD_PORT_CS |= (1< Made LCDSetPixel public +//************************************************************************ +void LCDSetPixel(int color, unsigned char x, unsigned char y) +{ +int myYYvalue; + +//* Apr 3, 2010 This is to make it "RIGHT" side up + + myYYvalue = (COL_HEIGHT - 1) - y; + + #ifdef EPSON + LCDCommand(PASET); // page start/end ram + LCDData(x); + LCDData(ENDPAGE); + + LCDCommand(CASET); // column start/end ram + LCDData(myYYvalue); + LCDData(ENDCOL); + + LCDCommand(RAMWR); // write + LCDData((color>>4)&0x00FF); + LCDData(((color&0x0F)<<4)|(color>>8)); + LCDData(color&0x0FF); // nop(EPSON) + //LCDData(color); + //LCDData(NOP); + //LCDData(NOP); + #endif + #ifdef PHILLIPS + LCDCommand(PASETP); // page start/end ram + LCDData(x); + LCDData(ENDPAGE); + + LCDCommand(CASETP); // column start/end ram + LCDData(myYYvalue); + LCDData(ENDCOL); + + LCDCommand(RAMWRP); // write + + LCDData((unsigned char)((color>>4)&0x00FF)); + LCDData((unsigned char)(((color&0x0F)<<4)|0x00)); + #endif + +} + + diff --git a/arduino/all the sketchs of my life/SparkLCD/LCD_driver.h b/arduino/all the sketchs of my life/SparkLCD/LCD_driver.h new file mode 100644 index 0000000..85ca4bc --- /dev/null +++ b/arduino/all the sketchs of my life/SparkLCD/LCD_driver.h @@ -0,0 +1,184 @@ +//#define PHILLIPS +#define EPSON + +#ifdef __cplusplus +extern "C" { +#endif + +//******************************************************************** +// +// General Function Definitions +// +//******************************************************************** +void LCDCommand(unsigned char data); +void LCDData(unsigned char data); +void LCDInit(void); +void LCDClear(int color); +void LCDPrintLogo(void); +void LCDContrast(char setting); +void LCDSetPixel(int color, unsigned char x, unsigned char y); + +//******************************************************************** +// +// LCD Dimension Definitions +// +//******************************************************************** +#define ROW_LENGTH 132 +#define COL_HEIGHT 132 +#define ENDPAGE 132 +#define ENDCOL 130 + +//******************************************************************** +// +// EPSON Controller Definitions +// +//******************************************************************** +#define DISON 0xAF +#define DISOFF 0xAE +#define DISNOR 0xA6 +#define DISINV 0xA7 +#define SLPIN 0x95 +#define SLPOUT 0x94 +#define COMSCN 0xBB +#define DISCTL 0xCA +#define PASET 0x75 +#define CASET 0x15 +#define DATCTL 0xBC +#define RGBSET8 0xCE +#define RAMWR 0x5C +#define RAMRD 0x5D +#define PTLIN 0xA8 +#define PTLOUT 0xA9 +#define RMWIN 0xE0 +#define RMWOUT 0xEE +#define ASCSET 0xAA +#define SCSTART 0xAB +#define OSCON 0xD1 +#define OSCOFF 0xD2 +#define PWRCTR 0x20 +#define VOLCTR 0x81 +#define VOLUP 0xD6 +#define VOLDOWN 0xD7 +#define TMPGRD 0x82 +#define EPCTIN 0xCD +#define EPCOUT 0xCC +#define EPMWR 0xFC +#define EPMRD 0xFD +#define EPSRRD1 0x7C +#define EPSRRD2 0x7D +#define NOP 0x25 + +//******************************************************************** +// +// PHILLIPS Controller Definitions +// +//******************************************************************** +//LCD Commands +//* Apr 4, 2010 see definitions below, +#if 0 + #define NOPP 0x00 // nop + #define BSTRON 0x03 + #define SLEEPIN 0x10 + #define SLEEPOUT 0x11 + #define NORON 0x13 + #define INVOFF 0x20 + #define INVON 0x21 + #define SETCON 0x25 + #define DISPOFF 0x28 + #define DISPON 0x29 + #define CASETP 0x2A + #define PASETP 0x2B + #define RAMWRP 0x2C + #define RGBSET 0x2D + #define MADCTL 0x36 + #define COLMOD 0x3A + #define DISCTR 0xB9 + #define EC 0xC0 +#endif + +//************************************************************************************* +// LCD Include File for Philips PCF8833 STN RGB- 132x132x3 Driver +// +// Taken from Philips data sheet Feb 14, 2003 +//************************************************************************************* +//* I changed them to P_ for Philips +//* many of these commands are not used but I wanted them all listed in case +//* anyone wants to write more features +// Philips PCF8833 LCD controller command codes +#define P_NOP 0x00 // nop +#define P_SWRESET 0x01 // software reset +#define P_BSTROFF 0x02 // booster voltage OFF +#define P_BSTRON 0x03 // booster voltage ON +#define P_RDDIDIF 0x04 // read display identification +#define P_RDDST 0x09 // read display status +#define P_SLEEPIN 0x10 // sleep in +#define P_SLEEPOUT 0x11 // sleep out +#define P_PTLON 0x12 // partial display mode +#define P_NORON 0x13 // display normal mode +#define P_INVOFF 0x20 // inversion OFF +#define P_INVON 0x21 // inversion ON +#define P_DALO 0x22 // all pixel OFF +#define P_DAL 0x23 // all pixel ON +#define P_SETCON 0x25 // write contrast +#define P_DISPOFF 0x28 // display OFF +#define P_DISPON 0x29 // display ON +#define P_CASET 0x2A // column address set +#define P_PASET 0x2B // page address set +#define P_RAMWR 0x2C // memory write +#define P_RGBSET 0x2D // colour set +#define P_PTLAR 0x30 // partial area +#define P_VSCRDEF 0x33 // vertical scrolling definition +#define P_TEOFF 0x34 // test mode +#define P_TEON 0x35 // test mode +#define P_MADCTL 0x36 // memory access control +#define P_SEP 0x37 // vertical scrolling start address +#define P_IDMOFF 0x38 // idle mode OFF +#define P_IDMON 0x39 // idle mode ON +#define P_COLMOD 0x3A // interface pixel format +#define P_SETVOP 0xB0 // set Vop +#define P_BRS 0xB4 // bottom row swap +#define P_TRS 0xB6 // top row swap +#define P_DISCTR 0xB9 // display control +#define P_DOR 0xBA // data order +#define P_TCDFE 0xBD // enable/disable DF temperature compensation +#define P_TCVOPE 0xBF // enable/disable Vop temp comp +#define P_EC 0xC0 // internal or external oscillator +#define P_SETMUL 0xC2 // set multiplication factor +#define P_TCVOPAB 0xC3 // set TCVOP slopes A and B +#define P_TCVOPCD 0xC4 // set TCVOP slopes c and d +#define P_TCDF 0xC5 // set divider frequency +#define P_DF8COLOR 0xC6 // set divider frequency 8-color mode +#define P_SETBS 0xC7 // set bias system +#define P_RDTEMP 0xC8 // temperature read back +#define P_NLI 0xC9 // n-line inversion +#define P_RDID1 0xDA // read ID1 +#define P_RDID2 0xDB // read ID2 +#define P_RDID3 0xDC // read ID3 + + +//******************************************************* +// 12-Bit Color Definitions +//******************************************************* +#define WHITE 0xFFF +#define BLACK 0x000 +#define RED 0xF00 +#define GREEN 0x0F0 +#define BLUE 0x00F +#define CYAN 0x0FF +#define MAGENTA 0xF0F +#define YELLOW 0xFF0 +#define BROWN 0xB22 +#define ORANGE 0xFA0 +#define PINK 0xF6A + +typedef struct +{ + unsigned char red; + unsigned char green; + unsigned char blue; +} RGBColor; + + +#ifdef __cplusplus +} +#endif diff --git a/arduino/all the sketchs of my life/SparkLCD/SparkLCD.pde b/arduino/all the sketchs of my life/SparkLCD/SparkLCD.pde new file mode 100644 index 0000000..00f706e --- /dev/null +++ b/arduino/all the sketchs of my life/SparkLCD/SparkLCD.pde @@ -0,0 +1,882 @@ +//************************************************************************ +// Nokia Shield +//************************************************************************ +//* Edit History +//* = Mark Sproul msproul -at- jove.rutgers.edu +//************************************************************************ +//* Apr 2, 2010 I received my Color LCD Shield sku: LCD-09363 from sparkfun +//* Apr 2, 2010 The code was written for WinAVR, I modified it to compile under Arduino +//* Apr 3, 2010 Changed LCDSetPixel to make it "RIGHT" side up +//************************************************************************ + +#include +#include +#include +#include +#include +#include +#include + + +#include "WProgram.h" +#include "HardwareSerial.h" + + +//************************************************************************ +// External Component Libs +//************************************************************************ +#include "LCD_driver.h" +#include "nokia_tester.h" + +//static int uart_putchar(char c, FILE *stream); +//uint8_t uart_getchar(void); +//static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE); + +#define _SHOW_RGB_IMAGE_ +void DisplayRGBimage(); + + +#define kSwitch1_PIN 3 +#define kSwitch2_PIN 4 +#define kSwitch3_PIN 5 + +void DoMandleBrot(void); + +//#define _ENABLE_DEBUG_ + +//************************************************************************ +// Main Code +//************************************************************************ +void setup() +{ +int frameCounter; +unsigned long startTime; + + Serial.begin(9600); + Serial.println("Initializing"); + + //Initialize ARM I/O + ioinit(); + + Serial.println("ioinit. Done"); + + LCDInit(); //Initialize the LCD + + Serial.println("LCDInit. Done"); + + LCDClear(BLACK); + Serial.print("Logo..."); + //Show the splash-screen (Sparkfun Logo) + LCDPrintLogo(); + +#ifdef _ENABLE_DEBUG_ + //* test speed + Serial.println(); + Serial.print("Speed test..."); + frameCounter = 0; + startTime = millis(); + + while ((millis() - startTime) < 5000) + { + LCDClear((frameCounter << 8) + frameCounter); + LCDPrintLogo(); + + frameCounter++; + } + Serial.println(); + Serial.print("Frames="); + Serial.println(frameCounter); +#endif +} + +//************************************************************************ +// Loop +//************************************************************************ +void loop() +{ +int s1, s2, s3; + + s1 = !digitalRead(kSwitch1_PIN); + s2 = !digitalRead(kSwitch2_PIN); + s3 = !digitalRead(kSwitch3_PIN); +#ifdef _ENABLE_DEBUG_foo + Serial.print("switches..."); + Serial.print(s1); + Serial.print("..."); + Serial.print(s2); + Serial.print("..."); + Serial.print(s3); + Serial.println(); +#endif + + + if (s1) + { + Serial.println("GRREN"); + LCDClear(GREEN); + LCDPrintLogo(); + } + else if (s2) + { + Serial.println("WHITE"); + // LCDClear(PINK); + LCDClear(WHITE); + LCDPrintLogo(); + } + else if (s3) + { + DisplayRGBimage(); + delay(5000); + + // Serial.println("BLACK"); + // LCDClear(BLACK); + // LCDPrintLogo(); + DoMandleBrot(); + } + delay(200); +} + +//************************************************************************ +void ioinit(void) +{ +#ifdef _USE_ARDUINO_FOR_NOKIEA_ + + //* setup the switches for input + pinMode(kSwitch1_PIN, INPUT); + pinMode(kSwitch2_PIN, INPUT); + pinMode(kSwitch3_PIN, INPUT); + + //* set the pull up resisters + digitalWrite(kSwitch1_PIN, HIGH); + digitalWrite(kSwitch2_PIN, HIGH); + digitalWrite(kSwitch3_PIN, HIGH); + + + //* do the LCD control lines + pinMode(CS_PIN, OUTPUT); + pinMode(DIO_PIN, OUTPUT); + pinMode(SCK_PIN, OUTPUT); + pinMode(LCD_RES_PIN, OUTPUT); + +#else + DDRB = ((1<> 8) & 0x7F; //Make sure highest bit(URSEL) is 0 indicating we are writing to UBRRH + UBRR0L = MYUBRR; + UCSR0A = (1< 0 ; x--) + delay_us(1000); +} + +//************************************************************************ +//General short delays +void delay_us(int x) +{ + TIFR2 = (1<0) + { + while( (TIFR2 & (1<red << 4) & 0x0f00; + color12bit += (rgbColor->green) & 0x0f0; + color12bit += (rgbColor->blue >> 4) & 0x0f; + + LCDSetPixel(color12bit, col, row); +// LCDSetPixel(color12bit, row, col); +} + +//******************************************************************************* +boolean gettouch() +{ +int s1, s2, s3; + + s1 = !digitalRead(kSwitch1_PIN); + s2 = !digitalRead(kSwitch2_PIN); + s3 = !digitalRead(kSwitch3_PIN); + + return(s1 || s2 || s3); +} + + +//******************************************************************************* +void DoMandleBrot(void) +{ +float XMax, YMax, XMin, YMin; +float X, Y, Xsquare, Ysquare; +float QQtemp; +float QQ[kQmax]; +float PP, deltaP, deltaQ; +long color; +short row, col; +short maxcol; +short maxrow; +RGBColor rgbColor; +short itteration; +boolean keepGoing; +short deltaColumn; +short ii; +short startOffset[10] = {0, 16, 8, 4, 2, 1, 3, 0}; +short columnSteps[10] = {32, 32, 16, 8, 4, 4, 4, 0}; + + XMin = kMandel_FarLeft; + XMax = kMandel_FarRight; + YMin = kMandel_FarTop; + YMax = kMandel_FarBottom; + + itteration = 0; + keepGoing = true; + while (keepGoing) + { + switch(itteration % 3) + { + case 0: + XMin = kMandel_FarLeft; + XMax = kMandel_FarRight; + YMin = kMandel_FarTop; + YMax = kMandel_FarBottom; + break; + + case 1: + XMin = -1.7018; + XMax = -1.7016; + YMin = -0.000075; + YMax = 0.000075; + break; + + case 2: + XMin = -0.197272275682447305; + XMax = -0.196537412401197305; + YMin = -0.67495234375; + YMax = -0.67436640625; + break; + + } + maxcol = gWidth; + maxrow = gHeight; + deltaP = (XMax - XMin) / (maxcol); + deltaQ = (YMax - YMin) / (maxrow); + + QQ[0] = YMin; + for (row=1; row<=maxrow; row++) + { + QQ[row] = QQ[row-1] + deltaQ; + } + + ii = 0; + while (columnSteps[ii] > 0) + { + deltaColumn = columnSteps[ii]; + for (col=startOffset[ii]; col < maxcol; col += deltaColumn) + { + PP = XMin + (deltaP * col); + + for (row=0; row < maxrow; row++) + { + X = Y = Xsquare = Ysquare = 0.0; + color = kStartColor; + QQtemp = QQ[row]; + while ((color < kMaxItterations) && ((Xsquare + Ysquare) < 4)) + { + Xsquare = X * X; + Ysquare = Y * Y; + Y *= X; + Y += Y + QQtemp; + X = Xsquare - Ysquare + PP; + color++; + } + rgbColor.red = (255 - color) & 0xe0; + rgbColor.green = ((255 - color) << 3) & 0xe0;; + rgbColor.blue = ((255 - color) << 6) & 0xe0;; + setPixel(col, row, &rgbColor); + } + if (gettouch()) + { + keepGoing = false; + break; + } + } + ii++; + if (gettouch()) + { + keepGoing = false; + break; + } + } + if (keepGoing) + { + delay(2500); + } + itteration++; + } +} + + +#ifdef _SHOW_RGB_IMAGE_ +static uint8_t gRGBimage[] PROGMEM = { +0,64,0,59,0 , //xSize_hi, xSize_lo ,ySize_hi, ySize_lo + +//* Line # 0 +19,33,33, 20,33,34, 21,36,36, 25,39,39, 27,40,40, 28,40,40, 31,43,42, 32,44,42, 35,46,44, 38,48,45, 40,49,46, +41,50,46, 42,50,46, 44,52,47, 46,53,48, 49,56,51, 53,58,52, 59,63,57, 68,72,66, 72,74,68, 76,77,72, 82,82,77, +68,66,62, 62,64,54, 73,69,58, 97,79,70, 111,82,75, 131,101,94, 133,114,104, 105,99,85, 99,92,82, 92,82,76, 88,77,71, +83,74,68, 75,69,65, 70,71,69, 63,71,69, 57,66,63, 54,64,59, 52,61,57, 49,58,55, 47,57,55, 46,57,55, 48,59,58, +48,60,59, 46,58,56, 46,57,55, 43,56,53, 45,58,53, 46,60,55, 46,60,54, 51,63,58, 61,69,66, 63,73,69, 63,74,69, +63,73,67, 69,76,70, 78,82,77, 86,87,82, 95,91,88, 99,97,93, 102,100,96, 101,100,96, 98,98,94, +//* Line # 1 +22,35,36, 23,36,37, 23,37,38, 27,40,41, 29,42,42, 32,45,44, 32,44,43, 37,48,47, 38,49,47, 39,49,46, 41,51,48, +43,52,48, 43,51,47, 44,52,48, 47,54,49, 48,55,50, 57,60,53, 63,64,57, 70,70,64, 71,71,64, 72,70,65, 80,78,73, +74,71,66, 120,111,115, 170,161,165, 213,208,209, 206,203,203, 216,213,212, 235,227,228, 222,209,217, 213,193,188, 191,164,149, 169,143,129, +126,101,89, 106,87,77, 90,80,72, 80,77,72, 69,69,66, 63,66,62, 52,60,55, 47,60,54, 43,59,53, 43,59,55, 48,60,58, +51,62,59, 49,61,53, 49,61,53, 49,62,52, 51,63,54, 53,65,55, 54,67,56, 55,67,57, 63,72,63, 66,75,66, 64,75,64, +65,76,64, 70,77,66, 76,80,70, 87,87,78, 100,94,86, 104,98,90, 106,101,92, 106,102,93, 105,101,92, +//* Line # 2 +22,36,36, 25,38,39, 27,41,42, 31,45,46, 33,46,46, 35,48,47, 36,47,46, 39,51,49, 39,51,49, 40,50,47, 43,53,50, +44,54,51, 43,52,49, 47,56,51, 49,56,51, 49,57,52, 57,61,55, 62,65,59, 69,71,66, 72,72,68, 72,71,68, 80,77,75, +156,153,151, 221,212,209, 194,178,173, 172,150,145, 178,152,149, 181,156,153, 179,160,158, 204,191,190, 216,196,187, 213,182,168, 178,144,129, +160,123,108, 153,117,103, 140,111,97, 118,95,84, 93,75,68, 79,69,66, 64,66,59, 49,63,53, 42,61,52, 46,63,55, 51,63,58, +53,63,57, 54,65,56, 54,64,55, 57,67,58, 60,70,59, 61,71,60, 65,74,63, 64,73,62, 69,76,66, 71,79,69, 68,77,66, +68,76,65, 72,77,66, 78,81,70, 90,90,78, 100,96,85, 107,102,91, 110,106,95, 111,108,97, 110,109,97, +//* Line # 3 +23,36,37, 25,39,39, 30,44,45, 31,45,46, 34,48,48, 36,49,48, 37,49,48, 39,51,50, 43,54,52, 43,55,51, 44,56,52, +46,57,53, 47,57,52, 47,57,52, 48,56,51, 49,57,51, 53,61,57, 58,65,62, 67,71,68, 72,72,70, 76,74,73, 147,142,140, +196,188,188, 148,134,127, 154,136,125, 160,140,130, 171,150,142, 190,171,164, 230,214,210, 247,236,233, 248,237,234, 233,216,211, 203,176,166, +180,142,127, 165,123,104, 162,120,100, 150,110,90, 145,111,97, 114,91,83, 87,76,65, 62,65,53, 56,68,55, 53,66,56, 59,67,61, +59,67,63, 61,70,66, 63,72,67, 65,72,68, 69,75,71, 69,74,69, 71,76,71, 71,76,71, 73,78,73, 71,78,72, 70,77,71, +72,78,71, 78,81,74, 85,85,78, 94,92,86, 102,102,93, 112,113,103, 114,116,106, 117,119,110, 117,121,111, +//* Line # 4 +22,35,36, 23,36,37, 26,40,41, 30,44,45, 33,46,47, 35,47,47, 37,49,48, 39,50,49, 41,52,51, 41,53,50, 45,57,53, +46,58,53, 45,56,52, 46,56,51, 49,58,52, 50,59,53, 53,60,56, 60,66,63, 69,70,66, 75,71,66, 123,112,106, 225,210,203, +188,169,162, 197,176,163, 229,214,198, 240,224,209, 247,232,219, 251,236,226, 250,237,228, 237,223,218, 227,218,216, 222,212,208, 218,194,184, +201,163,145, 192,146,124, 191,143,120, 161,115,92, 150,109,89, 126,90,73, 132,105,88, 109,94,79, 77,71,59, 67,68,60, 67,72,66, +67,73,70, 67,75,73, 69,76,73, 71,77,74, 74,78,75, 74,77,74, 77,79,75, 77,79,76, 76,80,76, 72,76,73, 71,76,71, +75,79,74, 82,84,79, 92,91,86, 106,104,98, 117,117,109, 129,129,120, 132,133,124, 131,133,124, 129,132,122, +//* Line # 5 +25,38,39, 25,39,39, 24,38,39, 28,41,42, 32,45,45, 34,47,46, 36,48,47, 37,48,47, 39,50,48, 40,52,49, 41,54,50, +43,55,51, 45,57,52, 47,57,52, 46,57,51, 50,61,54, 61,65,58, 78,77,69, 86,80,70, 125,111,100, 195,173,159, 217,188,172, +215,180,163, 225,193,167, 198,165,136, 203,164,139, 210,169,147, 196,158,139, 204,175,158, 235,214,197, 226,216,203, 217,200,186, 207,177,158, +214,171,147, 196,148,123, 187,141,117, 164,122,102, 157,115,92, 129,82,58, 117,75,55, 128,95,80, 140,118,108, 98,89,82, 74,74,70, +72,78,74, 71,80,73, 72,79,73, 76,82,75, 79,82,76, 78,80,73, 80,80,73, 80,80,73, 78,81,74, 75,79,70, 72,77,68, +77,81,72, 90,91,82, 105,103,95, 123,119,110, 135,130,118, 147,142,130, 150,145,134, 146,143,131, 140,138,125, +//* Line # 6 +28,42,41, 28,41,40, 24,38,37, 26,39,38, 28,41,40, 32,45,43, 35,47,46, 36,48,46, 38,49,47, 40,50,49, 41,52,50, +44,55,51, 46,56,51, 46,56,50, 47,56,49, 50,59,53, 61,63,55, 85,76,66, 124,103,89, 158,127,109, 185,150,129, 181,144,123, +146,106,87, 105,71,52, 102,73,52, 135,107,86, 164,136,116, 146,118,100, 177,147,134, 207,175,168, 206,182,168, 225,204,185, 199,170,151, +198,158,133, 190,142,109, 184,137,104, 179,137,113, 183,141,116, 188,141,111, 140,92,67, 114,68,49, 132,95,82, 154,130,121, 115,104,98, +90,88,81, 76,77,69, 80,81,73, 81,82,75, 83,83,76, 83,82,74, 82,81,73, 80,80,71, 78,82,73, 77,82,72, 76,80,70, +84,86,76, 100,99,89, 117,115,105, 132,129,118, 142,137,125, 154,147,133, 158,150,137, 155,147,133, 150,143,129, +//* Line # 7 +34,48,46, 33,46,44, 29,42,40, 24,38,36, 26,39,38, 31,43,42, 33,44,43, 36,46,45, 38,48,48, 42,50,50, 44,54,53, +46,56,53, 45,56,52, 47,57,51, 50,59,53, 54,61,57, 57,60,54, 109,98,90, 150,121,107, 167,129,110, 172,135,112, 160,124,102, +113,75,59, 89,55,42, 111,81,69, 111,79,64, 93,62,49, 135,108,93, 193,174,161, 210,196,185, 205,183,171, 184,154,143, 174,139,131, +164,120,104, 159,106,77, 174,118,86, 158,104,82, 138,92,72, 175,133,107, 190,144,120, 162,114,93, 131,87,69, 142,106,90, 167,138,125, +137,119,108, 104,96,89, 98,91,84, 86,82,76, 87,84,78, 86,83,78, 83,81,74, 81,81,73, 79,83,76, 79,82,75, 83,83,76, +92,90,82, 106,104,95, 123,119,111, 135,131,122, 144,141,130, 154,148,136, 161,152,139, 160,150,136, 157,148,136, +//* Line # 8 +40,53,51, 38,50,49, 32,44,44, 30,43,43, 31,43,43, 32,44,44, 33,43,44, 37,47,48, 41,50,51, 46,53,52, 50,59,57, +48,58,55, 47,59,55, 51,61,58, 52,61,58, 54,60,58, 71,74,69, 129,118,112, 158,131,119, 167,132,115, 199,164,143, 161,126,106, +185,146,130, 219,199,189, 236,225,216, 223,208,197, 210,193,182, 206,186,179, 235,217,212, 245,226,224, 198,176,171, 185,157,150, 165,131,125, +172,129,118, 154,104,83, 132,79,56, 153,100,84, 151,104,92, 133,93,78, 125,84,67, 162,120,99, 166,122,100, 161,116,94, 156,109,88, +141,106,89, 124,110,100, 94,83,73, 98,90,83, 95,90,84, 92,89,82, 90,87,79, 88,86,77, 87,86,79, 87,86,78, 91,89,81, +100,96,88, 111,106,98, 124,118,109, 135,128,120, 147,142,131, 154,148,135, 160,152,138, 160,151,136, 159,151,137, +//* Line # 9 +42,54,52, 41,53,51, 37,49,50, 37,48,49, 36,47,48, 36,46,48, 36,46,48, 41,50,52, 46,54,56, 51,57,54, 55,63,59, +51,61,58, 51,62,60, 52,63,60, 55,62,59, 55,58,55, 84,82,78, 201,189,183, 195,169,159, 180,145,132, 189,155,138, 161,127,110, +141,103,88, 153,123,115, 187,165,160, 219,202,196, 251,237,230, 255,245,238, 252,243,236, 246,240,234, 243,235,223, 227,214,199, 216,193,180, +204,174,156, 197,166,143, 168,133,110, 135,96,75, 138,93,78, 163,116,102, 145,101,82, 131,89,66, 168,125,100, 146,98,75, 151,96,75, +155,110,91, 128,104,89, 115,96,83, 112,99,90, 99,92,85, 98,93,86, 98,94,85, 97,92,83, 98,94,86, 100,95,87, 102,97,88, +107,100,92, 114,106,97, 124,115,106, 134,126,116, 143,136,125, 150,143,130, 157,149,134, 160,152,136, 160,152,137, +//* Line # 10 +45,57,54, 43,54,51, 38,50,50, 39,50,51, 38,48,49, 40,50,51, 42,51,52, 45,53,55, 50,58,59, 56,62,58, 59,66,62, +53,64,61, 53,63,60, 56,63,59, 62,63,57, 75,70,62, 175,167,160, 242,224,217, 204,172,163, 186,151,138, 192,159,143, 169,137,121, +107,70,57, 101,68,58, 127,97,88, 161,134,124, 145,122,114, 187,166,156, 221,204,194, 224,206,196, 225,207,193, 230,205,187, 223,186,167, +214,175,155, 193,159,137, 175,139,117, 141,97,75, 148,96,76, 166,113,96, 144,96,75, 129,86,62, 128,86,62, 142,96,75, 149,99,83, +134,88,70, 150,114,93, 146,118,102, 118,100,89, 107,96,89, 106,100,92, 104,98,88, 104,98,87, 108,101,92, 108,101,93, 110,103,94, +114,106,96, 118,110,100, 124,116,105, 131,123,111, 139,129,118, 145,137,124, 151,144,128, 156,149,133, 155,147,132, +//* Line # 11 +49,59,56, 44,54,51, 41,52,50, 44,54,53, 41,51,50, 42,52,50, 46,55,54, 49,56,56, 54,61,60, 58,64,60, 58,66,62, +58,67,64, 58,66,63, 60,63,56, 76,69,58, 146,132,118, 232,212,199, 195,166,154, 195,156,145, 167,128,116, 145,112,98, 147,117,103, +111,78,67, 144,113,100, 170,142,128, 137,110,98, 97,68,58, 76,45,35, 110,75,65, 125,88,78, 107,69,58, 125,78,66, 131,72,57, +117,60,44, 115,69,56, 132,87,74, 131,72,56, 81,26,8, 100,58,42, 155,111,92, 161,115,95, 118,72,51, 132,86,66, 142,95,77, +141,94,73, 131,85,60, 139,104,85, 124,101,89, 114,102,93, 111,103,94, 113,105,95, 111,103,92, 112,104,94, 113,106,96, 116,108,98, +119,111,100, 120,113,101, 123,117,104, 129,122,110, 138,126,115, 141,132,118, 146,139,122, 154,148,130, 156,149,133, +//* Line # 12 +51,61,57, 47,57,54, 47,58,53, 47,58,53, 45,55,51, 45,54,50, 48,56,52, 51,57,54, 56,63,59, 60,67,62, 60,68,64, +58,68,64, 61,67,62, 72,69,60, 88,73,59, 156,134,115, 193,163,143, 141,103,85, 146,101,87, 151,108,95, 140,107,94, 147,119,107, +108,78,69, 99,61,53, 101,62,54, 85,50,44, 68,37,31, 66,36,29, 75,45,35, 84,51,39, 69,36,27, 83,40,32, 123,68,54, +110,61,48, 74,41,33, 63,33,25, 116,71,56, 98,61,48, 35,12,6, 104,69,58, 128,83,68, 114,62,42, 127,75,50, 137,89,61, +154,103,74, 140,88,60, 135,96,75, 145,120,107, 131,118,109, 122,114,106, 116,108,97, 117,108,97, 116,110,100, 118,111,100, 119,113,101, +123,117,104, 120,115,102, 122,117,103, 128,122,108, 136,122,111, 136,126,112, 139,133,115, 150,145,126, 156,148,131, +//* Line # 13 +49,60,55, 49,60,55, 49,60,56, 47,58,54, 45,54,51, 47,55,52, 49,57,54, 52,60,57, 56,64,61, 59,68,66, 64,67,61, +61,64,61, 56,64,62, 90,86,75, 160,134,111, 196,160,137, 158,122,105, 100,69,55, 96,66,53, 108,74,62, 108,70,56, 107,68,54, +95,59,47, 99,66,49, 99,66,48, 93,58,44, 84,47,35, 97,57,46, 103,59,46, 111,63,49, 91,52,40, 73,37,26, 92,50,37, +103,66,54, 82,54,45, 47,24,15, 51,24,12, 97,63,56, 52,31,26, 80,51,40, 126,72,62, 99,60,36, 126,72,46, 144,77,51, +144,93,58, 163,105,74, 150,99,73, 145,105,84, 168,139,125, 156,139,128, 132,122,113, 124,115,105, 126,111,98, 121,109,97, 123,115,103, +124,118,106, 123,118,106, 123,117,104, 127,120,107, 133,123,112, 135,127,115, 137,131,116, 145,139,124, 151,145,129, +//* Line # 14 +49,60,55, 49,61,55, 47,58,56, 46,56,54, 43,53,51, 45,54,52, 48,56,55, 51,59,58, 54,61,60, 55,66,66, 64,63,56, +62,63,57, 52,63,65, 77,73,61, 164,130,103, 190,146,123, 117,84,71, 54,34,25, 47,33,24, 58,33,23, 102,60,45, 125,76,58, +125,82,64, 131,90,67, 129,85,61, 121,76,56, 109,64,45, 108,62,44, 120,74,54, 114,68,45, 106,62,44, 88,47,33, 77,37,24, +85,46,35, 96,60,51, 74,43,35, 43,20,11, 64,29,25, 84,59,52, 80,54,44, 114,60,51, 97,68,44, 116,65,41, 147,72,53, +126,75,45, 147,91,64, 164,109,82, 160,109,85, 168,124,104, 161,130,113, 169,148,135, 160,141,129, 157,133,118, 138,119,106, 127,115,104, +123,115,106, 125,119,109, 126,119,108, 127,119,108, 130,124,112, 134,128,116, 136,130,117, 141,135,122, 146,140,126, +//* Line # 15 +47,58,53, 47,58,53, 46,57,55, 45,55,53, 44,54,52, 45,54,52, 47,56,54, 50,58,56, 52,59,58, 53,63,64, 60,61,54, +58,62,55, 53,64,64, 73,66,55, 146,112,87, 169,128,106, 106,79,69, 43,28,21, 24,12,7, 62,39,29, 122,80,64, 142,92,71, +137,91,70, 138,91,68, 139,91,67, 132,84,62, 124,77,56, 113,65,45, 129,83,61, 124,78,53, 111,67,47, 98,55,40, 78,36,22, +83,44,33, 76,42,33, 80,52,44, 47,24,17, 38,13,9, 50,28,24, 60,36,29, 83,47,38, 88,53,37, 92,45,27, 149,90,72, +137,85,64, 134,85,64, 126,75,54, 154,103,81, 164,114,92, 182,139,117, 179,143,121, 178,147,127, 194,168,154, 143,122,108, 126,112,101, +124,116,105, 127,121,111, 128,121,111, 127,119,108, 129,122,112, 132,125,114, 135,128,116, 140,133,121, 145,138,125, +//* Line # 16 +47,58,54, 47,59,54, 47,58,55, 45,55,53, 46,56,54, 45,54,53, 48,56,54, 50,57,56, 52,59,58, 53,63,65, 60,63,56, +57,64,56, 53,64,63, 83,73,63, 149,112,89, 123,86,65, 44,25,18, 17,8,6, 15,9,5, 65,45,36, 126,84,67, 149,97,74, +148,99,73, 149,98,73, 147,95,70, 136,85,61, 137,86,64, 119,69,47, 137,89,65, 133,85,58, 121,74,51, 105,60,42, 87,42,27, +80,40,28, 68,35,26, 66,40,34, 55,34,30, 34,22,18, 37,19,17, 42,20,16, 46,27,17, 83,44,36, 62,21,12, 114,74,58, +140,86,71, 152,100,79, 158,104,83, 137,81,59, 164,110,88, 167,118,97, 185,141,121, 204,167,148, 185,155,141, 140,115,101, 126,110,98, +124,114,103, 125,118,108, 125,118,108, 126,118,107, 128,120,110, 130,122,112, 136,128,117, 140,132,121, 144,137,125, +//* Line # 17 +47,58,55, 49,60,57, 47,58,56, 45,55,53, 44,54,52, 46,54,53, 47,55,54, 49,57,55, 51,59,57, 54,62,66, 58,63,56, +56,67,57, 51,63,61, 91,76,67, 143,104,84, 90,57,39, 23,9,5, 9,6,6, 12,10,8, 58,40,32, 133,92,75, 153,100,76, +149,99,71, 153,102,74, 153,100,74, 142,91,66, 146,94,71, 128,77,54, 146,95,70, 143,93,65, 127,77,52, 114,65,45, 101,54,38, +76,35,23, 64,31,23, 65,41,36, 52,35,33, 20,14,11, 40,24,25, 46,27,25, 30,21,13, 82,44,41, 63,28,20, 53,26,15, +126,74,62, 127,71,47, 144,87,64, 168,112,90, 190,138,119, 204,159,142, 216,184,170, 229,197,184, 167,132,117, 140,111,97, 122,102,90, +123,111,100, 122,113,103, 122,115,105, 124,116,106, 129,119,111, 132,123,114, 135,126,116, 140,130,121, 141,132,121, +//* Line # 18 +47,58,56, 49,60,57, 49,60,57, 48,59,56, 48,57,55, 48,56,55, 47,55,54, 49,57,55, 51,59,57, 53,60,65, 56,63,55, +52,68,56, 54,66,63, 92,74,67, 129,88,70, 73,43,27, 28,18,15, 14,14,15, 11,12,10, 44,28,20, 123,85,67, 154,103,78, +152,103,75, 152,104,75, 153,104,77, 148,98,73, 147,96,73, 130,78,55, 144,91,67, 154,101,74, 138,85,60, 120,68,46, 108,60,41, +81,39,27, 57,24,17, 33,11,8, 25,11,11, 13,8,7, 28,15,16, 36,18,18, 28,17,12, 65,33,32, 64,36,31, 55,34,26, +70,29,20, 111,62,42, 97,46,28, 110,60,42, 131,83,68, 144,102,89, 146,113,102, 159,125,114, 124,84,69, 135,102,88, 145,122,110, +123,109,98, 122,113,103, 122,114,104, 122,114,105, 126,116,109, 132,122,114, 134,124,116, 134,124,115, 136,127,116, +//* Line # 19 +48,58,56, 49,60,57, 49,60,58, 50,61,58, 50,60,58, 50,59,57, 50,59,57, 53,60,58, 55,62,60, 56,62,68, 57,65,57, +49,69,55, 55,68,64, 102,81,75, 127,85,70, 80,53,37, 27,18,14, 7,9,8, 6,8,6, 26,12,5, 104,67,48, 149,101,75, +153,107,79, 149,106,77, 144,101,73, 145,98,73, 145,95,72, 129,76,55, 151,96,74, 160,103,80, 138,82,56, 138,84,61, 119,70,51, +96,55,42, 58,27,20, 40,19,18, 21,8,9, 15,8,9, 24,11,11, 40,24,24, 34,18,17, 46,21,19, 63,40,36, 51,33,25, +54,28,23, 85,53,48, 99,63,53, 133,93,81, 119,75,62, 99,56,43, 118,78,64, 152,113,97, 155,111,95, 144,108,93, 136,112,100, +122,106,96, 120,111,102, 121,113,104, 122,114,104, 123,113,106, 128,118,110, 132,121,114, 131,121,112, 132,121,112, +//* Line # 20 +50,59,57, 51,59,58, 51,62,58, 52,63,60, 51,62,58, 52,60,58, 53,61,60, 54,63,61, 56,66,64, 57,68,69, 59,67,59, +58,70,62, 68,72,71, 125,97,85, 138,94,73, 52,32,24, 7,4,2, 18,15,13, 6,5,3, 16,8,1, 100,68,54, 153,103,82, +156,110,81, 133,94,65, 126,87,60, 116,74,49, 107,63,38, 105,57,33, 144,93,68, 157,104,77, 138,82,54, 157,99,72, 139,85,62, +114,67,49, 63,29,19, 39,20,17, 15,9,12, 10,7,8, 22,9,6, 38,19,13, 55,30,22, 39,16,11, 48,28,24, 48,31,26, +53,33,29, 95,67,61, 117,83,74, 137,97,85, 120,76,62, 120,77,63, 140,98,86, 92,53,40, 178,140,125, 158,126,113, 130,105,93, +123,106,93, 121,110,98, 120,112,104, 119,111,107, 121,111,104, 122,112,105, 126,116,108, 129,119,110, 130,119,111, +//* Line # 21 +53,60,58, 55,62,59, 53,64,60, 54,65,61, 54,64,60, 54,63,60, 56,65,62, 57,67,64, 57,67,65, 56,71,66, 62,71,65, +66,68,67, 91,80,77, 156,121,102, 114,74,53, 22,10,9, 3,5,4, 28,21,19, 12,5,4, 11,8,0, 89,62,52, 161,108,93, +154,107,78, 153,107,80, 164,115,94, 151,103,82, 130,81,61, 125,74,53, 135,80,56, 159,99,73, 166,107,78, 170,112,82, 160,102,74, +138,85,62, 99,59,43, 44,22,15, 21,15,14, 6,5,8, 13,7,7, 33,16,10, 51,28,20, 52,32,28, 36,19,17, 34,18,13, +44,22,16, 75,44,36, 124,88,77, 142,101,87, 139,96,81, 115,74,62, 84,47,39, 118,84,74, 169,135,120, 149,118,109, 173,150,141, +140,126,112, 120,111,96, 119,113,106, 117,111,109, 119,112,104, 119,112,103, 120,111,103, 122,113,104, 125,115,107, +//* Line # 22 +54,61,58, 56,63,60, 54,65,61, 54,65,61, 55,65,61, 56,65,62, 59,68,65, 63,71,68, 63,70,67, 61,71,66, 60,72,72, +69,67,65, 123,95,80, 148,110,89, 67,40,29, 19,10,10, 1,0,0, 26,18,17, 13,6,5, 5,3,0, 69,43,35, 155,103,89, +161,114,86, 169,117,91, 164,108,89, 139,89,74, 124,77,65, 136,87,74, 163,106,88, 180,114,91, 175,115,86, 172,117,86, 164,109,79, +156,102,77, 119,74,53, 86,52,38, 38,14,6, 17,8,9, 3,2,9, 17,7,9, 31,18,20, 33,21,24, 43,30,31, 48,30,24, +51,28,21, 63,36,35, 101,71,65, 81,45,35, 68,33,22, 95,60,50, 156,121,111, 193,157,145, 149,108,93, 158,126,118, 225,208,203, +189,180,171, 124,119,105, 124,118,107, 121,114,107, 117,110,101, 116,109,100, 117,108,100, 116,108,99, 118,109,101, +//* Line # 23 +52,59,57, 54,61,59, 54,63,61, 54,63,60, 55,64,61, 56,66,62, 60,67,64, 64,69,66, 65,69,66, 68,69,63, 64,72,75, +95,84,79, 169,125,99, 117,74,52, 64,48,46, 16,10,12, 0,0,0, 20,14,14, 12,7,6, 1,0,0, 56,32,24, 153,102,88, +160,112,86, 150,106,76, 105,64,43, 83,52,38, 63,36,25, 84,55,44, 122,84,63, 162,112,84, 171,118,87, 169,116,85, 164,110,80, +156,102,74, 133,81,56, 117,70,50, 90,47,33, 47,18,12, 27,10,8, 29,9,7, 33,16,17, 16,7,11, 13,6,9, 32,18,14, +50,31,25, 81,56,56, 144,115,110, 192,160,150, 202,177,163, 211,181,165, 200,162,145, 182,142,125, 130,87,71, 139,105,99, 195,175,174, +213,205,198, 134,131,117, 134,130,115, 124,118,105, 113,107,97, 108,102,92, 110,103,94, 110,102,93, 110,101,93, +//* Line # 24 +52,59,57, 52,58,56, 53,60,59, 55,64,61, 55,65,61, 55,65,60, 60,67,62, 65,68,64, 71,69,66, 71,65,56, 85,80,78, +155,131,119, 158,106,77, 108,66,45, 65,51,50, 11,5,6, 4,2,1, 14,8,9, 13,9,9, 0,0,0, 47,25,18, 149,98,86, +165,116,91, 156,112,82, 116,76,50, 118,85,66, 99,71,57, 114,85,69, 125,88,66, 154,107,79, 167,116,86, 168,116,86, 161,109,79, +153,100,72, 161,108,81, 166,112,88, 169,114,92, 156,106,84, 131,86,64, 103,59,41, 68,35,24, 27,10,9, 8,1,3, 6,2,1, +13,1,1, 32,9,8, 75,49,43, 109,77,66, 138,101,85, 154,113,95, 163,121,100, 159,116,95, 122,80,65, 142,107,101, 215,191,189, +183,169,160, 168,160,143, 134,128,109, 128,121,106, 123,118,107, 109,104,93, 105,99,89, 104,97,88, 106,98,91, +//* Line # 25 +52,59,57, 52,59,57, 54,59,59, 54,61,60, 55,64,60, 56,65,60, 61,67,61, 65,65,60, 83,78,74, 101,85,74, 139,114,101, +164,125,106, 123,74,51, 117,77,60, 64,44,37, 24,14,12, 5,2,2, 7,3,3, 13,9,10, 0,1,0, 39,19,13, 143,92,81, +167,118,95, 173,121,96, 172,116,94, 160,107,88, 163,112,95, 164,112,95, 171,115,96, 180,120,99, 171,115,90, 171,118,91, 166,115,88, +154,103,76, 160,108,82, 175,121,95, 180,122,98, 186,127,101, 183,123,92, 161,100,69, 124,74,50, 76,45,34, 15,4,3, 3,2,3, +7,4,4, 16,1,0, 25,7,3, 40,15,8, 73,43,31, 98,61,47, 126,85,67, 114,72,55, 122,85,73, 151,116,108, 201,169,161, +156,131,115, 160,143,120, 152,143,122, 137,131,115, 124,120,106, 109,104,92, 101,95,85, 101,95,86, 103,95,88, +//* Line # 26 +51,58,56, 54,60,58, 57,61,61, 57,63,63, 55,65,61, 53,64,58, 61,67,60, 72,71,65, 93,87,84, 137,116,104, 188,144,119, +153,100,73, 123,81,66, 108,73,61, 84,54,39, 41,25,19, 4,1,2, 5,1,3, 10,8,10, 5,10,5, 34,16,8, 133,82,72, +166,115,94, 171,125,100, 176,127,102, 184,132,105, 190,135,106, 189,133,106, 188,134,109, 179,129,106, 173,120,97, 172,117,93, 170,120,95, +158,110,85, 155,107,82, 171,119,94, 182,126,102, 187,132,109, 181,125,101, 172,109,80, 148,91,62, 100,59,40, 25,7,3, 5,2,2, +3,5,6, 4,3,5, 14,8,10, 26,15,14, 37,18,15, 58,32,26, 74,40,32, 93,59,48, 90,59,49, 108,71,61, 142,102,87, +150,113,89, 181,157,129, 160,148,126, 137,132,117, 123,121,106, 108,104,92, 100,95,84, 99,93,84, 98,91,85, +//* Line # 27 +50,58,54, 54,61,58, 57,63,64, 56,62,59, 57,66,61, 59,68,64, 72,76,74, 78,71,66, 106,89,78, 171,130,111, 157,108,82, +113,72,49, 112,78,64, 112,72,59, 108,69,56, 50,31,26, 3,1,2, 7,3,5, 10,8,9, 11,10,8, 34,19,14, 95,56,45, +161,113,90, 167,122,95, 177,131,102, 183,134,105, 189,141,110, 191,145,113, 189,143,114, 178,131,106, 171,119,94, 169,116,90, 177,125,100, +172,122,98, 158,108,84, 162,111,87, 176,125,99, 185,133,110, 175,125,101, 168,112,81, 157,93,66, 109,63,44, 22,10,4, 2,1,0, +7,5,8, 8,8,10, 11,7,9, 32,22,23, 60,46,45, 71,52,51, 60,39,37, 38,19,16, 35,21,14, 47,22,15, 85,47,35, +154,110,91, 200,164,142, 199,180,163, 181,173,161, 134,126,111, 117,109,95, 121,113,100, 104,96,86, 96,90,82, +//* Line # 28 +49,56,53, 52,58,57, 53,61,64, 57,64,61, 61,67,61, 73,79,77, 76,74,76, 98,82,74, 148,118,97, 176,116,90, 118,75,54, +103,81,65, 107,77,61, 129,83,67, 114,73,63, 58,37,34, 7,4,4, 5,4,3, 10,4,5, 17,10,13, 25,13,14, 57,32,23, +142,99,77, 169,116,87, 179,122,95, 187,131,104, 191,140,114, 189,144,116, 188,141,114, 183,126,101, 168,111,83, 171,118,88, 185,130,104, +188,133,109, 170,115,92, 161,108,84, 169,119,92, 180,126,100, 173,121,90, 165,111,75, 159,92,66, 112,66,51, 14,11,5, 0,3,2, +8,1,4, 14,6,5, 22,10,8, 38,21,19, 37,18,16, 32,15,14, 28,15,14, 28,19,18, 32,25,21, 52,37,34, 78,47,41, +120,76,63, 182,138,123, 216,185,171, 191,173,161, 138,123,107, 129,114,99, 131,117,103, 118,107,95, 94,85,76, +//* Line # 29 +46,52,53, 49,55,56, 54,62,65, 57,63,62, 75,79,75, 73,75,71, 80,73,69, 123,101,87, 158,120,96, 139,85,61, 112,73,55, +101,78,65, 112,82,67, 136,90,74, 119,77,65, 62,35,30, 13,8,8, 11,7,8, 8,3,4, 15,10,13, 19,11,14, 21,3,2, +105,67,51, 162,111,82, 175,116,86, 182,122,94, 183,127,99, 183,134,105, 185,137,108, 176,121,95, 170,112,85, 173,117,88, 180,124,97, +181,125,101, 161,107,82, 161,108,82, 170,117,90, 175,120,93, 173,118,89, 166,109,76, 156,93,69, 108,67,53, 13,7,3, 1,1,1, +14,4,7, 19,8,9, 29,14,13, 31,12,11, 34,12,10, 39,19,17, 49,32,32, 43,26,24, 56,34,28, 56,33,27, 90,60,50, +102,63,45, 141,98,76, 176,139,120, 196,166,151, 160,140,124, 142,123,108, 137,120,106, 141,125,114, 105,91,82, +//* Line # 30 +47,52,54, 51,56,58, 55,62,63, 62,66,66, 73,72,71, 70,66,61, 97,83,71, 151,120,99, 161,112,84, 124,74,52, 109,73,58, +100,76,65, 124,93,79, 132,88,70, 124,82,65, 69,36,28, 23,12,13, 15,9,10, 10,4,4, 8,3,7, 25,19,22, 19,7,8, +58,30,20, 150,102,75, 172,112,81, 179,116,87, 182,122,92, 181,129,97, 180,129,100, 174,119,93, 171,112,85, 167,108,79, 171,113,87, +171,115,90, 164,108,84, 161,106,81, 169,112,86, 169,113,86, 171,114,85, 167,106,78, 152,95,73, 94,62,50, 9,2,0, 11,5,6, +24,12,15, 23,11,12, 34,16,17, 39,17,17, 46,21,20, 57,33,31, 53,31,31, 45,22,21, 48,18,16, 53,30,27, 54,32,23, +89,60,42, 124,87,64, 161,119,100, 172,133,117, 200,173,155, 192,167,151, 151,128,115, 139,118,107, 116,97,87, +//* Line # 31 +56,58,59, 63,64,65, 64,68,64, 73,71,71, 79,72,73, 81,71,64, 140,120,100, 180,141,113, 161,103,73, 131,83,59, 119,83,68, +110,80,70, 131,96,82, 134,92,69, 138,94,74, 77,37,27, 37,19,19, 22,10,11, 19,9,8, 8,3,5, 14,11,13, 43,30,30, +38,16,14, 112,68,47, 168,111,82, 177,113,84, 181,117,87, 180,123,91, 178,124,94, 175,118,91, 177,116,90, 173,113,86, 166,109,84, +162,107,83, 160,107,83, 157,101,78, 165,107,83, 166,111,84, 170,112,85, 167,105,81, 146,100,79, 64,43,35, 5,0,0, 24,14,15, +24,13,14, 28,15,18, 31,13,14, 45,21,20, 42,15,13, 45,19,17, 53,29,27, 42,17,16, 47,21,23, 45,29,31, 28,16,13, +57,38,26, 133,100,83, 180,137,119, 204,161,145, 227,196,175, 191,162,144, 161,135,119, 133,109,96, 127,102,90, +//* Line # 32 +69,66,64, 73,70,67, 78,77,68, 89,81,79, 99,86,87, 97,81,70, 174,148,122, 180,136,103, 161,97,67, 131,82,56, 128,87,70, +130,91,80, 139,100,83, 137,95,69, 141,96,73, 89,44,32, 49,24,22, 31,13,11, 26,11,8, 17,10,10, 7,4,7, 32,23,24, +63,42,39, 81,44,29, 150,99,75, 174,112,87, 180,115,86, 181,121,89, 177,121,89, 176,118,90, 173,113,88, 160,99,76, 157,101,78, +160,108,86, 160,109,88, 142,89,67, 128,71,49, 158,105,79, 166,110,83, 166,103,81, 131,95,75, 22,14,10, 11,3,3, 29,16,16, +20,11,10, 25,14,16, 27,10,11, 39,15,14, 48,21,18, 54,27,24, 56,31,27, 44,21,18, 41,22,24, 33,23,26, 26,16,17, +61,40,33, 89,53,38, 147,100,82, 200,153,135, 206,171,148, 188,156,136, 159,132,115, 147,121,107, 169,142,128, +//* Line # 33 +82,76,69, 85,79,72, 95,89,74, 103,90,87, 106,87,89, 117,96,85, 172,143,112, 174,127,90, 167,99,69, 144,93,64, 138,92,72, +132,87,75, 152,109,90, 148,106,77, 151,107,81, 104,56,43, 61,31,28, 44,21,17, 38,20,13, 26,17,15, 12,9,11, 13,4,6, +40,18,17, 77,45,31, 118,73,54, 173,113,92, 181,115,88, 183,120,89, 178,121,89, 178,118,88, 146,85,61, 141,82,62, 175,122,101, +186,138,118, 175,127,108, 140,88,70, 133,76,58, 160,110,85, 167,112,84, 166,104,82, 91,63,46, 2,0,0, 15,7,6, 29,16,15, +19,13,10, 17,7,9, 26,11,11, 39,17,16, 48,22,18, 63,37,33, 49,24,19, 43,22,16, 41,26,20, 34,21,22, 38,21,21, +89,57,50, 181,134,118, 201,146,124, 195,141,117, 195,159,133, 183,150,129, 186,158,141, 217,192,177, 209,181,165, +//* Line # 34 +96,86,77, 96,85,76, 105,93,80, 111,94,87, 109,88,83, 131,107,92, 171,138,111, 162,117,85, 173,114,86, 161,105,74, 162,109,83, +151,101,79, 147,101,76, 152,107,79, 162,116,91, 112,63,47, 69,32,24, 54,27,21, 43,24,20, 32,22,20, 18,11,11, 13,3,4, +22,7,8, 37,16,9, 74,41,28, 142,93,73, 173,114,85, 179,117,84, 179,119,87, 176,118,90, 151,91,67, 139,79,56, 141,85,64, +143,89,70, 148,95,77, 150,95,76, 156,98,78, 167,114,88, 163,112,84, 147,99,81, 36,18,13, 0,0,1, 18,12,12, 28,14,13, +23,13,9, 17,6,7, 24,8,8, 40,18,16, 55,31,27, 53,29,25, 47,24,20, 38,21,17, 24,15,12, 24,13,13, 38,19,20, +90,57,53, 137,91,79, 109,55,37, 152,100,80, 201,167,145, 219,186,165, 241,210,188, 233,203,180, 211,181,160, +//* Line # 35 +107,93,84, 109,95,86, 114,97,89, 117,100,88, 116,96,81, 127,101,84, 167,133,113, 131,90,68, 170,126,102, 189,133,104, 193,137,106, +198,147,116, 182,135,105, 174,126,101, 142,93,71, 118,67,48, 76,33,19, 57,27,21, 34,18,18, 28,18,19, 20,10,8, 16,6,4, +16,9,10, 15,6,7, 35,17,11, 79,45,28, 153,103,74, 171,112,79, 174,114,83, 173,116,90, 176,118,91, 165,103,76, 161,100,76, +170,109,89, 171,111,91, 164,105,83, 167,110,84, 174,116,89, 164,114,89, 98,71,58, 3,0,0, 0,0,1, 14,10,12, 33,19,16, +31,14,11, 20,7,7, 34,16,15, 50,28,26, 50,27,25, 46,25,23, 39,22,20, 24,12,11, 18,15,14, 26,19,18, 32,18,18, +41,19,18, 56,26,23, 59,23,18, 93,52,45, 146,103,91, 179,134,116, 177,130,107, 165,120,93, 156,115,92, +//* Line # 36 +109,95,86, 109,95,85, 110,95,84, 116,100,88, 117,100,85, 115,94,77, 153,126,107, 110,79,59, 116,79,59, 155,108,82, 182,136,108, +212,168,141, 215,175,149, 198,153,129, 187,136,115, 124,69,50, 72,30,17, 53,24,19, 30,15,15, 23,14,15, 19,10,8, 19,9,7, +19,11,11, 6,1,1, 25,11,8, 50,19,10, 101,53,36, 152,94,71, 169,109,82, 171,115,85, 174,116,86, 175,116,87, 171,112,86, +167,108,85, 169,111,88, 177,119,95, 178,122,96, 173,115,87, 160,108,83, 73,43,31, 6,0,0, 0,0,2, 12,8,11, 30,17,15, +28,12,10, 27,12,15, 37,19,20, 41,19,19, 37,15,14, 26,8,6, 20,6,6, 26,16,13, 23,19,10, 22,16,10, 24,16,11, +32,20,16, 36,18,15, 64,41,37, 100,69,62, 148,94,80, 167,113,94, 163,108,86, 148,96,74, 144,98,80, +//* Line # 37 +109,95,84, 108,94,83, 110,95,81, 111,96,83, 115,101,85, 108,92,76, 128,108,91, 119,95,79, 105,77,61, 136,99,78, 123,86,63, +150,115,92, 197,161,139, 205,164,143, 190,140,121, 129,71,52, 75,33,22, 46,19,15, 28,14,16, 19,11,12, 16,7,5, 20,10,8, +21,12,12, 3,1,1, 18,9,8, 46,17,16, 77,30,23, 115,56,42, 150,90,66, 168,112,79, 173,116,83, 178,118,88, 180,121,92, +182,124,96, 181,124,96, 184,128,100, 177,121,92, 169,110,81, 143,88,63, 72,40,29, 7,0,0, 1,1,3, 7,4,7, 24,13,11, +23,8,7, 30,14,18, 30,12,14, 32,11,12, 30,9,9, 31,14,13, 30,18,17, 22,14,12, 10,7,2, 5,3,0, 9,4,1, +36,26,22, 52,35,31, 46,23,18, 82,52,42, 146,103,80, 187,145,120, 187,145,119, 188,152,127, 185,156,136, +//* Line # 38 +115,101,89, 110,96,84, 111,96,81, 113,99,83, 114,100,84, 111,97,81, 102,85,69, 137,116,101, 121,98,84, 126,94,75, 131,100,81, +107,80,62, 132,103,86, 181,146,129, 189,144,128, 139,84,67, 73,33,23, 40,15,12, 22,9,12, 15,7,10, 15,6,5, 24,14,12, +20,11,11, 4,1,2, 22,11,12, 47,17,17, 83,34,28, 126,67,52, 143,83,57, 152,95,61, 166,108,74, 178,118,86, 182,123,91, +184,125,93, 180,122,90, 175,118,87, 169,112,82, 159,99,69, 138,81,56, 77,42,31, 9,0,0, 1,1,3, 7,6,8, 19,11,10, +22,8,8, 23,9,12, 37,18,20, 39,19,18, 41,20,19, 47,30,28, 27,13,11, 15,7,6, 9,7,12, 9,7,10, 11,5,6, +41,28,24, 48,23,17, 82,46,36, 129,87,73, 166,126,103, 206,164,141, 205,164,141, 198,162,139, 207,178,159, +//* Line # 39 +117,104,90, 115,102,88, 128,111,96, 124,108,92, 119,104,88, 115,99,82, 111,92,76, 118,96,80, 135,109,95, 147,115,98, 161,132,116, +171,148,133, 211,192,179, 204,177,164, 202,165,152, 146,99,84, 68,32,23, 37,14,12, 17,5,8, 14,7,10, 17,8,8, 30,19,16, +16,7,6, 12,3,5, 32,14,14, 58,23,17, 103,51,36, 138,76,53, 158,95,65, 158,98,64, 155,94,60, 167,104,71, 174,112,77, +175,114,78, 169,109,74, 161,101,68, 163,104,73, 161,97,68, 138,79,53, 82,45,33, 9,0,0, 0,0,3, 3,4,6, 12,5,5, +27,16,14, 22,9,9, 32,14,13, 43,21,19, 55,31,29, 50,28,26, 40,21,19, 24,10,11, 14,6,14, 13,7,12, 16,8,10, +29,14,12, 39,13,7, 65,26,18, 102,56,46, 135,82,68, 163,109,94, 165,110,95, 151,98,84, 132,83,70, +//* Line # 40 +123,110,95, 124,110,95, 139,121,106, 134,116,100, 127,109,93, 123,104,86, 122,99,82, 124,96,80, 127,96,80, 152,117,101, 168,138,123, +186,165,154, 218,202,192, 233,215,206, 208,179,169, 139,101,88, 68,34,27, 41,18,18, 13,2,6, 8,2,5, 20,11,10, 27,16,13, +10,2,2, 23,9,12, 43,18,16, 85,44,29, 127,71,44, 147,83,48, 164,99,63, 167,104,72, 165,102,69, 166,99,66, 171,107,70, +174,110,72, 170,107,70, 167,104,69, 168,105,74, 162,96,66, 134,74,49, 89,53,37, 10,1,0, 0,0,3, 1,1,3, 6,2,2, +18,9,6, 29,18,14, 35,18,14, 50,27,23, 62,36,32, 64,37,33, 51,26,24, 43,20,18, 30,12,9, 20,7,5, 18,10,8, +21,12,10, 25,10,10, 36,12,12, 48,16,14, 83,38,28, 107,59,48, 118,68,56, 112,61,48, 155,105,90, +//* Line # 41 +137,124,106, 137,125,106, 145,126,111, 160,139,125, 178,157,144, 169,148,136, 186,165,152, 203,182,168, 221,201,186, 228,197,182, 208,176,161, +212,184,170, 221,201,189, 239,223,213, 216,188,180, 123,86,80, 67,36,29, 35,14,16, 14,4,11, 12,9,9, 19,15,11, 11,3,3, +18,9,8, 41,16,12, 73,35,25, 111,62,42, 136,78,46, 154,89,52, 164,100,62, 166,103,69, 170,106,73, 172,106,73, 173,108,73, +175,111,74, 172,107,72, 172,108,73, 170,106,74, 157,92,60, 132,71,43, 109,66,49, 31,9,7, 4,0,2, 1,1,4, 2,1,4, +6,1,3, 17,7,7, 33,17,15, 45,22,17, 55,27,22, 50,22,17, 46,23,22, 37,18,16, 40,21,14, 35,20,14, 30,21,16, +27,21,18, 30,20,19, 38,22,25, 52,31,32, 73,46,36, 80,46,34, 96,53,38, 129,81,63, 165,118,98, +//* Line # 42 +151,138,116, 154,140,117, 162,142,123, 189,166,150, 226,200,190, 221,193,186, 218,192,185, 225,206,196, 215,199,188, 228,196,174, 204,165,138, +187,146,116, 179,137,108, 199,158,133, 206,164,146, 127,84,72, 69,40,29, 44,22,28, 25,13,24, 18,16,10, 7,6,1, 17,5,9, +39,21,18, 77,37,23, 108,56,38, 126,70,48, 142,83,54, 153,92,59, 160,98,63, 167,107,71, 171,109,75, 174,109,77, 174,110,77, +177,113,80, 173,109,76, 174,110,76, 172,107,74, 153,89,55, 131,70,39, 124,72,54, 73,35,31, 32,12,16, 4,1,4, 1,1,5, +0,1,5, 2,2,5, 13,8,7, 24,12,7, 40,17,12, 48,23,20, 32,17,17, 24,14,15, 29,14,12, 27,15,12, 26,14,12, +28,17,14, 28,13,11, 33,14,14, 40,20,19, 48,26,20, 67,35,24, 125,79,62, 156,101,80, 149,95,77, +//* Line # 43 +166,148,124, 172,152,127, 179,159,131, 189,164,139, 200,172,153, 188,152,137, 147,103,91, 163,121,110, 136,90,77, 175,126,94, 221,172,134, +217,167,128, 210,159,120, 205,157,120, 209,161,130, 127,80,53, 76,45,29, 45,21,24, 27,10,15, 18,7,2, 18,3,0, 41,14,19, +72,39,33, 102,58,43, 115,63,45, 134,79,57, 147,90,63, 153,93,62, 159,97,65, 167,106,73, 172,110,77, 175,112,79, 176,113,79, +177,114,80, 174,112,78, 174,110,77, 170,107,73, 147,84,52, 130,70,42, 128,76,58, 91,51,44, 46,19,19, 12,0,1, 6,0,0, +2,0,0, 0,2,1, 0,3,0, 5,4,2, 17,7,6, 43,24,25, 32,14,16, 24,10,10, 32,16,15, 27,14,12, 21,9,8, +18,7,5, 17,6,4, 25,11,10, 28,13,12, 43,22,16, 64,34,25, 124,83,69, 163,115,98, 140,92,75, +//* Line # 44 +182,156,130, 186,159,132, 177,147,117, 193,164,138, 216,183,161, 174,129,112, 170,119,105, 163,108,95, 153,98,83, 146,89,69, 144,86,64, +145,87,65, 147,90,68, 131,78,57, 125,74,57, 76,26,13, 49,16,3, 36,8,7, 38,12,11, 48,23,12, 78,47,43, 85,42,49, +105,57,48, 109,59,40, 111,60,41, 124,71,49, 136,80,56, 143,85,58, 153,94,65, 161,102,70, 171,110,78, 176,114,81, 177,115,82, +177,115,82, 173,111,78, 172,110,78, 163,101,68, 145,83,52, 129,71,46, 122,69,50, 109,65,53, 63,26,20, 59,29,25, 44,18,15, +26,9,7, 10,3,1, 2,3,0, 0,1,0, 5,0,1, 28,13,16, 36,19,19, 27,11,9, 52,35,34, 40,24,23, 31,18,15, +28,16,13, 29,18,15, 35,25,22, 45,33,30, 58,39,34, 59,34,27, 82,49,38, 110,71,58, 115,75,61, +//* Line # 45 +198,167,139, 187,151,123, 182,136,113, 219,173,152, 182,135,118, 177,131,116, 181,137,122, 179,135,119, 177,133,116, 178,125,112, 171,116,103, +162,106,93, 153,98,86, 144,92,81, 130,83,73, 111,65,57, 89,53,39, 83,50,42, 97,61,54, 120,83,68, 142,97,96, 111,56,66, +144,87,77, 145,92,71, 136,85,66, 131,79,58, 128,75,53, 128,73,49, 134,77,51, 144,86,59, 158,98,68, 167,106,75, 174,114,83, +172,112,81, 166,105,75, 166,105,75, 155,94,63, 142,82,54, 122,64,42, 113,60,40, 108,60,43, 75,32,20, 80,38,29, 97,55,49, +83,41,35, 63,25,19, 40,13,8, 29,10,8, 22,4,5, 24,6,6, 37,21,17, 25,11,6, 44,25,23, 53,33,31, 34,16,13, +33,17,13, 33,18,14, 30,17,14, 37,24,20, 40,22,19, 39,19,14, 43,19,13, 79,51,44, 109,77,67, +//* Line # 46 +207,172,144, 178,137,109, 191,134,114, 177,121,103, 173,123,106, 173,128,113, 172,131,115, 171,133,115, 173,135,116, 177,133,110, 175,127,104, +173,124,102, 169,121,99, 165,119,97, 159,115,94, 150,109,87, 142,103,84, 138,99,86, 142,99,86, 147,101,84, 144,91,94, 115,55,70, +156,98,88, 160,106,84, 153,102,82, 150,99,80, 147,96,76, 146,93,73, 152,97,74, 150,92,67, 150,90,64, 154,94,68, 159,99,73, +158,98,71, 152,92,66, 155,96,69, 141,81,54, 130,71,48, 114,57,37, 105,51,30, 103,52,32, 92,43,28, 91,41,31, 89,38,33, +108,51,47, 109,48,38, 101,52,41, 86,45,34, 64,25,17, 50,17,11, 41,19,12, 29,12,5, 33,10,6, 38,15,10, 44,19,15, +47,21,17, 41,19,14, 45,24,19, 35,15,10, 32,16,14, 35,20,17, 28,13,11, 41,23,19, 62,37,30, +//* Line # 47 +196,158,130, 190,146,119, 168,110,86, 173,116,94, 172,120,99, 172,125,104, 173,127,107, 178,131,111, 180,133,112, 179,134,112, 177,131,109, +175,127,108, 172,122,104, 170,120,103, 166,119,100, 160,114,94, 157,113,93, 158,113,97, 160,111,93, 157,107,88, 145,88,96, 116,58,78, +157,104,95, 157,106,82, 157,105,85, 158,108,89, 156,106,89, 155,104,86, 158,105,84, 166,110,87, 159,100,77, 154,94,72, 148,89,66, +148,88,65, 151,91,69, 154,94,72, 147,88,65, 145,85,66, 141,83,66, 139,84,63, 139,86,65, 140,87,70, 143,89,79, 111,55,53, +137,78,72, 148,88,68, 139,83,61, 124,70,46, 114,60,39, 104,56,44, 69,36,28, 36,13,5, 48,24,15, 54,26,20, 70,40,34, +56,24,20, 67,36,31, 67,38,32, 51,25,19, 25,12,11, 27,16,16, 20,12,11, 21,10,8, 39,20,15, +//* Line # 48 +180,141,112, 183,135,108, 162,105,78, 173,118,92, 173,121,96, 174,124,101, 176,126,105, 180,128,107, 181,129,108, 178,130,114, 176,128,114, +175,125,114, 174,122,112, 174,122,112, 174,123,112, 171,120,110, 169,123,103, 168,119,107, 163,118,101, 166,111,94, 146,89,99, 123,62,86, +157,110,98, 156,106,86, 156,104,84, 156,107,88, 160,110,92, 161,110,92, 157,105,85, 163,108,87, 164,107,86, 159,101,80, 151,93,73, +154,97,76, 159,102,81, 158,101,80, 158,100,79, 156,99,80, 154,99,80, 155,101,79, 156,104,80, 158,106,84, 161,107,93, 130,74,68, +118,61,57, 130,76,60, 128,75,45, 130,74,46, 138,81,59, 134,80,58, 107,61,46, 47,14,9, 53,29,26, 70,39,32, 87,48,39, +90,47,36, 87,45,34, 90,52,42, 91,58,50, 53,28,21, 27,10,8, 23,11,11, 15,6,7, 38,22,20, +//* Line # 49 +179,138,109, 177,125,96, 159,103,78, 173,118,94, 175,121,98, 175,123,101, 176,126,105, 176,127,108, 176,129,110, 176,128,110, 173,125,107, +173,125,108, 176,127,111, 174,126,112, 177,128,115, 176,127,114, 174,132,108, 175,126,121, 166,127,115, 177,120,104, 145,88,99, 133,66,92, +161,118,99, 157,108,95, 157,108,89, 155,105,86, 157,107,88, 160,108,88, 160,108,88, 158,106,85, 160,106,86, 162,107,87, 158,103,83, +160,105,84, 161,106,85, 158,104,83, 156,101,80, 157,104,84, 157,106,85, 156,106,81, 156,106,78, 156,105,79, 153,101,81, 135,82,67, +106,50,50, 119,63,64, 121,69,41, 129,75,53, 138,83,68, 142,90,59, 135,81,54, 74,28,22, 42,19,19, 84,49,43, 101,55,41, +111,58,40, 131,80,61, 95,50,35, 97,55,40, 104,60,43, 53,21,11, 31,13,11, 27,15,17, 27,12,11, +//* Line # 50 +190,148,119, 169,116,89, 158,101,76, 171,116,91, 175,121,98, 176,123,101, 177,126,105, 178,128,107, 177,127,107, 174,126,108, 173,125,108, +172,124,107, 173,126,110, 175,128,114, 180,133,120, 182,135,123, 180,137,115, 179,131,124, 170,130,116, 178,123,110, 142,84,98, 144,80,100, +164,120,102, 161,113,98, 161,112,93, 157,108,89, 154,104,85, 155,104,85, 159,108,88, 158,106,85, 155,102,81, 158,104,84, 161,107,87, +158,105,84, 155,101,81, 153,99,78, 153,99,78, 156,103,83, 156,105,85, 156,105,83, 154,103,77, 152,100,76, 150,98,78, 142,90,75, +111,56,54, 123,66,68, 130,76,57, 131,78,59, 137,83,65, 139,88,57, 140,88,60, 118,70,56, 58,23,15, 66,26,17, 98,53,41, +108,59,46, 133,86,70, 126,81,65, 87,42,25, 104,59,43, 85,51,41, 42,20,17, 30,14,15, 34,14,13, +//* Line # 51 +182,139,112, 164,109,83, 162,105,80, 169,113,89, 174,119,94, 176,122,98, 175,122,100, 175,122,100, 175,123,102, 173,124,104, 171,121,103, +172,124,106, 175,128,112, 174,128,114, 181,136,123, 182,138,126, 181,138,119, 178,132,123, 172,129,114, 176,122,114, 138,76,96, 158,97,108, +171,125,109, 167,119,104, 163,115,97, 161,113,95, 159,109,91, 159,108,90, 159,108,88, 158,107,87, 156,105,84, 155,102,82, 158,105,85, +156,103,83, 154,102,82, 153,101,81, 152,100,80, 154,102,83, 155,104,85, 154,103,82, 151,101,78, 152,102,79, 151,100,81, 147,96,80, +123,69,63, 111,54,58, 139,85,77, 136,84,72, 135,84,64, 138,87,57, 141,90,61, 142,89,69, 120,72,53, 74,28,13, 65,20,9, +91,48,36, 114,69,56, 126,79,62, 110,62,42, 85,38,22, 96,58,48, 47,21,18, 28,7,7, 44,19,18, +//* Line # 52 +163,119,93, 163,108,83, 168,111,86, 171,115,90, 177,121,96, 176,121,96, 175,121,97, 175,121,97, 174,120,96, 172,119,97, 167,114,94, +171,120,101, 173,124,107, 173,127,111, 180,136,122, 184,141,128, 184,140,123, 178,135,124, 178,133,115, 177,124,122, 136,71,96, 165,109,109, +170,123,109, 166,121,104, 166,118,102, 165,117,99, 166,117,99, 162,112,94, 160,110,91, 158,107,88, 157,106,86, 155,104,84, 155,104,84, +158,106,86, 159,108,88, 160,109,89, 158,106,87, 156,105,86, 155,105,86, 154,103,84, 153,103,82, 152,102,82, 151,101,83, 150,99,82, +142,88,77, 110,53,54, 136,81,85, 142,91,85, 139,91,68, 138,89,60, 143,91,64, 150,95,69, 151,95,69, 136,85,65, 100,54,40, +76,32,20, 83,37,23, 113,63,44, 126,75,53, 95,46,31, 75,34,24, 65,35,30, 46,20,19, 49,21,19, +//* Line # 53 +172,128,103, 162,105,82, 171,114,89, 173,117,91, 177,120,95, 177,121,95, 178,121,96, 176,120,95, 174,117,92, 170,112,87, 164,107,83, +170,115,93, 174,123,102, 175,128,109, 183,138,120, 184,141,125, 184,138,123, 176,135,123, 181,135,113, 172,122,125, 135,67,98, 174,121,112, +175,127,114, 167,123,105, 166,119,103, 164,117,100, 165,117,100, 163,114,96, 162,112,93, 160,110,91, 159,109,89, 156,106,87, 154,104,85, +154,104,85, 158,108,89, 160,111,91, 162,112,91, 160,111,92, 160,110,92, 158,108,90, 156,107,88, 155,105,87, 154,105,86, 154,103,85, +155,103,85, 129,72,69, 119,64,77, 146,96,94, 142,97,72, 140,93,66, 143,91,67, 148,93,67, 154,98,71, 153,98,76, 150,98,80, +145,94,78, 121,70,53, 102,50,29, 106,55,33, 108,60,45, 68,27,16, 53,21,14, 97,70,65, 53,25,20, +//* Line # 54 +158,113,89, 165,106,85, 171,113,88, 174,117,91, 175,118,92, 177,120,93, 176,118,91, 175,118,91, 172,114,87, 169,106,80, 162,101,75, +169,111,86, 175,121,97, 176,126,105, 180,134,115, 182,138,119, 183,136,122, 176,137,124, 186,138,114, 165,117,121, 138,67,102, 182,131,115, +177,126,115, 168,124,107, 165,119,102, 161,114,98, 162,115,97, 161,113,95, 161,112,94, 162,113,94, 162,114,94, 162,114,94, 162,113,94, +160,111,92, 159,110,91, 160,111,91, 160,112,92, 161,112,92, 161,111,94, 160,111,94, 158,109,92, 157,108,91, 155,106,88, 154,105,86, +156,105,82, 150,92,84, 110,54,74, 143,95,94, 144,102,73, 143,96,72, 144,91,72, 148,93,68, 152,98,74, 157,101,78, 160,103,80, +161,102,80, 160,104,82, 147,94,72, 123,72,52, 93,47,32, 76,36,24, 49,17,9, 52,25,19, 57,29,23, +//* Line # 55 +157,111,87, 170,110,87, 171,113,85, 175,118,90, 176,119,91, 177,119,92, 175,117,89, 177,118,90, 174,115,86, 165,102,72, 160,97,70, +168,106,83, 173,116,92, 178,125,102, 179,131,110, 182,136,118, 183,140,126, 180,141,123, 188,134,121, 156,95,122, 147,74,110, 185,134,112, +172,127,112, 167,125,109, 166,119,104, 162,114,99, 163,112,98, 162,111,96, 162,113,95, 160,114,95, 163,115,95, 167,118,100, 167,120,102, +165,118,100, 164,116,99, 162,114,95, 160,112,93, 160,111,92, 161,111,92, 162,112,95, 160,110,94, 159,109,93, 157,107,90, 154,104,87, +154,105,82, 156,105,93, 113,56,78, 119,63,78, 151,102,89, 148,100,80, 147,96,76, 148,95,72, 151,98,76, 156,100,77, 162,101,77, +164,102,77, 163,103,77, 161,106,82, 158,106,82, 143,92,71, 105,60,44, 64,27,15, 54,22,13, 63,32,23, +//* Line # 56 +158,112,87, 174,111,85, 170,111,79, 175,117,86, 177,118,90, 176,117,90, 177,117,90, 179,119,90, 176,116,86, 163,101,70, 149,85,60, +168,104,84, 175,114,92, 180,125,99, 179,129,106, 182,135,119, 180,143,129, 186,144,121, 178,112,126, 135,50,115, 140,63,102, 181,127,110, +169,132,112, 164,124,111, 165,119,104, 161,110,98, 160,106,95, 160,106,95, 159,110,94, 159,114,95, 162,114,95, 168,117,102, 169,121,106, +167,121,108, 166,121,107, 163,117,101, 159,113,94, 162,113,94, 164,113,95, 161,110,93, 158,107,92, 157,106,92, 156,105,91, 156,104,89, +151,105,87, 149,109,93, 122,62,79, 109,37,83, 144,79,110, 155,103,90, 148,102,74, 146,96,77, 149,95,72, 155,99,76, 162,103,78, +165,106,79, 165,106,78, 166,109,80, 165,107,78, 164,103,74, 146,91,67, 111,64,45, 70,30,16, 65,29,18, +//* Line # 57 +166,121,93, 171,111,81, 169,110,77, 173,115,84, 175,116,88, 176,116,91, 178,119,92, 179,120,92, 178,119,90, 168,106,75, 138,75,49, +166,103,80, 176,115,89, 180,125,94, 183,133,105, 184,136,115, 183,141,120, 193,141,134, 149,76,107, 133,45,109, 137,54,105, 171,107,122, +178,129,129, 164,124,110, 161,121,100, 159,114,96, 157,109,92, 157,105,89, 155,104,87, 158,109,91, 163,113,95, 168,118,102, 172,124,109, +174,128,113, 172,127,112, 170,125,108, 167,119,102, 164,116,99, 161,113,97, 159,112,96, 159,111,95, 157,108,92, 154,106,90, 154,105,89, +150,107,89, 150,110,91, 131,69,80, 122,40,105, 124,46,108, 156,97,96, 152,105,79, 148,99,86, 148,94,69, 151,96,69, 157,100,71, +166,106,78, 169,110,82, 169,112,84, 167,109,82, 166,105,77, 153,98,73, 124,76,57, 75,35,20, 57,22,12, +//* Line # 58 +184,143,111, 171,112,79, 173,113,80, 173,114,83, 174,115,87, 176,116,90, 176,117,91, 178,120,93, 180,122,94, 173,111,81, 144,81,54, +161,99,73, 177,117,87, 181,125,90, 185,134,102, 182,134,110, 187,136,115, 182,118,131, 133,50,103, 142,50,115, 144,54,117, 137,59,110, +182,120,146, 173,127,122, 163,124,107, 160,117,99, 155,110,90, 153,106,85, 153,102,82, 157,104,86, 162,109,92, 167,117,98, 172,124,108, +176,130,115, 174,130,115, 174,129,113, 172,124,107, 168,122,107, 164,118,106, 161,114,101, 157,112,96, 157,112,95, 155,110,92, 155,108,92, +151,110,91, 149,107,91, 133,65,88, 127,37,115, 126,39,120, 133,65,92, 159,107,98, 150,100,88, 148,95,68, 147,93,64, 152,95,65, +163,104,74, 171,112,83, 171,113,88, 170,112,87, 172,111,83, 160,104,78, 134,83,62, 79,37,21, 63,28,18, +}; + + + +//******************************************************************************* +void DisplayRawRGB(uint8_t *rgbData, int xLoc, int yLoc) +{ +int imageWidth, imageHeight; +int byte1, byte2; +long dataIndex; +int ii, jj; +RGBColor myColor; +int myXX, myYY; + + + dataIndex = 0; + byte1 = pgm_read_byte(rgbData + dataIndex++); + byte2 = pgm_read_byte(rgbData + dataIndex++); + imageWidth = (byte1 << 8) + byte2; + byte1 = pgm_read_byte(rgbData + dataIndex++); + byte2 = pgm_read_byte(rgbData + dataIndex++); + imageHeight = (byte1 << 8) + byte2; + + //* if x,y are negitive, then center + myXX = xLoc; + myYY = yLoc; + if (myXX < 0) + { + myXX = (gWidth - imageWidth) / 2; + } + if (myYY < 0) + { + myYY = (gHeight - imageHeight) / 2; + } + if (imageWidth < 100) + { + myXX = 0; + myYY = 0; + } + for (jj=0; jj +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + +#---------------- Programming Options (STK500) ---------------- +# Programming hardware: stk500 + +STK500 = stk500 + +# Location of STK500.exe - no trailing '\' +STK500_PATH = C:\Program Files\Atmel\AVR Tools\STK500 + +# The STK500 AVR ISP MKII is USB. The USB drivers must already be installed. +# Do this normally by installing AVR Studio. +STK500_PORT = USB + +#-erase chip -Program Flash -Verify Flash -File name -Serial programing(ISP) +STK500_WRITE_FLASH = -e -pf -vf -if$(TARGET).hex -ms +STK500_WRITE_FLASH += -s + +#Program the Fuse Bytes +#STK500_FLAGS = -d$(MCU) -c$(STK500_PORT) -fFF79 -FFF79 +#Skip the Fuse Bytes +STK500_FLAGS = -d$(MCU) -c$(STK500_PORT) + +#-Set ISP frequency to 250kHz. Limit is 1/4 of internal osc which is default 1MHz +STK500_FLAGS += -I250kHz + +#---------------- Programming Options (avrdude serial bootloader) ---------------- + +#"C:\arduino\hardware\tools\avr\bin\avrdude" -PCOM28 -c stk500v1 -patmega168 -b19200 -Uflash:w:Simon-PTH-v1.hex -V -F -C"C:\arduino\hardware\tools\avr\etc\avrdude.conf" +SERIAL_AVRDUDE = "C:\Documents and Settings\Administrator\Desktop\Arduino 16\arduino-0016\hardware\tools\avr\bin\avrdude" +SERIAL_AVRDUDE_CONFIG = "C:\Documents and Settings\Administrator\Desktop\Arduino 16\arduino-0016\hardware\tools\avr\etc\avrdude.conf" +SERIAL_AVRDUDE_PORT = COM2 +SERIAL_AVRDUDE_SPEED = 57600 +SERIAL_AVRDUDE_PROGRAMMER = stk500v1 + +SERIAL_AVRDUDE_FLAGS = -p $(MCU) -P $(SERIAL_AVRDUDE_PORT) -c $(SERIAL_AVRDUDE_PROGRAMMER) -b $(SERIAL_AVRDUDE_SPEED) +SERIAL_AVRDUDE_FLAGS += -C$(SERIAL_AVRDUDE_CONFIG) +SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + +#---------------- Debugging Options ---------------- + +# For simulavr only - target MCU frequency. +DEBUG_MFREQ = $(F_CPU) + +# Set the DEBUG_UI to either gdb or insight. +# DEBUG_UI = gdb +DEBUG_UI = insight + +# Set the debugging back-end to either avarice, simulavr. +DEBUG_BACKEND = avarice +#DEBUG_BACKEND = simulavr + +# GDB Init Filename. +GDBINIT_FILE = __avr_gdbinit + +# When using avarice settings for the JTAG +JTAG_DEV = /dev/com1 + +# Debugging port used to communicate between GDB / avarice / simulavr. +DEBUG_PORT = 4242 + +# Debugging host used to communicate between GDB / avarice / simulavr, normally +# just set to localhost unless doing some sort of crazy debugging when +# avarice is running on a different computer. +DEBUG_HOST = localhost + + + +#============================================================================ + + +# Define programs and commands. +SHELL = sh +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +AR = avr-ar rcs +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +REMOVEDIR = rm -rf +COPY = cp +WINSHELL = cmd + + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling C: +MSG_COMPILING_CPP = Compiling C++: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: +MSG_CREATING_LIBRARY = Creating library: + + + + +# Define all object files. +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) + +# Define all listing files. +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) + + +# Compiler flags to generate dependency files. +GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + + + +# Default target. +all: begin gccversion sizebefore build sizeafter end + +# Change the build target to build a HEX file or a library. +build: elf hex eep lss sym +#build: lib + + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym +LIBNAME=lib$(TARGET).a +lib: $(LIBNAME) + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf + +sizebefore: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +sizeafter: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ + 2>/dev/null; echo; fi + + + +# Display compiler version information. +gccversion : + @$(CC) --version + + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + +program_stk500: $(TARGET).hex $(TARGET).eep + $(STK500_PATH)\$(STK500) $(STK500_FLAGS) $(STK500_WRITE_FLASH) + +program_serial: $(TARGET).hex $(TARGET).eep + $(SERIAL_AVRDUDE) $(SERIAL_AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) + +# Generate avr-gdb config/init file which does the following: +# define the reset signal, load the target file, connect to target, and set +# a breakpoint at main(). +gdb-config: + @$(REMOVE) $(GDBINIT_FILE) + @echo define reset >> $(GDBINIT_FILE) + @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) + @echo end >> $(GDBINIT_FILE) + @echo file $(TARGET).elf >> $(GDBINIT_FILE) + @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) +ifeq ($(DEBUG_BACKEND),simulavr) + @echo load >> $(GDBINIT_FILE) +endif + @echo break main >> $(GDBINIT_FILE) + +debug: gdb-config $(TARGET).elf +ifeq ($(DEBUG_BACKEND), avarice) + @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. + @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ + $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) + @$(WINSHELL) /c pause + +else + @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ + $(DEBUG_MFREQ) --port $(DEBUG_PORT) +endif + @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT = $(OBJCOPY) --debugging +COFFCONVERT += --change-section-address .data-0x800000 +COFFCONVERT += --change-section-address .bss-0x800000 +COFFCONVERT += --change-section-address .noinit-0x800000 +COFFCONVERT += --change-section-address .eeprom-0x810000 + + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Create library from object files. +.SECONDARY : $(TARGET).a +.PRECIOUS : $(OBJ) +%.a: $(OBJ) + @echo + @echo $(MSG_CREATING_LIBRARY) $@ + $(AR) $@ $(OBJ) + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +$(OBJDIR)/%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create object files from C++ source files. +$(OBJDIR)/%.o : %.cpp + @echo + @echo $(MSG_COMPILING_CPP) $< + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C++ source files. +%.s : %.cpp + $(CC) -S $(ALL_CPPFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +$(OBJDIR)/%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + + +# Target: clean project. +clean: begin clean_list end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lss + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) $(SRC:.c=.i) + $(REMOVEDIR) .dep + + +# Create object files directory +$(shell mkdir $(OBJDIR) 2>/dev/null) + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff \ +clean clean_list program debug gdb-config + + diff --git a/arduino/all the sketchs of my life/SparkLCD/fromOriginal/main.c b/arduino/all the sketchs of my life/SparkLCD/fromOriginal/main.c new file mode 100644 index 0000000..5261f9f --- /dev/null +++ b/arduino/all the sketchs of my life/SparkLCD/fromOriginal/main.c @@ -0,0 +1,121 @@ +//******************************************************* +// Nokia Shield +//******************************************************* +#include +#include +#include +#include +#include +#include +#include + +//******************************************************* +// External Component Libs +//******************************************************* +#include "LCD_driver.h" +#include "nokia_tester.h" + +static int uart_putchar(char c, FILE *stream); +uint8_t uart_getchar(void); +static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE); + +int main (void) +{ +//******************************************************* +// Main Code +//******************************************************* + //Initialize ARM I/O + ioinit(); + + printf("Initializing\n"); + + //Show the splash-screen (Sparkfun Logo) + LCDInit(); //Initialize the LCD + + printf("Init. Done\n"); + + LCDClear(BLACK); + printf("Logo..."); + LCDPrintLogo(); + + while(1){ + if((PIND & (1<<3)) == 0) + { + LCDClear(GREEN); + LCDPrintLogo(); + } + if((PIND & (1<<4)) == 0) + { + LCDClear(PINK); + LCDPrintLogo(); + } + if((PIND & (1<<5)) == 0) + { + LCDClear(BLACK); + LCDPrintLogo(); + } + } + return 0; +} + +void ioinit(void) +{ + DDRB = ((1<> 8) & 0x7F; //Make sure highest bit(URSEL) is 0 indicating we are writing to UBRRH + UBRR0L = MYUBRR; + UCSR0A = (1< 0 ; x--) + delay_us(1000); +} + +//General short delays +void delay_us(int x) +{ + TIFR2 = (1<0){ + while( (TIFR2 & (1<0) { + byte l = Serial.read(); + if(l=='L') { + digitalWrite(7, HIGH); + } + else if(l=='D') { + digitalWrite(7, LOW); + } + else if(l=='l') { + digitalWrite(6, HIGH); + } + else if(l=='d') { + digitalWrite(6, LOW); + } + } + +} + diff --git a/arduino/all the sketchs of my life/br2_android.zip b/arduino/all the sketchs of my life/br2_android.zip new file mode 100644 index 0000000..58b7d3a Binary files /dev/null and b/arduino/all the sketchs of my life/br2_android.zip differ diff --git a/arduino/all the sketchs of my life/exemplo1/exemplo1.ino b/arduino/all the sketchs of my life/exemplo1/exemplo1.ino new file mode 100644 index 0000000..ab05c60 --- /dev/null +++ b/arduino/all the sketchs of my life/exemplo1/exemplo1.ino @@ -0,0 +1,21 @@ + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +void setup() { + pinMode(MOTOR1_A, OUTPUT); + pinMode(MOTOR1_B, OUTPUT); +} + +void loop() { + digitalWrite(MOTOR1_A, 1); + digitalWrite(MOTOR1_B, 0); + analogWrite(MOTOR1_PWM,1023); +} + diff --git a/arduino/all the sketchs of my life/heart/Motores.pde b/arduino/all the sketchs of my life/heart/Motores.pde new file mode 100644 index 0000000..728909b --- /dev/null +++ b/arduino/all the sketchs of my life/heart/Motores.pde @@ -0,0 +1,102 @@ +#define MOTOR1_P 13 +#define MOTOR1_N 12 +#define MOTOR1_PWM 5 +#define MOTOR2_P 8 +#define MOTOR2_N 7 +#define MOTOR2_PWM 3 +int sentido = 0; + + +void girarNoEixo(int tempo, int intensidade, int sentido1) { + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido1); + digitalWrite(MOTOR1_N,!sentido1); + digitalWrite(MOTOR2_P,!sentido1); + digitalWrite(MOTOR2_N,sentido1); + delay(tempo); +} +void parar() { + analogWrite(MOTOR1_PWM,0 ); + analogWrite(MOTOR2_PWM,0); +} +void andar(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade); + analogWrite(MOTOR2_PWM,intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + +void andarFrente(int tempo, int intensidade) { + sentido = 0; + analogWrite(MOTOR1_PWM,intensidade*50); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} +void andarTraz(int tempo,int intensidade) { + sentido = 1; + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarEsquerda(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,intensidade*50 ); + analogWrite(MOTOR2_PWM,10*intensidade); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); + +} +void virarDireita(int tempo,int intensidade) { + analogWrite(MOTOR1_PWM,10*intensidade ); + analogWrite(MOTOR2_PWM,intensidade*50); + digitalWrite(MOTOR1_P,sentido); + digitalWrite(MOTOR1_N,!sentido); + digitalWrite(MOTOR2_P,sentido); + digitalWrite(MOTOR2_N,!sentido); + delay(tempo); +} + + +void readPing() +{ + /* + pinMode(PING_PIN, OUTPUT); + digitalWrite(PING_PIN, LOW); + delayMicroseconds(2); + digitalWrite(PING_PIN, HIGH); + delayMicroseconds(5); + digitalWrite(PING_PIN, LOW); + + pinMode(PING_PIN, INPUT); + duration = pulseIn(PING_PIN, HIGH); + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + Serial.println(cm);*/ +} + +long microsecondsToInches(long microseconds) +{ + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) +{ + return microseconds / 29 / 2; +} + diff --git a/arduino/all the sketchs of my life/heart/heart.pde b/arduino/all the sketchs of my life/heart/heart.pde new file mode 100644 index 0000000..e5319a8 --- /dev/null +++ b/arduino/all the sketchs of my life/heart/heart.pde @@ -0,0 +1,95 @@ +#include "Wire.h" +#include "hrmi_funcs.h" +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 +#define MAX_IN_BUFFSIZE 16 + +#define SPEAKER 4 //em paralelo com led +#define LED_P5 4 //em paralelo com speaker +#define LED_P4 7 +#define LED_P3 8 +#define LED_P2 12 +#define LED_P1 13 + +#define CHAVE_1 2 + +#define TRANSISTOR_Q5 9 +#define TRANSISTOR_Q4 6 //servo +#define TRANSISTOR_Q2 5 //servo +#define TRANSISTOR_Q3 3 + +//Analogicas +#define SENSOR_TEMPERATURA 2 +#define SENSOR_LUZ 3 +#define ENTRADA_1 0 +#define ENTRADA_2 1 + +//Entradas para interrupcao +#define INT_1 3 +#define INT_0 2 + +#define SERVO_1 5 +#define SERVO_2 6 + +//Ponte H +#define MOTOR1_A 7 //led paralelo +#define MOTOR1_B 8 //led paralelo +#define MOTOR1_PWM 10 //led paralelo + +#define MOTOR2_A 12 //led paralelo +#define MOTOR2_B 13 //led paralelo +#define MOTOR2_PWM 11 //led paralelo + +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use +int leds[] = { + 13, 12, 8, 7, 4}; + +void setup() +{ + hrmi_open(); + Serial.begin(HRMI_HOST_BAUDRATE); + for(int x=0;x<5;x++) { + pinMode(leds[x], OUTPUT); + } +} + + +void loop() +{ + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + + int val = map(i2cRspArray[2], 80,130,0, 150); + + Serial.print(i2cRspArray[2]); + int numeroLedsALigar = map(i2cRspArray[2], 80, 100, 0, 4); + //Serial.println(numeroLedsALigar); + for(int x=0;x<=numeroLedsALigar;x++) { + digitalWrite(leds[x], HIGH); + delay(100); + } + for(int x=numeroLedsALigar;x>-1;x--) { + digitalWrite(leds[x], LOW); + delay(100); + } + + //analogWrite(9, val); + + /*if(i2cRspArray[2]>100) + andar(0, map(i2cRspArray[2], 100, 130, 100,255)); + else parar();*/ + } + if (++numEntries > 30) numEntries = 0; + delay(300); +} + + + + + + diff --git a/arduino/all the sketchs of my life/heart/hrmi_funcs.cpp b/arduino/all the sketchs of my life/heart/hrmi_funcs.cpp new file mode 100644 index 0000000..3fae9aa --- /dev/null +++ b/arduino/all the sketchs of my life/heart/hrmi_funcs.cpp @@ -0,0 +1,60 @@ +/* + * hrmi_funcs.cpp + * + * Arduino library to communicate with a HRMI using I2C + * + * Written by Dan Julio, www.danjuliodesigns.com + * Version 1.1, 12/28/2008 + * + */ + + #include + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.send(cmd); + Wire.send(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.send(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/jHome/home1/home1.ino b/arduino/all the sketchs of my life/jHome/home1/home1.ino new file mode 100644 index 0000000..b76084e --- /dev/null +++ b/arduino/all the sketchs of my life/jHome/home1/home1.ino @@ -0,0 +1,27 @@ +#include "Device.h" + +Device homeDevice=Device("central-device"); + +void setup() { + homeDevice.add("pwm-aux1", PWM, 3); + homeDevice.add("pwm-aux2", PWM, 5); + homeDevice.add("buzz", PWM, 6); + homeDevice.add("fan", PWM, 9); + + homeDevice.add("speaker", DIGITAL, 4); + homeDevice.add("relay1", DIGITAL, 14); + homeDevice.add("relay2", DIGITAL, 15); + homeDevice.add("relay3", DIGITAL, 7); + homeDevice.add("relay4", DIGITAL, 8); + homeDevice.add("light", ANALOG, 3); + homeDevice.add("temp", ANALOG, 2); + //Starting booth communication! + Serial.begin(115200); + +} + +void loop() { + homeDevice.loop(); +} + + diff --git a/arduino/all the sketchs of my life/jHome/home1_comir/home1_comir.ino b/arduino/all the sketchs of my life/jHome/home1_comir/home1_comir.ino new file mode 100644 index 0000000..5e6f10f --- /dev/null +++ b/arduino/all the sketchs of my life/jHome/home1_comir/home1_comir.ino @@ -0,0 +1,42 @@ +#include "Device.h" +#include //biblioteca do controle +int RECV_PIN = 6; // colocar o Shield IR receiver module na porta 11 +IRrecv irrecv(RECV_PIN); +decode_results results; +unsigned long codigo;//variável que recebe o código + +Device homeDevice=Device(); + +void setup() { + homeDevice.add("relay1", "RELAY", 14); + homeDevice.add("relay2", "RELAY", 15); + homeDevice.add("relay3", "RELAY", 16); + homeDevice.add("relay4", "RELAY", 17); + homeDevice.add("light", "LIGHT", 3); + homeDevice.add("temperature", "TEMP", 2); + Serial.begin(115200); + irrecv.enableIRIn(); // inicia o recebimento de dados + + +} + +void print() { + Serial.println(homeDevice.read("light")); +} +int state; +void loop() { + //homeDevice.loop(); + if (irrecv.decode(&results)) { + codigo=results.value; // variável "código" recebe dados da "results.value " + Serial.println(codigo, DEC); // mostra o dados na Serial Monitor em decimal + irrecv.resume(); + } + if(codigo==2640478335) { + digitalWrite(14,state); + state=!state; + delay(200); + } + +} + + diff --git a/arduino/all the sketchs of my life/jHome/home2/home2.ino b/arduino/all the sketchs of my life/jHome/home2/home2.ino new file mode 100644 index 0000000..8a4df08 --- /dev/null +++ b/arduino/all the sketchs of my life/jHome/home2/home2.ino @@ -0,0 +1,29 @@ +#include "Device.h" +#include "etherShield.h" +#include "ETHER_28J60.h" + +Device homeDevice=Device("old-central"); + +void setup() { + homeDevice.add("red", PWM, 5); + homeDevice.add("green", PWM, 6); + homeDevice.add("blue", PWM, 9); + + homeDevice.add("relay1", DIGITAL, 4); + homeDevice.add("relay2", DIGITAL, 2); + homeDevice.add("portao1", DIGITAL, 7); + homeDevice.add("portao2", DIGITAL, 8); + + homeDevice.add("light", ANALOG, 3); + homeDevice.add("temp", ANALOG, 2); + //Starting booth communication! + Serial.begin(115200); + //int ip[]={192,168,1,15}; + //homeDevice.startNetwork(ip); +} + +void loop() { + homeDevice.loop(); +} + + diff --git a/arduino/all the sketchs of my life/jHome/home3/HeartMonitor.ino b/arduino/all the sketchs of my life/jHome/home3/HeartMonitor.ino new file mode 100644 index 0000000..6cdd89d --- /dev/null +++ b/arduino/all the sketchs of my life/jHome/home3/HeartMonitor.ino @@ -0,0 +1,71 @@ +#define HRMI_HOST_BAUDRATE 9600 +#define HRMI_I2C_ADDR 127 +#define MAX_IN_BUFFSIZE 16 + +char serInStr[MAX_IN_BUFFSIZE]; // Serial input string array +int numEntries = 0; // Number of HR values to request +int numRspBytes; // Number of Response bytes to read +byte i2cRspArray[34]; // I2C response array, sized to read 32 HR values +byte hrmi_addr = HRMI_I2C_ADDR; // I2C address to use +boolean heartInit = false; +void heartMonitor_setup() { +} + +char* readHeartBeat() { + if(!heartInit) { + hrmi_open(); + heartInit=true; + } + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + //int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + if (++numEntries > 30) numEntries = 0; + char r[1];// = { i2cRspArray[2] ]}; + return r; + } + else { + char r[1]; return r; + } +} +void writeHeartBeat(char *c) { + +} + +void oldReadHeartBeat() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + Serial.flush(); + } + if (++numEntries > 30) numEntries = 0; +} + +void heartMonitor() { + hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries); + numRspBytes = numEntries + 2; + if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) { + int val = map(i2cRspArray[2], 80,130,0, 150); + //for(int x=0;x<34;x++) { + Serial.print(i2cRspArray[2],DEC); + //} + Serial.println(" "); + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Heart Monitor"); + lcd.setCursor(0, 1); + //char c*[]; + //toa(i2cRspArray[2],&c); + String n = String(i2cRspArray[2]); + + lcd.print(i2cRspArray[2],DEC); + + } + if (++numEntries > 30) numEntries = 0; + //Kernel.wait(300); +} + diff --git a/arduino/all the sketchs of my life/jHome/home3/RGB.ino b/arduino/all the sketchs of my life/jHome/home3/RGB.ino new file mode 100644 index 0000000..4e091c0 --- /dev/null +++ b/arduino/all the sketchs of my life/jHome/home3/RGB.ino @@ -0,0 +1,85 @@ +char rgb='R'; +long cm; +void RGB(char* comando) { + int port = 0; + if(comando[1]=='R') port = 1; + if(comando[1]=='G') port = 1; + if(comando[1]=='B') port = 1; + int amount = map(atoi(&comando[2]),0,9,0,255); + analogWrite(port, amount); +} + +void rgb_red_setup() { + lcd.setCursor(0, 1); + lcd.print("RED"); + rgb='R'; +} +void rgb_green_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("GREEN"); + rgb='G'; +} +void rgb_blue_setup() { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("RGB Ping"); + lcd.setCursor(0, 1); + lcd.print("BLUE"); + rgb='B'; +} +void mode_rgb() { + lcd.clear(); + lcd.setCursor(0, 0); + //readPing(); + //homeDevice.execute("distance"); + int port = 0; + if(rgb=='R') { + port = 3; + lcd.print("RGB Red"); + } + else if(rgb=='G') { + port = 6; + lcd.print("RGB Green"); + } + else if(rgb=='B') { + port = 9; + lcd.print("RGB Blue"); + } + if(cm<10) { + delay(200); + //cm = long(homeDevice.execute("distance")); + //readPing(); + if(cm<10){ + blink(port, 3, 100); + while(cm<50) { + int cmok=cm; + cmok = cmok>25 ? 25 : cmok; + cmok = cmok<5 ? 5 : cmok; + + int amount = map(cmok,5,25,255,0); + lcd.setCursor(0, 1); + lcd.print(cm); + lcd.setCursor(4, 1); + lcd.print(amount); + analogWrite(port, amount); + delay(50); + //cm = atoi(homeDevice.execute("distance")); + } + } + } + delay(150); +} + +void blink(int port, int n, int d) { + pinMode(port, OUTPUT); + for(int x=0;x1000) { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print(homeDevice.execute("distance")); + lcd.setCursor(4, 1); + float temperatura = (analogRead(2) * 0.00488); // 5V / 1023 = 0.00488 (precisão do A/D) + temperatura = temperatura * 100; //Converte milivolts para graus celcius, lembrando que a cada 10mV equivalem a 1 grau celcius + lcd.print(temperatura); + handTimer=millis(); + }*/ + +} + + diff --git a/arduino/all the sketchs of my life/jHome/home3/hrmi_funcs.cpp b/arduino/all the sketchs of my life/jHome/home3/hrmi_funcs.cpp new file mode 100644 index 0000000..a0c8c46 --- /dev/null +++ b/arduino/all the sketchs of my life/jHome/home3/hrmi_funcs.cpp @@ -0,0 +1,60 @@ +/* + * hrmi_funcs.cpp + * + * Arduino library to communicate with a HRMI using I2C + * + * Written by Dan Julio, www.danjuliodesigns.com + * Version 1.1, 12/28/2008 + * + */ + + #include + #include "hrmi_funcs.h" + + /* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open() +{ + Wire.begin(); +} + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.write(arg); + Wire.endTransmission(); +} + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd) +{ + Wire.beginTransmission(addr); + Wire.write(cmd); + Wire.endTransmission(); +} + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray) +{ + Wire.requestFrom(addr, numBytes); + if (Wire.available()) { + for (int i=0; i + +/* + * hrmi_open: Initialize the I2C library + * This routine must be called before attempting to communicate with I2C + */ +void hrmi_open(); + + +/* + * hrmiCmdArg: Send a Command followed by a single Argument + */ +void hrmiCmdArg(byte addr, byte cmd, byte arg); + + +/* + * hrmiCmd: Send a Command with no argument + */ +void hrmiCmd(byte addr, byte cmd); + + +/* + * hrmiGetData: Get the specified number of data bytes from the HRMI into + * an array. + */ +int hrmiGetData(byte addr, byte numBytes, byte* dataArray); + diff --git a/arduino/all the sketchs of my life/jHome/home3_AGAIN/home3_AGAIN.ino b/arduino/all the sketchs of my life/jHome/home3_AGAIN/home3_AGAIN.ino new file mode 100644 index 0000000..e7022f3 --- /dev/null +++ b/arduino/all the sketchs of my life/jHome/home3_AGAIN/home3_AGAIN.ino @@ -0,0 +1,34 @@ +#include "Device.h" +#include "etherShield.h" +#include "ETHER_28J60.h" +#include "EEPROM.h" +#include "Ethernet.h" + +Device homeDevice=Device("central-device"); +Ethernet ethernet=Ethernet(&homeDevice); + +void setup() { + homeDevice.add("red", PWM, 3); + homeDevice.add("distance", PING, 5); + homeDevice.add("blue", PWM, 6); + homeDevice.add("fan", PWM, 9); + + homeDevice.add("speaker", DIGITAL, 4); + homeDevice.add("relay1", DIGITAL, 7); + homeDevice.add("relay2", DIGITAL, 8); + homeDevice.add("relay3", DIGITAL, 14); + homeDevice.add("relay4", DIGITAL, 15); + homeDevice.add("light", ANALOG, 3); + homeDevice.add("temp", ANALOG, 2); + //Starting booth communication! + Serial.begin(115200); + int ip[]={192,168,1,15}; + ethernet.startNetwork(ip); +} + +void loop() { + homeDevice.loop(); + ethernet.loop(); +} + + diff --git a/arduino/all the sketchs of my life/jHome/home3_basicop/home3_basicop.ino b/arduino/all the sketchs of my life/jHome/home3_basicop/home3_basicop.ino new file mode 100644 index 0000000..81f7215 --- /dev/null +++ b/arduino/all the sketchs of my life/jHome/home3_basicop/home3_basicop.ino @@ -0,0 +1,78 @@ +//jHome and Electron Kernel includes +//#include "ElectronKernel.h" +#include "Device.h" +#include "etherShield.h" +#include "ETHER_28J60.h" + +//Specific includes to LCD and HR + +Device homeDevice=Device("sensor-device"); + + +long handTimer=0; + +void setup() +{ + homeDevice.add("red", PWM, 3); + homeDevice.add("green", PWM, 6); + homeDevice.add("blue", PWM, 9); + + + homeDevice.add("distance", PING, 5); + + homeDevice.add("light", LIGHT, 3); + homeDevice.add("temp", TEMP, 2); + //Cool jHome Feature: you can add your custom component passing a read / write function pointer + //homeDevice.add("heart", "LIB", I2C, readHeartBeat, writeHeartBeat); + + /*Kernel.setup(INTERRUPTION); + Kernel.registerMode("M1", jhome_setup); + Kernel.registerTask(jhome); + Kernel.registerMode("MH", heartMonitor_setup); + Kernel.registerTask(heartMonitor); + + Kernel.registerMode("M2", rgb_red_setup); + Kernel.registerTask(mode_rgb); + Kernel.registerMode("M3", rgb_green_setup); + Kernel.registerTask(mode_rgb); + Kernel.registerMode("M4", rgb_blue_setup); + Kernel.registerTask(mode_rgb);*/ + + Serial.begin(115200); + int ip[]={192,168,1,15}; + homeDevice.startNetwork(ip); + Serial.println(homeDevice.serial); + /*lcd.init(); + lcd.setBacklight(0); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print("by Globalcode"); + delay(1500);*/ +} + +void loop() +{ + //Kernel.loop(); + jhome(); +} + +void jhome() { + + homeDevice.loop(); + /*if(millis()-handTimer>1000) { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("jHome v1.0"); + lcd.setCursor(0, 1); + lcd.print(homeDevice.execute("distance")); + lcd.setCursor(4, 1); + float temperatura = (analogRead(2) * 0.00488); // 5V / 1023 = 0.00488 (precisão do A/D) + temperatura = temperatura * 100; //Converte milivolts para graus celcius, lembrando que a cada 10mV equivalem a 1 grau celcius + lcd.print(temperatura); + handTimer=millis(); + }*/ + +} + + diff --git a/arduino/all the sketchs of my life/jHome/jHomeEthernet/jHomeEthernet.pde b/arduino/all the sketchs of my life/jHome/jHomeEthernet/jHomeEthernet.pde new file mode 100644 index 0000000..b94dad6 --- /dev/null +++ b/arduino/all the sketchs of my life/jHome/jHomeEthernet/jHomeEthernet.pde @@ -0,0 +1,294 @@ +#include "etherShield.h" +// Default jHome pin +#define RX 0 +#define TX 1 +#define AUX_INT 2 + +#define RELAY1 3 +#define RELAY2 4 + +#define RED 5 +#define GREEN 6 + +#define AUX1 7 +#define AUX2 8 + +#define BLUE 9 +//10, 11, 12, 13 SPI port reserved for ethernet + +//ANALOG +#define RELAY3 14 //0 +#define RELAY4 15 //1 + +#define TEMPERATURE 2 +#define LIGHT 3 +//4, 5 reserved for I2C component, ex. LCD display + + +// please modify the following two lines. mac and ip have to be unique +// in your local area network. You can not have the same numbers in +// two devices: +static uint8_t mymac[6] = { + 0x54,0x55,0x58,0x10,0x00,0x24}; +static uint8_t myip[4] = { + 192,168,1,15}; +static char baseurl[]="http://192.168.1.15/"; +static uint16_t mywwwport =80; // listen port for tcp/www (max range 1-254) + + + +#define BUFFER_SIZE 500 +static uint8_t buf[BUFFER_SIZE+1]; +#define STR_BUFFER_SIZE 22 +static char strbuf[STR_BUFFER_SIZE+1]; + +EtherShield es=EtherShield(); + +// prepare the webpage by writing the data to the tcp send buffer +uint16_t print_webpage(uint8_t *buf, byte on_off); +int8_t analyse_cmd(char *str); + +// LED cathode connects the Pin4, anode to 5V through 1K resistor +#define LED_PIN 14 + + +void setup(){ + + /*initialize enc28j60*/ + es.ES_enc28j60Init(mymac); + es.ES_enc28j60clkout(2); // change clkout from 6.25MHz to 12.5MHz + delay(10); + + /* Magjack leds configuration, see enc28j60 datasheet, page 11 */ + // LEDA=greed LEDB=yellow + // + // 0x880 is PHLCON LEDB=on, LEDA=on + // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00); + es.ES_enc28j60PhyWrite(PHLCON,0x880); + delay(500); + // + // 0x990 is PHLCON LEDB=off, LEDA=off + // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00); + es.ES_enc28j60PhyWrite(PHLCON,0x990); + delay(500); + // + // 0x880 is PHLCON LEDB=on, LEDA=on + // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00); + es.ES_enc28j60PhyWrite(PHLCON,0x880); + delay(500); + // + // 0x990 is PHLCON LEDB=off, LEDA=off + // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00); + es.ES_enc28j60PhyWrite(PHLCON,0x990); + delay(500); + // + // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit + // enc28j60PhyWrite(PHLCON,0b0000 0100 0111 01 10); + es.ES_enc28j60PhyWrite(PHLCON,0x476); + delay(100); + + //init the ethernet/ip layer: + es.ES_init_ip_arp_udp_tcp(mymac,myip,80); + + pinMode(LED_PIN, OUTPUT); + pinMode(15, OUTPUT); + digitalWrite(LED_PIN, LOW); // switch on LED +} + +void loop(){ + uint16_t plen, dat_p; + int8_t cmd; + byte on_off = 1; + + plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf); + + /*plen will ne unequal to zero if there is a valid packet (without crc error) */ + if(plen!=0){ + + // arp is broadcast if unknown but a host may also verify the mac address by sending it to a unicast address. + if(es.ES_eth_type_is_arp_and_my_ip(buf,plen)){ + es.ES_make_arp_answer_from_request(buf); + return; + } + + // check if ip packets are for us: + if(es.ES_eth_type_is_ip_and_my_ip(buf,plen)==0){ + return; + } + + if(buf[IP_PROTO_P]==IP_PROTO_ICMP_V && buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V){ + es.ES_make_echo_reply_from_request(buf,plen); + return; + } + + // tcp port www start, compare only the lower byte + if (buf[IP_PROTO_P]==IP_PROTO_TCP_V&&buf[TCP_DST_PORT_H_P]==0&&buf[TCP_DST_PORT_L_P]==mywwwport){ + if (buf[TCP_FLAGS_P] & TCP_FLAGS_SYN_V){ + es.ES_make_tcp_synack_from_syn(buf); // make_tcp_synack_from_syn does already send the syn,ack + return; + } + if (buf[TCP_FLAGS_P] & TCP_FLAGS_ACK_V){ + es.ES_init_len_info(buf); // init some data structures + dat_p=es.ES_get_tcp_data_pointer(); + if (dat_p==0){ // we can possibly have no data, just ack: + if (buf[TCP_FLAGS_P] & TCP_FLAGS_FIN_V){ + es.ES_make_tcp_ack_from_any(buf); + } + return; + } + //Here jHome starts to rocks... + if (strncmp("PUT ",(char *)&(buf[dat_p]),4)==0){ + if(strncmp("RELAY ON",(char *)&(buf[dat_p+4]),8)==0){ + digitalWrite(15, 1); + //char relayNumber = + } + else if(strncmp("RELAY OFF",(char *)&(buf[dat_p+4]),9)==0){ + digitalWrite(15, 0); + //char relayNumber = + } + } + + if (strncmp("GET ",(char *)&(buf[dat_p]),4)!=0){ + // head, post and other methods for possible status codes see: + // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html + plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n

200 OK

")); + goto SENDTCP; + } + if (strncmp("/ ",(char *)&(buf[dat_p+4]),2)==0){ + plen=print_webpage(buf, on_off); + goto SENDTCP; + } + if (strncmp("/setup",(char *)&(buf[dat_p+4]),6)==0){ + plen=print_setuppage(buf, on_off); + goto SENDTCP; + } + cmd=analyse_cmd((char *)&(buf[dat_p+5])); + + if (cmd==2){ + on_off=1; + digitalWrite(LED_PIN, LOW); // switch on LED + } + else if (cmd==3){ + on_off=0; + digitalWrite(LED_PIN, HIGH); // switch off LED + } + plen=print_webpage(buf, on_off); + + plen=print_webpage(buf, on_off); +SENDTCP: + es.ES_make_tcp_ack_from_any(buf); // send ack for http get + es.ES_make_tcp_ack_with_data(buf,plen); // send data + } + } + } + +} +// The returned value is stored in the global var strbuf +uint8_t find_key_val(char *str,char *key) +{ + uint8_t found=0; + uint8_t i=0; + char *kp; + kp=key; + while(*str && *str!=' ' && found==0){ + if (*str == *kp){ + kp++; + if (*kp == '\0'){ + str++; + kp=key; + if (*str == '='){ + found=1; + } + } + } + else{ + kp=key; + } + str++; + } + if (found==1){ + // copy the value to a buffer and terminate it with '\0' + while(*str && *str!=' ' && *str!='&' && i 0x2f){ + // is a ASCII number, return it + r=(*strbuf-0x30); + } + } + return r; +} + + +uint16_t print_webpage(uint8_t *buf, byte on_off) +{ + + int i=0; + + + uint16_t plen; + + + + plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

Welcome to Arduino Ethernet Shield V1.0

")); + + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

REMOTE LED is

")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

")); + + if(on_off) + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("ON")); + else + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("OFF")); + + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("


") ); + + if(on_off){ + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
")); + } + else { + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("")); + } + + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

V1.0 www.nuelectronics.com")); + + return(plen); +} + + +uint16_t print_setuppage(uint8_t *buf, byte on_off) +{ + int i=0; + uint16_t plen; + + + plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

Welcome to jHome Hardware Setup Interface

")); + + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("

SETUP PAGE

")); + plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
")); + + return(plen); +} + + diff --git a/arduino/all the sketchs of my life/jHome/jHomeSample1/jHomeSample1.ino b/arduino/all the sketchs of my life/jHome/jHomeSample1/jHomeSample1.ino new file mode 100644 index 0000000..292cca2 --- /dev/null +++ b/arduino/all the sketchs of my life/jHome/jHomeSample1/jHomeSample1.ino @@ -0,0 +1,18 @@ +#include "jHomeEthernet.h" + +jHomeEthernet ethernet=jHomeEthernet(); +//jHome home=jHome(); + +void setup() { + //setup IP and Mac Address + ethernet.setup(); + home.add("relay1", "RELAY", 5); + home.add("relay2", "RELAY", 6); + home.add("light", "LIGHT", 3); + home.add("temperature","TEMP", 2); + +} + +void loop() { + home.loop(); +} diff --git a/arduino/all the sketchs of my life/jHome/jhome_ubatuba/jhome_ubatuba.ino b/arduino/all the sketchs of my life/jHome/jhome_ubatuba/jhome_ubatuba.ino new file mode 100644 index 0000000..b118891 --- /dev/null +++ b/arduino/all the sketchs of my life/jHome/jhome_ubatuba/jhome_ubatuba.ino @@ -0,0 +1,37 @@ +#include "Device.h" + +#include "etherShield.h" +#include "ETHER_28J60.h" +#include "Ethernet.h" + +Device homeDevice=Device("central-device"); +Ethernet ethernet=Ethernet(&homeDevice); + +void setup() { + homeDevice.add("buzz", PWM, 6); + homeDevice.add("red", PWM, 9); + homeDevice.add("green", PWM, 5); + homeDevice.add("blue", PWM, 3); + + homeDevice.add("p-esq", DIGITAL, 10); + homeDevice.add("p-dir", DIGITAL, 11); + + homeDevice.add("speaker", DIGITAL, 4); + homeDevice.add("relay2", DIGITAL, 15); + homeDevice.add("luz1", DIGITAL, 19); + homeDevice.add("luz2", DIGITAL, 18); + homeDevice.add("relay1", DIGITAL, 14); + homeDevice.add("light", ANALOG, 3); + homeDevice.add("temp", ANALOG, 2); + //Starting booth communication! + Serial.begin(115200); + int ip[]={192,168,1,3}; + ethernet.startNetwork(ip); +} + +void loop() { + homeDevice.loop(); + ethernet.loop(); +} + + diff --git a/arduino/all the sketchs of my life/javafx/javafx.ino b/arduino/all the sketchs of my life/javafx/javafx.ino new file mode 100644 index 0000000..0811af5 --- /dev/null +++ b/arduino/all the sketchs of my life/javafx/javafx.ino @@ -0,0 +1,35 @@ +#include "Device.h" + +#include "etherShield.h" +#include "ETHER_28J60.h" +#include "Ethernet.h" +#include "Servo.h" + +Device homeDevice=Device("central-device"); +Ethernet ethernet=Ethernet(&homeDevice); +Servo servo; +void setup(){ + servo.attach(6); + //homeDevice.add("buzz", PWM, 6); + //homeDevice.add("red", PWM, 9); + // homeDevice.add("green", PWM, 5); + //homeDevice.add("blue", PWM, 3); + + + //homeDevice.add("speaker", DIGITAL, 4); + //homeDevice.add("light", ANALOG, 3); + homeDevice.add("pot1", ANALOG, 0); + //homeDevice.add("temp", ANALOG, 2); + //Starting booth communication! + Serial.begin(115200); + int ip[]={192,168,1,5}; + ethernet.startNetwork(ip); +} + +void loop() { + homeDevice.loop(); + ethernet.loop(); + servo.write(map(analogRead(0), 0, 1023, 0, 179)); +} + + diff --git a/arduino/all the sketchs of my life/jone-2010.zip b/arduino/all the sketchs of my life/jone-2010.zip new file mode 100644 index 0000000..2a8cc8d Binary files /dev/null and b/arduino/all the sketchs of my life/jone-2010.zip differ diff --git a/arduino/all the sketchs of my life/kernel_sample1/kernel_sample1.pde b/arduino/all the sketchs of my life/kernel_sample1/kernel_sample1.pde new file mode 100644 index 0000000..400684c --- /dev/null +++ b/arduino/all the sketchs of my life/kernel_sample1/kernel_sample1.pde @@ -0,0 +1,26 @@ +#include +#include +/* + Arduinos -> Arduino -> Modes -> Mode -> Tasks -> Task + -> Components -> Component + -> Events -> Event + + */ +void setup() { + Kernel.setup(); + Kernel.registerMode(1, "Blinking Leds", piscarLedSetup); + Kernel.registerTask(1, piscarLed); + Kernel.registerMode(2, "Blinking Leds"); + Kernel.registerTask(2, nada); + +} + +void loop() { + Kernel.loop(); +} + +void nada() {} +void piscarLed() { +} +void piscarLedSetup() { +} diff --git a/arduino/all the sketchs of my life/libraries/readme.txt b/arduino/all the sketchs of my life/libraries/readme.txt new file mode 100644 index 0000000..a8f1390 --- /dev/null +++ b/arduino/all the sketchs of my life/libraries/readme.txt @@ -0,0 +1 @@ +For information on installing libraries, see: http://arduino.cc/en/Guide/Libraries diff --git a/arduino/all the sketchs of my life/lm35/lm35.pde b/arduino/all the sketchs of my life/lm35/lm35.pde new file mode 100644 index 0000000..41f4460 --- /dev/null +++ b/arduino/all the sketchs of my life/lm35/lm35.pde @@ -0,0 +1,17 @@ +//declare variables +float tempC; +int tempPin = 2; + +void setup() +{ +Serial.begin(9600); //opens serial port, sets data rate to 9600 bps +} + +void loop() +{ + +tempC = analogRead(tempPin); //read the value from the sensor +tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature +Serial.print((byte)tempC); //send the data to the computer +delay(1000); //wait one second before sending new data +} diff --git a/arduino/all the sketchs of my life/sharp_sensor/sharp_sensor.pde b/arduino/all the sketchs of my life/sharp_sensor/sharp_sensor.pde new file mode 100644 index 0000000..9b9f1d9 --- /dev/null +++ b/arduino/all the sketchs of my life/sharp_sensor/sharp_sensor.pde @@ -0,0 +1,27 @@ +#define MUITO_PERTO_VAL 350 +#define PERTO_VAL 300 +#define APROXIMANDO_VAL 200 +#define MUITO_LONGE_VAL 100 + +void setup() { + Serial.begin(9600); +} + +void loop() { + int val = analogRead(0); + Serial.print("Valor analogico: "); + Serial.println(val); + + float volts = (5.0/1024.0) * val; + //Serial.print("Valor Volts na mo: "); + Serial.println(volts); + if(volts>0 && volts<0.6) Serial.println("25cm"); + if(volts>0.6 && volts<1.0) Serial.println("20cm"); + if(volts>1.0 && volts<1.5) Serial.println("15cm"); + if(volts>1.5 && volts<2.0) Serial.println("10cm"); + if(volts>2.0) Serial.println("5cm"); + + delay(500); +} + + diff --git a/arduino/all the sketchs of my life/starterkit1/starterkit1.ino b/arduino/all the sketchs of my life/starterkit1/starterkit1.ino new file mode 100644 index 0000000..6d5458c --- /dev/null +++ b/arduino/all the sketchs of my life/starterkit1/starterkit1.ino @@ -0,0 +1,28 @@ +#include "Device.h" +#include "etherShield.h" +#include "ETHER_28J60.h" +#include "Ethernet.h" +Device homeDevice=Device("central-device"); +Ethernet ethernet=Ethernet(&homeDevice); + +void setup() { + homeDevice.add("red", PWM, 9); + homeDevice.add("green", PWM, 5); + homeDevice.add("blue", PWM, 3); + homeDevice.add("speaker", DIGITAL, 4); + homeDevice.add("relay2", DIGITAL, 8); + homeDevice.add("relay1", DIGITAL, 7); + + homeDevice.add("light", ANALOG, 3); + homeDevice.add("temp", ANALOG, 2); + //Starting booth communication! + Serial.begin(115200); + int ip[]={192,168,1,15}; + ethernet.startNetwork(ip); +} + +void loop() { + homeDevice.loop(); + ethernet.loop(); +} + diff --git a/arduino/all the sketchs of my life/tiziu_motor/tiziu_motor.pde b/arduino/all the sketchs of my life/tiziu_motor/tiziu_motor.pde new file mode 100644 index 0000000..003e8cf --- /dev/null +++ b/arduino/all the sketchs of my life/tiziu_motor/tiziu_motor.pde @@ -0,0 +1,24 @@ +void setup() { + pinMode(11,OUTPUT); + pinMode(12,OUTPUT); + pinMode(13,OUTPUT); +} + +void loop() { + digitalWrite(12, 0); + digitalWrite(13, 1); + analogWrite(11,200); + delay(1000); + analogWrite(11,0); + delay(3000); + digitalWrite(12, 1); + digitalWrite(13, 0); + analogWrite(11,200); + delay(1000); + analogWrite(11,0); + delay(3000); +} + + + +