Need AVR debugging/help

Here's my setup, I'm building an electronic car that needs to go a predetermined distance for a contest. We get the distance right before the challenge, and then my team is going to program it into the avr. We get distance feedback via an encoder wheel and a phototransistor with IR LED. The phototransistor pulls the pin (PB0) up. Do I need a pulldown resistor? The code powers a motor through a transistor via PB4. There is a calabrate function so that we can enter the distance on top, the calabrate function will turn it into a useful number, and then the code will run. The motor runs until the calabrated number is reached. Unfortuanteley the code doesn't work. Any help, please? I'm probably not specific enough in this little paragraph, so please leave a comment if this doesn't make any sense.The target uController is the attiny13/attiny13acode (this is one of the first AVR codes i've made, with the help of other team members):#include #include #include #define mmDistance 5 // the required distance in millimeters // For the aTTiny13a/*pinout:1) PB5, RESET2) PB3, CLK3) PB44) GND5) PB0 MOSI6) PB1 MISO7) PB2 SCK8) VCC*/ // Input from encoder wheel is PB0 (physical pin 5) // Output to motor is PB4 (physical pin 3)int Calibrate(int x) // Calibrate converts distance to set{ int y; y = x+3; return y;}int main(void){ int clickDistance, setDistance, on = 0; clickDistance = 0; // clickDistance is the distance travelled so far DDRB = 0b00001000; // setting outputs and inputs 00001000 setDistance = Calibrate(mmDistance); // setDistance is set distance in clicks PORTB = 0b00001000; // turn on motor on = 1; //on tells if previous sense had button on or off while(clickDistance < setDistance) { // while loop if(PINB == 0b00000000 && on == 1) // button off, previous true { clickDistance = clickDistance+1; // increments clickDistance by 1 on = 0; } if(PINB == 0b00001000) { on = 1; } } PORTB = 0b00000000; // turn off motor _delay_ms(5000); return (0);}

Topic by guyfrom7up   |  last reply


MSP430 LaunchPad (almost for free)

Guys, For all you guys who are into microcontrollers......TI is trying to take over some lost market shares of Arduino and so on. You can now order the MSP430 LaunchPad development tool in the TI webshop for only $ 4,30 incl shipment worldwide!!! Check it out at www.ti-estore.com/Merchant2/merchant.mvc?Screen=PROD&Product;_Code=MSP-EXP430G2 More specs at the TI Wiki http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_%28MSP-EXP430G2%29 Happy programming..... ;)

Topic by ton2303   |  last reply


how to "ROOT" samsung intercept for sprint Answered

1)     how do i "ROOT" my samsung intercept from sprint? i found a few apps that are amazing     ("wifi tethering", "set CPU", "root explorer" "root manager"), but  i need superuser (root)     access. can anyone explain what "ROOT" is and how to get it?     (update) I'm starting to understand "ROOT" is.) 2)      and what is  "KERNAL" 3)      i want to install flash player 10.1 on my intercept from sprint, but after i installed, it was the      same. do i have to root my phone? 4)     i cant find any good info on HOW to root the SPRINT INTERCEPT phone. 5)     which is better, the samsung moment, or the samsung intercept? 6)     is this the ONLY phone the SUCKS in EVERY SENSE (bad screen re;  unable to root;  no     multi-touch; android 2.1;  no flash support;  non-sensitive capacitive buttons;       unresponsive;  slow) 7)     (update), my phone updated today and now is running 2.2, froyo. now the capacitive      buttons work the way there supposed too. but i still cant i update flash.  and is rooting      gonna be possible (or at lest possible)? (re update 2011 Jan. 11) my phone still has no multi-touch (except for the "pinch to zoom" like before.but only on the browser); no flash player; and the hardware still SUCKS (bad res LCD screen, "EV-rev O" radio, ABSOLUTELY TERRIBLE built in memory) some reason this phone after the 2.2 update, is a LOT slower and more unresponsive then before. 8) does anyone know how to root this phone and flash it with some better-suited software for this model phone (m910)

Question by -max-   |  last reply


Needed: a trick to debug a circuit on a breadboard - (The Spaghetti Incident)

The situation: I'm prototyping a circuit with a 14-legged logic IC on a breadboard. What happens: The picture tells it all: The breadboard looks like a Spaghetti Incident. What a mess. It's hard to find the right holes between all the leads sticking out, and avoiding shorts is even trickier. And of course: The circuit doesn't work. Not suprising considering the chaos. No biggie, but debugging a circuit on such a breadboard is a real pain! So please: Share your tips / tricks / magic to keep a proper and readable circuit on a breadboard. Thanks! Ynze PS: The circuit is not very complex btw. It's a solar engine, with one logic IC (NAND gates) and about 15 other parts. The circuit does contain feedback loops, which make it a bit trickier...

Topic by ynze   |  last reply


microcontroller help

Hi i got aPICkit 2 Debug Express kithttp://www.microchipdirect.com/productsearch.aspx?Keywords=PICkit+2+Debug+Expressand a PICkit 2 Low Pin Count Demo Board http://www.microchipdirect.com/productsearch.aspx?Keywords=DM164120-1for my birthday and i was wandering where can i go to get started with it and what can be created using them. all help will be greatful thanks =)

Topic by jimbojonesy   |  last reply


Are there any third-party Java tools for the Blackberry?

Is/are there any third-party Java SDKs or "compilers" that can be installed on a Blackberry; so BB source can be debugged/edited directly on the Blackberry? Thanks in advance.

Question by    |  last reply


AVR debugger

I'm looking for a DIY debugger for atmel AVR microcontroller (ATMega644 to be exact but any other avr will do). that have step-by-step debug capabilities. DIY means i preferred making the circuit at home rater then buying some kit. thanks.

Question by axodus   |  last reply


ITEADLIB_Arduino_WeeESP8266 android response

Im planing to do a project that using Arduino+esp8266 with android device, at first my code was something like this. #include #define DEBUG true SoftwareSerial esp8266(9,10); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.                          // This means that you need to connect the TX line from the esp to the Arduino's pin 2                          // and the RX line from the esp to the Arduino's pin 3 void setup() {   Serial.begin(9600);   esp8266.begin(9600); // your esp's baud rate might be different   pinMode(11,OUTPUT);   digitalWrite(11,LOW);   pinMode(12,OUTPUT);   digitalWrite(12,LOW);   pinMode(13,OUTPUT);   digitalWrite(13,LOW);   pinMode(10,OUTPUT);   digitalWrite(10,LOW);   sendCommand("AT+RST\r\n",2000,DEBUG); // reset module   sendCommand("AT+CWMODE=1\r\n",1000,DEBUG); // configure as access point   sendCommand("AT+CWJAP=\"Arsalan Wifi\",\"arsalan123\"\r\n",3000,DEBUG);   delay(10000);   sendCommand("AT+CIFSR\r\n",1000,DEBUG); // get ip address   sendCommand("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections   sendCommand("AT+CIPSERVER=1,8080\r\n",1000,DEBUG); // turn on server on port 80   Serial.println("Server Ready"); } void loop() {   if(esp8266.available()) // check if the esp is sending a message   {     if(esp8266.find("+IPD,"))     {      delay(1000); // wait for the serial buffer to fill up (read all the serial data)      // get the connection id so that we can then disconnect      int connectionId = esp8266.read()-48; // subtract 48 because the read() function returns                                        // the ASCII decimal value and 0 (the first decimal number) starts at 48      esp8266.find("pin="); // advance cursor to "pin="      int pinNumber = (esp8266.read()-48); // get first number i.e. if the pin 13 then the 1st number is 1      int secondNumber = (esp8266.read()-48);      if(secondNumber>=0 && secondNumber<=9)      {       pinNumber*=10;       pinNumber +=secondNumber; // get second number, i.e. if the pin number is 13 then the 2nd number is 3, then add to the first number      }      digitalWrite(pinNumber, !digitalRead(pinNumber)); // toggle pin         String content;      content = "چراغ ";      content += pinNumber;      content += " is ";      if(digitalRead(pinNumber))      {        content += "ON";      }      else      {        content += "OFF";      }      sendHTTPResponse(connectionId,content);      // make close command      String closeCommand = "AT+CIPCLOSE=";      closeCommand+=connectionId; // append connection id      closeCommand+="\r\n";      sendCommand(closeCommand,1000,DEBUG); // close connection      Serial.print(connectionID);     }   } } /* * Name: sendData * Description: Function used to send data to ESP8266. * Params: command - the data/command to send; timeout - the time to wait for a response; debug - print to Serial window?(true = yes, false = no) * Returns: The response from the esp8266 (if there is a reponse) */ String sendData(String command, const int timeout, boolean debug) {     String response = "";     int dataSize = command.length();     char data[dataSize];     command.toCharArray(data,dataSize);     esp8266.write(data,dataSize); // send the read character to the esp8266     if(debug)     {       Serial.println("\r\n====== HTTP Response From Arduino ======");       Serial.write(data,dataSize);       Serial.println("\r\n========================================");     }     long int time = millis();     while( (time+timeout) > millis())     {       while(esp8266.available())       {         // The esp has data so display its output to the serial window         char c = esp8266.read(); // read the next character.         response+=c;       }      }     if(debug)     {       Serial.print(response);     }     return response; } /* * Name: sendHTTPResponse * Description: Function that sends HTTP 200, HTML UTF-8 response */ void sendHTTPResponse(int connectionId, String content) {      // build HTTP response      String httpResponse;      String httpHeader;      // HTTP Header      httpHeader = "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\n";      httpHeader += "Content-Length: ";      httpHeader += content.length();      httpHeader += "\r\n";      httpHeader +="Connection: close\r\n\r\n";      httpResponse = httpHeader + content + " "; // There is a bug in this code: the last character of "content" is not sent, I cheated by adding this extra space      sendCIPData(connectionId,httpResponse); } /* * Name: sendCIPDATA * Description: sends a CIPSEND=, command * */ void sendCIPData(int connectionId, String data) {    String cipSend = "AT+CIPSEND=";    cipSend += connectionId;    cipSend += ",";    cipSend +=data.length();    cipSend +="\r\n";    sendCommand(cipSend,1000,DEBUG);    sendData(data,1000,DEBUG); } /* * Name: sendCommand * Description: Function used to send data to ESP8266. * Params: command - the data/command to send; timeout - the time to wait for a response; debug - print to Serial window?(true = yes, false = no) * Returns: The response from the esp8266 (if there is a reponse) */ String sendCommand(String command, const int timeout, boolean debug) {     String response = "";     esp8266.print(command); // send the read character to the esp8266     long int time = millis();     while( (time+timeout) > millis())     {       while(esp8266.available())       {         // The esp has data so display its output to the serial window         char c = esp8266.read(); // read the next character.         response+=c;       }      }     if(debug)     {       Serial.print(response);     }     return response; } but then i chose to use library code for esp8266 and i use this link ITEADLIB_Arduino_WeeESP8266 now i have problem that i dont know how can i get a response message back to my android device, also this is my code using library, (i know its really noobish code cuz im new but... it work atleast :D ) #include #include "ESP8266.h" #include #include LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //moshakhas kardane pin haye LCD SoftwareSerial mySerial(7, 8); // moshakhas kardane pin haye wifi ESP8266 wifi(mySerial); String msg; #define SSID        "Arsalan Wifi"  //UserName wifi #define PASSWORD    "arsalan123"  //Password wifi String pinnum; int count= 0; void setup() {   lcd.begin(20, 4);       Serial.begin(9600);   pinMode(9,OUTPUT);   digitalWrite(9,HIGH);   String IP;   Serial.print("setup begin\r\n");   lcd.print("Connecting to Wifi");   delay(3000);   Serial.print("FW Version: ");   //  Serial.println(wifi.getVersion().c_str());         if (wifi.setOprToStation()) {         Serial.print("to station ok\r\n");     } else {         Serial.print("to station err\r\n");     }     if (wifi.joinAP(SSID, PASSWORD)) {         Serial.print("Join AP success\r\n");         Serial.print("IP: ");               Serial.println(wifi.getLocalIP().c_str());         IP = wifi.getLocalIP().c_str();         lcd.setCursor(0, 1);         lcd.print("Join AP success");         lcd.setCursor(0, 2);         lcd.print("IP: "+IP);     } else {         Serial.print("Join AP failure\r\n");         lcd.setCursor(0, 1);         lcd.print("Join AP failure");         lcd.setCursor(0, 2);         lcd.print("Contact Administrator");     }      if (wifi.enableMUX()) {         Serial.print("multiple ok\r\n");     } else {         Serial.print("multiple err\r\n");     }     if (wifi.startTCPServer(80)) {         Serial.print("start tcp server ok\r\n");         lcd.setCursor(0, 3);         lcd.print("Server Ready");     } else {         Serial.print("start tcp server err\r\n");         lcd.setCursor(0, 3);         lcd.print("Server Setup Fail");     }     if (wifi.setTCPServerTimeout(10)) {         Serial.print("set tcp server timout 10 seconds\r\n");     } else {         Serial.print("set tcp server timout err\r\n");     }           Serial.print("setup end\r\n"); } void loop() {    uint8_t buffer[128] = {0};     uint8_t mux_id;     uint32_t len = wifi.recv(&mux;_id, buffer, sizeof(buffer), 100);     if (len > 0) {         Serial.print("Status:[");         Serial.print(wifi.getIPStatus().c_str());         Serial.println("]");                 Serial.print("Received from :");         Serial.print(mux_id);         Serial.print("[");         for(uint32_t i = 0; i < len; i++) {             Serial.print((char)buffer[i]);             msg = "";             msg += ((char)buffer[i]);                         if (msg == "p")             {               count=1;                                         }                          if (msg != "p" & count ==1)             {               if(msg =="i")               {                                 count++;               }               else               {                                 count = 0;               }             }             if (msg !="i" & count ==2)             {               if (msg =="n")               {                 count++;               }               else               {                 count = 0;               }             }             if (msg !="n" & count ==3)             {               if(msg=="=")               {                 count++;                               }               else               {                 count = 0;               }             }             if (msg != "=" & count==4)             {               Serial.print(msg);               pinnum =msg;               count = 0;             }                     }         Serial.print(pinnum);         Serial.print("]\r\n");         int pin = pinnum.toInt();         Serial.print(pin);         digitalWrite(pin, !digitalRead(pin)); // toggle pin            String content;      content = "چراغ ";      content += pinnum;      content += " is ";           if(digitalRead(pin))      {        content += "ON";      }      else      {        content += "OFF";      }                 if(wifi.send(mux_id, buffer, len)) {             Serial.print("send back ok\r\n");         } else {             Serial.print("send back err\r\n");         }                 if (wifi.releaseTCP(mux_id)) {             Serial.print("release tcp ");             Serial.print(mux_id);             Serial.println(" ok");         } else {             Serial.print("release tcp");             Serial.print(mux_id);             Serial.println(" err");         }                 Serial.print("Status:[");         Serial.print(wifi.getIPStatus().c_str());         Serial.println("]");     }   }

Question by Arsalan Ahmadi   |  last reply


Set up gmail on Nokia C6-01?

A new Nokia C6-01 phone, I have already succeeded stetting up yahoo and hotmail on it. But each time I put the configuration of gmail, it gives me the error message - can't communicate with the mail server. Anyone has any ideas how to debug this? Thanks!

Question by hectintin   |  last reply


Arduino WX code help for Weather Underground data upload?

Hello- I tried to recreate this WiFi Weather Station project using most of the same parts except for the Arduino WiFi101 shield.  I am having a problem with the data only being uploaded once.  The code tries again, but it seems the connection to WU fails after the first time.  I have to hit the reset button on the board or reload the code for it to upload again.   I am wondering if the connection to WU needs to be severed after each upload and the entire process needs to repeat after that.  I have no idea...  Someone else posted a comment in the comment section for the project with same issue and the author has never responded to the upload issue.  Any help would be great.   Here is the code: int DEBUG = 1; #include #include #include #include #include     //UV sensor #include #include #define DHTPIN 2 #define DHTTYPE DHT22 //DHT22 //Constants char ssid[] = "******";     //  your network SSID (name) char pass[] = "******";    // your network password int status = WL_IDLE_STATUS;     // the Wifi radio's status char SERVER[] = "rtupdate.wunderground.com";           // Realtime update server - RapidFire char WEBPAGE [] = "GET /weatherstation/updateweatherstation.php?"; char ID [] = "**********"; char PASSWORD [] = "*********"; DHT dht(DHTPIN, DHTTYPE); Adafruit_SI1145 uv = Adafruit_SI1145(); // UV Sensor Adafruit_BMP085 bmp; WiFiClient client; void setup(void) {   Serial.begin(9600);   Wire.begin();   dht.begin();   uv.begin();   bmp.begin();   Serial.println("Attempting to connect to WPA network...");   status = WiFi.begin(ssid, pass);    //if you're not connected, stop here:   if ( status != WL_CONNECTED) {     Serial.println("Couldn't get a wifi connection");     while(true);   }    //if you are connected, print out info about the connection:   else {     Serial.println("WiFi is a Go!!");     } } void loop(void){    //Get sensor data   float tempc = bmp.readTemperature();    float tempf =  (tempc * 9.0)/ 5.0 + 32.0;    float humidity = dht.readHumidity();   float baromin = bmp.readPressure()* 0.0002953;   float dewptf = (dewPoint(tempf, dht.readHumidity()));    float UVindex = uv.readUV();         UVindex /= 100.0;                               if (DEBUG) {     Serial.println("+++++++++++++++++++++++++");   Serial.print("temp= ");   Serial.print(tempf);   Serial.println(" *F");   Serial.print("baro= ");   Serial.print(baromin);   Serial.println(" inHg");   Serial.print("dew point= ");   Serial.println(dewptf);   Serial.print("humidity= ");   Serial.println(humidity);   Serial.print("UV: ");    Serial.println(UVindex);   }//End debug loop //Send data to Weather Underground if (client.connect(SERVER, 80)) {     if (DEBUG) {          Serial.println("Sending DATA ");       }     // Ship it!     client.print(WEBPAGE);     client.print("ID=");     client.print(ID);     client.print("&PASSWORD;=");     client.print(PASSWORD);     client.print("&dateutc;=");     client.print("now");     client.print("&tempf;=");     client.print(tempf);     client.print("&baromin;=");     client.print(baromin);     client.print("&dewptf;=");     client.print(dewptf);     client.print("&humidity;=");     client.print(humidity);     client.print("&uv;=");     client.print(UVindex);     client.print("&softwaretype;=Arduino%20UNO%20version1&action;=updateraw&realtime;=1&rtfreq;=2.5");//Rapid Fire     client.println();         if (DEBUG) {         Serial.println("Upload complete");       }          }//End send loop     else {       if (DEBUG) { Serial.println(F("Connection failed")); }       return;       }         delay(2500);     }//End loop /****************************************************************   Function Fun Time ****************************************************************/ double dewPoint(double tempf, double humidity) {   double A0= 373.15/(273.15 + tempf);   double SUM = -7.90298 * (A0-1);   SUM += 5.02808 * log10(A0);   SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;   SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;   SUM += log10(1013.246);   double VP = pow(10, SUM-3) * humidity;   double T = log(VP/0.61078);     return (241.88 * T) / (17.558-T); }

Question by rwcwx   |  last reply


Picaxe 08m starts randomly blinking? Answered

I program my picaxe turn it on and it runs sweet for about ~20s and then after perfect operation the led that was on starts blinking and it then doesn't respond to any thing? The function of this program was to turn an led when the readabc from an input is under 100. when i connect the +ve to the input it makes the debugger say 255 but then it doesn't get any new debug data some times all the other variables change as well and its real erratic. Any reasons why this may be happening?

Question by wee_man   |  last reply


DIY IR Droid Module - 3.5mm to Infrared - Breadboard Prototype

Hey guys, I figured since I had grabbed so much great information from you all  I might try my luck with a little more! ;-) I have built this on my breadboard, powered with 6V 150mAh AC-DC converter. First connect saw at least one of the LEDs flicker dark orange and then go out. Assuming this means I burned it out, as afterwards I didn't notice any response. To prevent burning IR LEDs, I'll use visible LEDs, but I'm still concerned that my breadboard has a mistake. I'm pretty much worthless (but willing to learn, at least outside of the classroom setting!) at Phys II, so the debugging is foreign to me.  Pulling out the multimeter... What process should I be using to confirm that everything is powered correctly? The schematic is attached if you would like to customize your response to the hardware, but a general guide to debugging amplified LED circuits would be much appreciated as well! Additionally, if amplification the best way to go? How about a relay? Does that not offer the same (not Phys II...) amplitude? Smaller the better! Source List: - Schematic - Attached PDF - PCB Creation - https://www.instructables.com/id/Extreme-Surface-Mount-Soldering/ - Mounting plan - https://www.instructables.com/id/LEGO-Nikon-IR-Remote/ Thanks in advance! Andrew Oh, and I'll post a picture of it within the week to get another set of eyes. I must confess, it is a little ratty...

Question by JustUnicycle   |  last reply


TI TPA2000D4DAP: What's the PowerPad and other questions?

Hi, A couple months agao, I ordered something from TI but I actually ordered to wrong thing. What I got was the TPA2000D4DAP (http://focus.ti.com/lit/ds/symlink/tpa2000d4.pdf). I set it aside because I couln't use it. As I look at it now, I see that on the bottom of the is a square silver piece. Looking at the datasheet, it says that there is "Space-Saving, Thermally-Enhanced PowerPAD." Is that the PowerPAD? I read the paper on the powerPAD and it says its reflow soldered but I can't do that. Could I just use thermal paste if I ever wanted to use it for something. Another question is about the DAP letters. Does it mean Debug Access Port? Just wanted to read the correct paper on TI's site. Thanks

Question by phillyj   |  last reply


Grundig TV doesnt power up !

Hi everyone. I am new in this area, mention that I have the basis of electronics but I'm not good debugging. Now let's cut to the chase: I have a Grundig T70 - 540 text / GB, with chassis CUC 5310 (GCT 28 - do not know what this is, but may help). When I turned on the TV smelled burned and I quickly turned off from the button (the general). I opened, I checked visual components that can burn resistance, a capacitor etc, but I noticed nothing. I checked, because of the short time, the fuses on the board (I know, mistake). After i start the TV from general inside i hear a ticking, as the clock and nothing happens, the TV remains off. May it be the sound for entry in protection or something? What could it be?

Topic by danyelo   |  last reply


How can I create a program that allows me to run it and automatically upload a sketch to arduino without the software?

I have an Arduino uno board, and a robot that can follow, and have obstacle avoidance. My robot is designed for a person at school who has crutches for life, and the robot follows her with her books. I want to create a program with visual studio that automatically uploads each sketch to the board, depend on which button to click on. I already have visual micro for Visual Studio 10, and when I debug it or build it, it just uploads it to the robot. I need it to be a .bat file or a .exe file. If anyone could help me with this, I will be extremely grateful. Any ideas? Below I have a screenshot of what the program plans on doing.

Question by 28holes   |  last reply


Where can I buy a premade vox / PA-style voice-override circuit?

I have a pair of hearing protection headphones.  I want to play radio & walkie-talkie through them.  However, when the walkie talkie plays, I want the radio to cut out. This is a basic PA-style circuit.  Some sound mixers have this too.  I can find circuit schematics online, but no time to build a circuit. Is there a pre-made device I can buy to do this?  Ideally it'd be a small box with 3 audio jacks - 2 inputs & 1 output.  One of the audio inputs would override the other. This would also be great for things like music + GPS in the car.  Is there something premade that I can buy?  I'd rather not have to build & debug a DIY circuit, as I really don't have the time right now.

Question by jumpfroggy 


How to use a 3DS screen

Hi everyone! I have a spare  working 3DS screen (a friend of mine thought that her screen was broken, so she ordered a new one, and it turns out the problem wasn't solved so it didn't came from the screen, and she told me I could keep it if I wanted to). I'd like to know how I could use it in various projects, for debugging or for a more long term use. I don't need 3D (anyway I assume this wouldn't be possible unless I write a driver). Is it possible to add a VGA port? A HDMI or USB (I don't think that USB screens exists, but hey, we're on Instructables, everything is possible here ^^) Thanks for your help Please keep in mind that my knowledge in Electronics is not huge, as I study it for only two years in college, and now I only study Computer Technology. And also note that I'm French, I know my English speaking isn't perfect, so feel free to ask me to clarify any point that is not correct in your language

Topic by PepperBoy 


Need help with arduino code.?

Alright I asked this question on the arduino forums but nobody is giving me a straight answer, and it's getting annoying. I am using the capsense library on an attiny85, I want to count the number of times an even happens, in this case the capacitive censor exceeding a certain amount. Then based on that number I want it to turn on one led, or two, and so forth, to keep count. Can someone tell me how the f*****g get this to work? I try to use serial to debug and just get "Serial" not defined in this scope. Heres the code: #include #include CapacitiveSensor   cs_1_2 = CapacitiveSensor(1,2);        // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired int ledpin = 0; int countnumber = 0; void setup()                    {   cs_1_2.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example   pinMode (ledpin, OUTPUT); } void loop()                    {   long start = millis();   long total1 =  cs_1_2.capacitiveSensor(30);   if (total1 < 99) {    countnumber == 1;   }   if (countnumber = 1) {     digitalWrite(ledpin, HIGH);   } }

Question by XOIIO   |  last reply


Advice on microcontroller selection

Hello I am a newbie to the world of microcontrollers and would be really grateful for some advice about choosing one. Basically, I’m doing a final year university engineering project that requires an MCU to take a number of analogue inputs, do some processing, and spit out an analogue output that will drive a loudspeaker. My supervisor has recommended looking at the Philips LPC2148 and associated development kits (http://www.olimex.com/dev/lpc-h2148.html) because it is cheap and looks able to fulfil the following requirements: I/O – three analogue inputs (so 3 ADCs), 3 digital inputs (two servos and a bus for programming the controller), and one analogue output (requiring a DAC either built into the development board, or one I could connect on an add-on board) Speed – a program size of about 500 floating pt operations, processing samples at a rate of up to 400/second, hence of the order 200,000 floating pt operations per second. I think the LPC2148 uses fixed pt arithmetic so would need to perform the equivalent of this in fixed pt. Support – in place debugging support would be desirable; ability to be run on Windows; overall hardware and software cost of £100 or less. Does this chip and its development tools look up to the job? If not, would you recommend an alternative? Are there any other major criteria I’m neglecting in the process of selecting a MCU? Many thanks, Sam

Topic by samtheengineer   |  last reply


FEETECH 17DOF DIY humanoid robot

Https://www.instructables.com/edit/new Feetech 17 DOF humanoid robot ready to play for education DIY FEETECH New Humanoid Robot Profile https://www.youtube.com/watch?v=bSsR33E2Zr0 The FT-17DOF-SC-RTP is a ready to play humanoid robot which comes fully assembled & completed from our team at FEETECH. This humanoid robot uses 17PCS FT-SCServo (SCS15). SCS15 is all metal gear 15kg.cm and uses TTL level Half Duplex Asynchronous UART BUS Communication Protocol. It gives the feedback of the data relevant to position, voltage temperature, load and speed. This humanoid robot uses all aluminum alloy parts, anodized color (red, blue, white for optional) or an assortment.It is simple wiring and makes assembly and disassembly fast and convenient. It is easy to use "MOTION" editing software for Windows system. As long as you use a computer you will love playing with this humanoid robot, even if you do not have any programming knowledge, you can edit the humanoid robot actions within ‘MOTION’ editing software. Robot hobbyist can move the robot in a variety of different poses by hand, then read in and save data from robot joint SCServo via software, moving through the posture sequences from one by one will complete the program of series motion or dance. The data of dance or motion group can be saved into your local computer for use the next time, or download into the robot control board for offline operation. The 2.4G remote control system is based on Arduino open source, users can freely modify according to our Arduino source and combination with the Robot Control Board (SCM-1) to create more advanced functions. You will feel strong & excited when to play this robot dance and movement patterns. The Robot Control Board (SCM-1) can also accept UART instructions, allowing the user to send control instructions according to the packet data’s protocol complementing the robot scope of uses and research. Humanoid Robot Specifications Height:380mm; Weight: 1.7kg(Including battery); DOF:17 Degrees Of Freedom in total Head 1 PCS Hands 6 PCS Feet 10 PCS Connect with computer:USB-mini 2300mAH NI-MH rechargeable battery and AC charger Arduino open source 2.4 G remote control system Key feature -17DOF,UART BUS servo, simple wiring, easy to assemble and disassemble -It is easy to use "MOTION" editing software for Windows system, Programmed robot’s motion by hand. -Save the robot motion data on local and is easy to be use by other robots. -Motion automatic interpolations function; Make the movement more continuous and smooth, make sure the movement of posture to posture more perfect within specified speed time. -Can name the motion group by yourself if you need great for understanding and memory. It can repeat like function calls every motion group. Each motion can be imported and exported alone. -After a series of motion group orderly arrangement can coherent form a dance. Both played online and off-line available. -Each motion group can be remote controlled by Arduino open source 2.4G remote control system (especially good for use as a fighting robot) -With 39kb FLASH motion data storage unit, can be divided into 254 motion group. If storing one motion group, It can contain up to store 730 posture. -The “MOTION” software can show motion data. The robot will to move online when double-click any data of software. This is very easy to debug robot’s motion. -Can be controlled by Arduino UART with instructions. -NI-MH battery can recharge any time no needing worry about d damage. Battery can run about 30 minutes. -Accurate design of each part. Using a screwdriver can complete the assembly Packing list One assembly completed set of FT-17DOF-SC-RTP humanoid robot including: -All metal gear SCServo * 17pcs -Aluminum alloy machinery frame * 1set -Master control board (SCM-1) * 1pcs -Arduino open source 2.4 G remote control system * 1set -7.2V 3,000mAh NI-MH battery  * 1set -8.4 V AC charger * 1pcs -USB-mini cable 150cm -Programming software “Motion”  * 1set (download from Website) Related documents -Instruction manual -Robot debugging manual -Software debugging instruction -Remote controller instruction

Topic by Robotfans 


How to use Multiple mcp23017 chips with the adafruit mcp23017.h library?

I have been experimenting with I2C and the mcp23017 IO expander chip for my arduino ATMega2560 as I would rather use the IO on the arduino its self for other things I am just figuring out how to use the adafruit mcp23017.h library and cant figure out how to address multiple mcp23017 chips and how to use there pins individually this is the code from the button library that I editied. Here is the datesheet of mcp23017 I want to be able to address the individual chips and the pins I was not quite sure if in the setup that the pin modes for the IO go up sequentially from 0 past 15 if multiple chips are connected and addressed in code. For example if the first chip is addressed as 0x20 and the IO number count is from 0 - 15 if I added and addressed another chip as 0x21 will that count go from 0 - 15 to 0 - 31. ~ Edit if you could recommend or send a library that would be easier or could help please do. #include #include "Adafruit_MCP23017.h" //pin 1 and 0 are mcp pins not arduino IO pins Adafruit_MCP23017 mcp; void setup() {  mcp.begin();      // use default address 0 mcp.pinMode(0, INPUT); mcp.pinMode(1, OUTPUT); Serial.begin(9600); pinMode(13, OUTPUT);  // use the p13 LED as debugging } void loop() { // The LED will 'echo' the button digitalWrite(13, mcp.digitalRead(0)); //Writes pin 13 to the reading of pin    0 mcp.digitalWrite(1, mcp.digitalRead(0)); //Writes pin 1 to the reading of 0 if(mcp.digitalRead(1) == HIGH){ //if pin 1 == high serialprint led whent   high Serial.println("Led whent HIGH"); } }

Question by DELETED_MakiY2   |  last reply


I need help with my arduino code, the error code is "stray #" . located at #define DO_NEXT 4

1.//iOS switch control example 2.//Simple version 3.#define MY_DEBUG 1 4.#include "BluefruitRoutines.h" 5. 6.//Pin numbers for switches 7.#define PREVIOUS_SWITCH A0 8.#define SELECT_SWITCH A1 9.#define NEXT_SWITCH A2 10. 11.//Actions 12.#define DO_PREVIOUS 1 13.#define DO_SELECT   2 14.#define DO_NEXT     4 15. 16.uint8_t readSwitches(void) { 17.  return (~(digitalRead(PREVIOUS_SWITCH)*DO_PREVIOUS 18.      + digitalRead(SELECT_SWITCH)*DO_SELECT 19.      + digitalRead (NEXT_SWITCH)*DO_NEXT) 20.     ) & (DO_PREVIOUS+ DO_SELECT+ DO_NEXT); 21.} 22. 23.//Translate character to keyboard keycode and transmit 24.void pressKeyCode (uint8_t c) { 25.  ble.print(F("AT+BLEKEYBOARDCODE=00-00-")); 26.  uint8_t Code=c-'a'+4; 27.  if (Code<0x10)ble.print("0"); 28.  ble.print(Code,HEX); 29.  ble.println(F("-00-00-00-00")); 30.  MESSAGE(F("Pressed.")); 31.  delay(100);//de-bounce 32.  while (readSwitches()) { //wait for button to be released 33.    /*do nothing*/ 34.  }; 35.  ble.println(F("AT+BLEKEYBOARDCODE=00-00")); 36.  MESSAGE(F("Released")); 37.} 38. 39.void setup() { 40.  if(MY_DEBUG) 41.  while (! Serial) {}; delay (500); 42.  Serial.begin(9600); Serial.println("Debug output"); 43.endif 44.  pinMode(SELECT_SWITCH, INPUT_PULLUP); 45.  pinMode(NEXT_SWITCH, INPUT_PULLUP); 46.  pinMode(PREVIOUS_SWITCH, INPUT_PULLUP); 47.  initializeBluefruit(); 48.} 49. 50.void loop() { 51.  uint8_t i=readSwitches(); 52.  switch (i) { 53.    case DO_PREVIOUS: pressKeyCode('p'); break; 54.    case DO_SELECT:   pressKeyCode('s'); break; 55.    case DO_NEXT:     pressKeyCode('n'); break; 56.  } 57.} void setup() {   // put your setup code here, to run once: } void loop() {   // put your main code here, to run repeatedly: }

Question by JacLir00179   |  last reply


LED Cube problems

I am having some minor (or perhaps major) difficulties with my 3x3x3 Led Cube. I have a program that i wrote that cycles the different 3x3 cross sections and in 3 of the cross sections there is one column of leds that will light up even though it is not commanded or supplied power. I also have a sort of kill all routine that runs after each level is dislplayed that sets every pin to low. in my configuration the problem pins are pins 8, 17, and 26. if anyone knows how to debug this or help in any way it would be much appreciated. Thanks! I have a video of the LED cube with the problems here and a sample of my program here // kill all routine for(i=2, i<15, i++) { digitalWrite( i, LOW); } // Level routines that have problems of LEDs lighting up when they shouldn't elseif (LVL_Num ==10) {   for(j=0, j< Repeat, j++)   {    LED_ON(3); LED_ON(6); LED_ON(9);     delay(5)    LED_OFF(3); LED_OFF(6); LED_OFF(9);     delay(1)    LED_ON(11); LED_ON(14); LED_ON(17);    delay(5)    LED_OFF(11); LED_OFF(14); LED_OFF(17);    delay(1)    LED_ON(19); LED_ON(22); LED_ON(25);    delay(5)    LED_OFF(19); LED_OFF(22); LED_OFF(25);   } } elseif (LVL_Num ==11) {   for(j=0, j< Repeat, j++)   {    LED_ON(1); LED_ON(4); LED_ON(7);     delay(5)    LED_OFF(1); LED_OFF(4); LED_OFF(7);     delay(1)    LED_ON(11); LED_ON(14); LED_ON(17);    delay(5)    LED_OFF(11); LED_OFF(14); LED_OFF(17);    delay(1)    LED_ON(21); LED_ON(24); LED_ON(27);    delay(5)    LED_OFF(21); LED_OFF(24); LED_OFF(27);   } } elseif (LVL_Num ==13) {   for(j=0, j< Repeat, j++)   {    LED_ON(1); LED_ON(2); LED_ON(3);     delay(5)    LED_OFF(1); LED_OFF(2); LED_OFF(3);     delay(1)    LED_ON(13); LED_ON(14); LED_ON(15);    delay(5)    LED_OFF(13); LED_OFF(14); LED_OFF(15);    delay(1)    LED_ON(25); LED_ON(26); LED_ON(27);    delay(5)    LED_OFF(25); LED_OFF(26); LED_OFF(27);   } }

Question by Lee_Smith 


Arduino code Answered

Hello, I have been trying to make code for my arduino. I would like code to tell my arduino to receive a servo signal from my rc receiver, then detect whether the signal is telling the esc to move forwards or backwards. If the signal is forwards, it simply relays that code to the ESC. If the signal tells the ESC to go backwards, then it sends a signal to go forwards at the speed it would have gone in reverse, while sending out a power source to power a relay. Chowmix12 came up with some code that may help and I put  "//" before all of the code that was not needed for his application to work. Also, this link may be helpful for multitasking.  #include Servo ThrottleServo; //int PWMpin = 2; // connect RC receiver here. //int ServoVal; //int RCinput; void setup() { //Serial.begin(9600); //ThrottleServo.attach(9); // attaches the servo on pin 9 to the servo object //ThrottleServo.write(97); // go to nuetral pinMode(13, OUTPUT); } void loop() { //RCinput = pulseIn(PWMpin, HIGH, 20000); //ServoVal = map(RCinput, 520, 2370, 0, 180); //if(RCinput== 0) { // Signal timed out! digitalWrite(13, HIGH); // ALERT! ThrottleServo.write(97); // Go to neutral throttle position } //else{ // digitalWrite(13, LOW); // everything's fine. // ThrottleServo.write(ServoVal); // Repeat the data to the truck's ESC // Serial.print(" PulseMicros "); // This part is used to debug the values for calibration // Serial.print(RCinput); //Serial.print(" ServoRead "); // Serial.println(ServoVal); // } //} My program so far is as follows. /* created 2005 by David A. Mellis and chowmix12 modified by Justin Baker */ #include const int relay =  10; Servo ThrottleServo; int ServoVal; int RCinput; int PWMpin=2; int relayState = LOW;       long previousMillis = 0;    long interval = 1000;          void setup() {   pinMode(relay, OUTPUT);  Serial.begin(9600); pinMode(9, OUTPUT);  } void loop() { RCinput = pulseIn(PWMpin, HIGH, 20000); ServoVal = map(RCinput, 520, 2370, 0, 180); if(ServoVal>90) { digitalWrite(9, HIGH); ThrottleServo.write(ServoVal); } else{ ServoVal=180-ServoVal; digitalWrite(9, HIGH); ThrottleServo.write(ServoVal); }   unsigned long currentMillis = millis();   if(currentMillis - previousMillis > interval) {        previousMillis = currentMillis;       if (ServoVal >= 90)       relayState = LOW;     else       relayState = HIGH; //this output will turn a mosfet off, turning the relay off       digitalWrite(relay, relayState);   } }

Question by jbaker22   |  last reply


[URGENT] Unable to Connect Ethernet Shield With Ubuntu:? Answered

[URGENT] Unable to Connect Ethernet Shield With Ubuntu: I have Arduino Uno R3 compatible Microcontroller and Ethernet Shield v1.1 I tried a lot But the ethernet Shield isn't responding Online need help. Details are below My Ubuntu IP: 192.168.1.17 Mask: 255.255.255.0 Gateway: 192.168.1.1 Demo Arduino Sketch: #include #include #include Servo myservo; // create servo object to control a servo byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address byte ip[] = { 192, 168, 1, 177 }; // fixed IP addr in LAN byte gateway[] = { 192, 168, 1, 17 }; // internet access via router byte subnet[] = { 255, 255, 255, 0 }; //subnet mask EthernetServer server(80); //server port String readString; void setup(){ pinMode(6, OUTPUT); //pin selected to control LED //start Ethernet Ethernet.begin(mac, ip, gateway, subnet); server.begin(); //the pin for the servo co //enable serial data print Serial.begin(9600); Serial.println("server LED test"); // so I can keep track } void loop(){ // Create a client connection EthernetClient client = server.available(); if (client) { while (client.connected()) { if (client.available()) { char c = client.read(); //read char by char HTTP request if (readString.length() < 100) { //store characters to string readString += c; //Serial.print(c); } //if HTTP request has ended if (c == '\n') { Serial.println(readString); //print to serial monitor for debuging client.println("HTTP/1.1 200 OK"); //send new page client.println("Content-Type: text/html"); client.println(); client.println(""); client.println(""); client.println("Home Automation"); client.println(""); client.println(""); client.println("Home Automation"); client.println(""); client.println(""); client.println("Turn On Light"); client.println("Turn Off Light"); client.println(""); client.println(""); delay(1); //stopping client client.stop(); // control arduino pin if(readString.indexOf("?lighton") >0)//checks for on { digitalWrite(6, HIGH); // set pin 6 high Serial.println("LED On"); } else{ if(readString.indexOf("?lightoff") >0)//checks for off { digitalWrite(6, LOW); // set pin 6 low Serial.println("LED Off"); }} readString=""; //clearing string for next read }}}}}

Question by Beacon_av   |  last reply


sensitivity of servo that is controlled via android phone

Good day everyone! just like to ask for an assistance on how to make the motion of the servo motor more sensitive with the tilt of the android phone... our program was to control the tilt of the ball maze board via android phone... our code was also given... we are just wondering if this is just the limitation of the Bluetooth connection... we are using amarino application also for the connection between android phone and bluesmirf... here's the code... #include #include float data[3] = {0}; int intdata[3] = {0}; int i = 1; Servo myservo; Servo myservo2; int pos = 0; // MeetAndroid meetAndroid(); // you can define your own error function to catch messages // where not fuction has been attached for MeetAndroid meetAndroid(error); float previousdata = 0; int elapsedtime = 0; void error(uint8_t flag, uint8_t values) {   Serial.print("ERROR: ");   Serial.print(flag); } void setup() {   Serial.begin(115200); //begin serial link @ 9600bps   // register callback functions, which will be called when an associated event occurs.   // - the first parameter is the name of your function (see below)   // - match the second parameter ('A', 'B', 'a', etc...) with the flag on your Android application   meetAndroid.registerFunction(floatValues, 'A');    myservo.attach(9); //Attach the servo to pin eleven   myservo2.attach(10); } void StopCar() {   myservo.write(90);   myservo2.write(90); } void loop() {   myservo.write(90);   myservo2.write(90);   meetAndroid.receive(); // you need to keep this in your loop() to receive events } void floatValues(byte flag, byte numOfValues) {   // create an array where all event values should be stored   // the number of values attached to this event is given by   // a parameter(numOfValues)     // call the library function to fill the array with values (floats)   meetAndroid.getFloatValues(data);     for (int i=0; i<3;i++)   {     meetAndroid.send(data[i]);//Used for debug purposes   }   if (-10<=data[1]<=10)   {      intdata[1] = int(data[1]); //Cast the X axis float value to int      intdata[1] = intdata[1]+10;      pos = intdata[1]*9;      myservo.write(pos);   }   if (-10<=data[0]<=10)   {     intdata[0] = int(data[0]);     intdata[0] = intdata[0]+10;     pos = intdata[0]*9;     myservo.write(pos);   }   if (previousdata == data[0]) { //If the data's still the same (It should have been changed by the meetAndroid.getFloatValues(data) function)      if ((elapsedtime-millis())>=1000) { //If the car has lost the signal more than 1sec, then stop the car         StopCar();      }    }             }

Topic by maevalen   |  last reply


Virtualwire RF 433mhz Voltage problem

Hi, i am trying to have it switch a 5v relay on pin 8 receiver side only when pin 2 transmitter side in held down. I have set up a XY-MK 5v transmitter , Push button to pin 2 live when pushed 3.3v Data rf transmitter to pin 4 and 5v,gnd and receiver, data pin 2 5v and gnd led to pin 8 and gnd Here are the codes. Transmitter Code= #include const int button = 2; const int transmit_pin = 4; const int receive_pin = 2; const int transmit_en_pin = 3; void setup() {   // Initialise the IO and ISR   Serial.begin(9600);   vw_set_tx_pin(transmit_pin);   vw_set_rx_pin(receive_pin);   vw_set_ptt_pin(transmit_en_pin);   vw_set_ptt_inverted(true); // Required for DR3100   vw_setup(2000);  // Bits per sec } byte count = 1; void loop() {   char msg[7] = {'h','e','l','l','o',' ','#'};   if     (digitalRead(button) == HIGH)   {Serial.println("on its way");   msg[6] = count;   //digitalWrite(led_pin, HIGH); // Flash a light to show transmitting   vw_send((uint8_t *)msg, 7);   Serial.println("on its way");   vw_wait_tx(); // Wait until the whole message is gone   //digitalWrite(led_pin, LOW);   //delay(1000);   count = count + 1; } } And receiver code = #include const int led_pin = 8; const int transmit_pin = 12; const int receive_pin = 2; const int transmit_en_pin = 3; void setup() {     delay(1000);     Serial.begin(9600); // Debugging only     Serial.println("setup");     // Initialise the IO and ISR     vw_set_tx_pin(transmit_pin);     vw_set_rx_pin(receive_pin);     vw_set_ptt_pin(transmit_en_pin);     vw_set_ptt_inverted(true); // Required for DR3100     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     { int i;         digitalWrite(led_pin, HIGH); // Flash a light to show received good message // Message with a good checksum received, print it. Serial.print("Got: "); for (i = 0; i < buflen; i++) {      Serial.print(buf[i], HEX);      Serial.print(' '); } Serial.println();         digitalWrite(led_pin, LOW);     } } I have tried many different codes i have found and this works the best but.........the voltage is only going from 0.20v to 0.40 on the receiver pin 8. i need this to be 5v any ideas?

Topic by Senken   |  last reply


Can't properly flash Attiny85, please help.

I have working proto of a bathroom exhaust fan controlled by methane sensor via arduino uno. I now wish to transfer this sketch to an ATtiny85 (cause i had extras). I have programmed ATtiny before, and can successfully get 'blink' going on this specific MCU. However I cannot get my sensor sketch to work properly... Perhaps I am asking too much of this little guy? I am including my code and video in hopes that someone can steer me in the right direction.  /*   AT85      Arduino    Circuit   0 (PB5)   A0             pin 3 of 50k pot   2 (PB7)   ~9             led or relay     Trim Pot        1              GND   2              GND   3              Arduino (attiny) & Sensor B1     Sensor   A1             +5VDC   H1             GND   GND            GND   B1             Trim Pot 3   */   const int numReadings = 10;    // average sensor reading used from 10 samples int ledPin = 1;                  // replaced ac/dc relay with led to debug int readings[numReadings];      // the readings from the analog input int index = 0;                  // the index of the current reading int total = 0;                  // the running total int average = 0;                // the average int inputPin = 0;    //reading from sensor unsigned long start_time; unsigned long current_time; unsigned long elapsed_time; void setup() {   // sets digital pin 1 to output   pinMode(ledPin, OUTPUT);     // sets analog 0 to input   pinMode(inputPin, INPUT);   // initialize all the readings to 0:   for (int thisReading = 0; thisReading < numReadings; thisReading++)     readings[thisReading] = 0;          } void loop() {         // 10 sample average used to prevent false positive from a bounce and/or spike         // subtract the last reading:   total= total - readings[index];           // read from the sensor:    readings[index] = analogRead(inputPin);   // add the reading to the total:   total= total + readings[index];         // advance to the next position in the array:    index = index + 1;                      // if we're at the end of the array...   if (index >= numReadings)                  // ...wrap around to the beginning:     index = 0;                             // calculate the average:   average = total / numReadings;           // send it to the computer as ASCII digits          delay(1000); // delay in between reads for stability                    int threshold = 300;                  // sets the threshold value   if(average > threshold){  // determines if the level of methane breaks threshold         start_time = millis();      // starts exhaust fan on 5 min timer     digitalWrite(ledPin, HIGH);      do  {       current_time = millis();      // defines the 5 minute timer       elapsed_time = current_time - start_time;     }     while(elapsed_time < 300000); // 5 min. countdown   }     if(average < threshold){      // sensor is checked against threshold       digitalWrite(ledPin, LOW);  // fan turns off if sensor value below threshold     }                             // or stays on until it is below threshold     } http://youtu.be/cm_uuEXd8HM thanks in advance!

Question by earthtown   |  last reply


Virtualwire RF 433mhz Voltage problem mk2

Hi, I have this code and have modded it a bit, i was wondering if there was a way of making the pincode more than 1 digit long? Also i have got the code sending command and pin code when buton to pressed and stopping when released and the receiver end reading it and seeing it stop, sending a pin high when it reads it but i cant get i to go low when it stops receiving it. wen ever it looks like it will work It seems to make the pin go to 0.16 when low to 0.24 when high. can you help? tom Transmitter code #include int button = 2;   void setup() {     Serial.begin(9600);     vw_set_ptt_inverted(true);     vw_setup(2000);     vw_set_tx_pin(4);     pinMode(button,INPUT);     pinMode(button,LOW);   }   void loop() {     while     (digitalRead(button) == LOW);      sendMessage("1", "5");      //delay(10000);   }   void sendMessage(char* pinCode, char *data) {      if (strlen(data) > 0) {       double startTime = millis();       Serial.println("Sending...");       int msgSize = (strlen(data) + strlen(pinCode) + 1);       char packetData[msgSize];       strcat(packetData, pinCode);       strcat(packetData, ".");       strcat(packetData, data);       Serial.println("Debugging ");       Serial.print("Sending Command: ");       Serial.print(data);       Serial.print(" with Pin Code: ");       Serial.print(pinCode);       Serial.print("\n");       vw_send((uint8_t *)packetData, msgSize);       vw_wait_tx();       double endTime = millis();       double timeTaken = (endTime - startTime);       Serial.print("Time Taken: ");       Serial.print(timeTaken);       Serial.print(" ms\n");     }    } Receiver Code #include   #include   int relay = 8;   byte message[VW_MAX_MESSAGE_LEN];   byte messageLength = VW_MAX_MESSAGE_LEN;   void setup() {     Serial.begin(9600);     vw_set_ptt_inverted(true);     vw_setup(2000);     vw_set_rx_pin(2);     vw_rx_start();     pinMode(relay,INPUT);     pinMode(relay,LOW);   }   void loop() {     while     //(vw_have_message())    (vw_get_message(message, &messageLength;))     {        int command = processResponse((char*)message, 1); //Byte Array Response and Pin Code.        if       // (vw_have_message());        (command) {          Serial.print("Received Command: ");          Serial.print(command);               Serial.print("\n");          digitalWrite (relay,HIGH);        }                   else //REMOVE          delay(100); //REMOVE          digitalWrite (relay,LOW); //REMOVE                 }    } int processResponse(char* message, int pinCode) {       char *p = message;       char *buf;       int o = 0;       int pin;       int command;       while ((buf = strtok_r(p, ".", &p;)) != NULL)  {          if (o == 0) {            pin = atoi(buf);                    } else {            command = atoi(buf);            ;          }          o++;       }       if (pinCode == pin && command > 0) {           return command;                 } else {          return 0;                         }   } This code only sends pin 8 from 0.14 when low to 0.17 when high. unless you remove the three lines marked REMOVE then it goes from 0.14 when low to 4.47 when high but stays there and will not go low when buttton it released. Please help

Topic by Senken 


My code compiles, but doesn't work?? Answered

Hi, i'm doing a project based on the capacitive sensor method. the code will work fine as standard, but when its  with my added extras it doesnt work but it compiles. The other thing is that the its printing to the serial at 3.4 seconds, do you know why this might be. here's the code. #include #include Servo Mech; int pos = 0;   /*   * CapitiveSense Library Demo Sketc  * Paul Badger 2008 5.  * Uses a high value resistor e.g. 10M between send pin and receive pin 6  * Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values. 7.  * Receive pin is the sensor pin - try different amounts of foil/metal on this pin 8.  */     CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);        // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired CapacitiveSensor   cs_4_6 = CapacitiveSensor(4,6);        // dnt need this CapacitiveSensor   cs_4_8 = CapacitiveSensor(4,8);        // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil int light = 13; int yellow = 12; //dnt need this int power = 11; int fans = 5; boolean status_light = LOW, status_light_prev = LOW; boolean status_yellow = LOW, status_yellow_prev = LOW; // dnt need this boolean status_power = LOW, status_power_prev = LOW;    void setup()                    {     cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example     Serial.begin(9600);     Mech.attach(9);     pinMode(light, OUTPUT);     pinMode(yellow, OUTPUT); // dnt need this     pinMode(power, OUTPUT);     pinMode(fans, OUTPUT); }   void loop()                    {      long start = millis();      long total1 =  cs_4_2.capacitiveSensor(30); // to power pin 11      long total2 =  cs_4_6.capacitiveSensor(30); // dnt need this      long total3 =  cs_4_8.capacitiveSensor(30); // to light        Serial.print(millis() - start);        // check on performance in milliseconds      Serial.print("\t");                    // tab character for debug windown spacing        Serial.print(total1);                  // print sensor output 1      Serial.print("\t\t\t");      Serial.print(total2);                  // print sensor output 2      Serial.print("\t\t\t");      Serial.println(total3);                // print sensor output 3        delay(100);                             // arbitrary delay to limit data to serial port          if (total1 > 200)        status_light = !status_light;      Serial.print("\tstatus_light = ");      Serial.print(status_light);      Serial.print("\t");          if (status_light)        Mech.write(20);     else     Mech.write(160);     delay(600);          if (status_light)        digitalWrite(light, HIGH);      else      digitalWrite(light, LOW);                if (total2 > 200)                // dnt need this        status_yellow = !status_yellow;      Serial.print("status_yellow = ");      Serial.print(status_yellow);           Serial.print("\t");      if (status_yellow)        digitalWrite(yellow, HIGH);        else        digitalWrite(yellow, LOW);     if (total3 > 200)       status_power = !status_power;      Serial.print("status_power = ");      Serial.println(status_power);      if (status_power)        digitalWrite(power, HIGH);      else        digitalWrite(power, LOW);        if (status_power)               if (status_power)        digitalWrite(fans, HIGH);        else        digitalWrite(fans, LOW);     } thank you for your help thank you.

Question by icey.hood   |  last reply


wemos d1 mini blynk? display temperature&humidity?

this is my code and it works to display c&% on display and blynk app and it notifies me when it starts and run time, is there a way to display runtime/uptime on the display and should i remove anything? maybe add in code to send email when offline for more than 5 minutes? why does the screen go black when it updates? what other data can i display on the screen? it will be used to monitor server room temperature, thanks #include #include #include #include "Adafruit_SSD1306.h" #include #include #include #define OLED_RESET 0  // GPIO0 Adafruit_SSD1306 display(OLED_RESET); #define BLYNK_PRINT Serial #define DHTPIN D4 #define DHTTYPE DHT22  DHT dht(DHTPIN, DHTTYPE); // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = ""; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = ""; char pass[] = ""; BlynkTimer timer; void notifyUptime() {   long uptime = millis() / 60000L;   // Actually send the message.   // Note:   //   We allow 1 notification per 15 seconds for now.   Blynk.notify(String("Running for ") + uptime + " minutes."); } void sendSensor() {   float h = dht.readHumidity();   float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit   if (isnan(h) || isnan(t)) {     Serial.println("where is my DHT sensor!");     return;   }   // You can send any value at any time.   // Please don't send more that 10 values per second.   Blynk.virtualWrite(V5, h);   Blynk.virtualWrite(V6, t); } void setup() {   // Debug console   Serial.begin(9600);   Blynk.begin(auth, ssid, pass);   // You can also specify server:   //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);   //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);   dht.begin();   // Notify immediately on startup   Blynk.notify("Device started");   // Setup a function to be called every minute   timer.setInterval(60000L, notifyUptime);     // Setup a function to be called every second   timer.setInterval(1000L, sendSensor); } void loop() {   Blynk.run();   timer.run();   Serial.begin(115200);   dht.begin();   // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 64x48)   display.display();   delay(5000);   // Efface l'écran et positionne le curseur dans le coin supérieur gauche - clear display and set cursor on the top left corner   display.clearDisplay();   display.setTextSize(2);   display.setTextColor(WHITE);   display.setCursor(0,0);   float h = dht.readHumidity();   float t = dht.readTemperature();   float f = dht.readTemperature(true);   float bat = ESP.getVcc();// / 1024;   // Check if any reads failed and exit early (to try again).   if (isnan(h) || isnan(t) || isnan(f)) {     Serial.println("where is DHT sensor!");     return;   }     // Température en Celcius - Temperature in Celcius // display.println("Temp.");   display.print(t);   display.println(" c");   // Humidité en % - Humidity in % // display.println("Humidity"); //display.setTextSize(1);   display.print(h);   display.print(" %");   display.display(); }

Question by turbiny 


RadioShack Tri Color LED strip light show help?

I'm having partial success creating a synchronized light show by calling some colors and adding delays. My main problem is creating specific colors or even displaying one color on the entire strip.  here's the default code for the strip for arduino: #include // ******** DEBUG ==== should auto config to adapt different mother board ********* //#define DATA_1 (PORTF |=  0X01)    // DATA 1    // for ATMEGA //#define DATA_0 (PORTF &=  0XFE)    // DATA 0    // for ATMEGA //#define STRIP_PINOUT DDRF=0xFF  // for ATMEGA #define DATA_1 (PORTC |=  0X01)    // DATA 1    // for UNO #define DATA_0 (PORTC &=  0XFE)    // DATA 0    // for UNO #define STRIP_PINOUT (DDRC=0xFF)    // for UNO PROGMEM const unsigned long pattern_test_red[10][10]={   {0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000}, }; PROGMEM const unsigned long pattern_test_blue[10][10]={   {0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00}, }; PROGMEM const unsigned long pattern_test_green[10][10]={   {0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff}, }; PROGMEM const unsigned long pattern_test_white[10][10]={   {0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff}, }; PROGMEM const unsigned long pattern_test_comet1[][10]={   {0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff}, }; PROGMEM const unsigned long pattern_test_comet2[][10]={   {0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000},   {0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000},   {0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000},   {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},   {0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff},   {0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000},   {0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000},   {0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000},   {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},   {0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff}, }; PROGMEM const unsigned long pattern_test_comet3[][10]={   {0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff},   {0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x444444},   {0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0xffffff,0x444444,0x111111},   {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0xffffff,0x444444,0x111111,0x000000},   {0x000000,0x000000,0x111111,0x444444,0xffffff,0xffffff,0x444444,0x111111,0x000000,0x000000},   {0x000000,0x000000,0x111111,0x444444,0xffffff,0xffffff,0x444444,0x111111,0x000000,0x000000},   {0x000000,0x000000,0x000000,0xffffff,0x444444,0x444444,0xffffff,0x000000,0x000000,0x000000},   {0x000000,0x000000,0xffffff,0x444444,0x111111,0x111111,0x444444,0xffffff,0x000000,0x000000},   {0x000000,0xffffff,0x444444,0x111111,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},   {0xffffff,0x444444,0x111111,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff}, }; PROGMEM const unsigned long pattern_test_rainbow[10][10]={   {0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000},   {0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000},   {0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000},   {0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff},   {0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff},   {0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff},   {0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00},   {0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00},   {0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00},   {0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000}, }; // *********************************************************************************************************** // * // *                            Power Up Init. // * // * // *********************************************************************************************************** void setup() {                  STRIP_PINOUT;        // set output pin - DEBUG: should auto detect which mother board for use   reset_strip();   //noInterrupts(); } // *********************************************************************************************************** // * // *                            Main Loop // * // * // *********************************************************************************************************** void loop() {   send_1M_pattern(pattern_test_red, 10, 500);   delay(500);   send_1M_pattern(pattern_test_blue, 10, 500);   delay(500);   send_1M_pattern(pattern_test_green, 10, 500);   delay(500);   send_1M_pattern(pattern_test_white, 10, 500);   delay(500);   send_1M_pattern(pattern_test_comet1, 10, 70);   delay(500);   send_1M_pattern(pattern_test_comet2, 10, 70);   delay(500);   send_1M_pattern(pattern_test_comet3, 10, 70);   delay(500);         while (1)   {     send_1M_pattern(pattern_test_rainbow, 10, 70);   }   /* frame++;     if(frame<=10) LEDSTRIP_PATTERN_0();     if(10     if(20     if(frame>30) frame=1;    */   //delay(1); } /******************************************************************************* * Function Name  : send_1M_pattern * Description    : Transmit pattern to whole 1 meter strip *                  * Input          : pointer to ROM pattern; pattern length; frame rate *                  * Output         : None * Return         : None *******************************************************************************/ void send_1M_pattern(const unsigned long data[][10], int pattern_no, int frame_rate) {   int i=0;   int j=0;   uint32_t temp_data;   for (i=0;i   {     noInterrupts();     for (j=0;j<10;j++)     {       temp_data=pgm_read_dword_near(&data;[i][j]);       send_strip(temp_data);     }     interrupts();     delay(frame_rate);   } } /******************************************************************************* * Function Name  : send_strip * Description    : Transmit 24 pulse to LED strip *                  * Input          : 24-bit data for the strip *                  * Output         : None * Return         : None *******************************************************************************/ void send_strip(uint32_t data) {   int i;   unsigned long j=0x800000;     for (i=0;i<24;i++)   {     if (data & j)     {       DATA_1;       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");          __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       /*----------------------------*/       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");        __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");        __asm__("nop\n\t");        __asm__("nop\n\t");        /*----------------------------*/            DATA_0;     }     else     {       DATA_1;       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");          DATA_0; /*----------------------------*/             __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");      /*----------------------------*/             }     j>>=1;   }   } /******************************************************************************* * Function Name  : reset_strip * Description    : Send reset pulse to reset all color of the strip *                  * Input          : None *                  * Output         : None * Return         : None *******************************************************************************/ void reset_strip() {   DATA_0;   delayMicroseconds(20); } //***********AND HERE"S MY MODIFIED LIGHT SHOW CODE:*********** #include // ******** DEBUG ==== should auto config to adapt different mother board ********* //#define DATA_1 (PORTF |=  0X01)    // DATA 1    // for ATMEGA //#define DATA_0 (PORTF &=  0XFE)    // DATA 0    // for ATMEGA //#define STRIP_PINOUT DDRF=0xFF  // for ATMEGA #define DATA_1 (PORTC |=  0X01)    // DATA 1    // for UNO #define DATA_0 (PORTC &=  0XFE)    // DATA 0    // for UNO #define STRIP_PINOUT (DDRC=0xFF)    // for UNO PROGMEM const unsigned long pattern_test_red[10][10]={   {0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000}, }; PROGMEM const unsigned long pattern_test_blue[10][10]={   {0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00}, }; PROGMEM const unsigned long pattern_test_green[10][10]={   {0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff}, }; PROGMEM const unsigned long pattern_test_white[10][10]={   {0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff}, }; PROGMEM const unsigned long pattern_test_comet1[][10]={   {0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff}, }; PROGMEM const unsigned long pattern_test_comet2[][10]={   {0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000},   {0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000},   {0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000},   {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},   {0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff},   {0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000},   {0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000},   {0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000},   {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},   {0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff}, }; PROGMEM const unsigned long pattern_test_comet3[][10]={   {0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff},   {0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x444444},   {0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0xffffff,0x444444,0x111111},   {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0xffffff,0x444444,0x111111,0x000000},   {0x000000,0x000000,0x111111,0x444444,0xffffff,0xffffff,0x444444,0x111111,0x000000,0x000000},   {0x000000,0x000000,0x111111,0x444444,0xffffff,0xffffff,0x444444,0x111111,0x000000,0x000000},   {0x000000,0x000000,0x000000,0xffffff,0x444444,0x444444,0xffffff,0x000000,0x000000,0x000000},   {0x000000,0x000000,0xffffff,0x444444,0x111111,0x111111,0x444444,0xffffff,0x000000,0x000000},   {0x000000,0xffffff,0x444444,0x111111,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},   {0xffffff,0x444444,0x111111,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff}, }; PROGMEM const unsigned long pattern_test_rainbow[10][10]={   {0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000},   {0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000},   {0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000},   {0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff},   {0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff},   {0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff},   {0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00},   {0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00},   {0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00},   {0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000}, }; // *********************************************************************************************************** // * // *                            Power Up Init. // * // * // *********************************************************************************************************** void setup() {                  STRIP_PINOUT;        // set output pin - DEBUG: should auto detect which mother board for use   reset_strip();   //noInterrupts(); } // *********************************************************************************************************** // * // *                            Main Loop // * // * // *********************************************************************************************************** void loop() {   send_1M_pattern(pattern_test_white, 0, 0);   delay(36000);   send_1M_pattern(pattern_test_white, 500,0);   delay(5000);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);    send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);    send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);     send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 10, 70);   delay(10);   send_1M_pattern(pattern_test_white, 500, 0);   delay(4000);       while (1)   {     send_1M_pattern(pattern_test_rainbow, 10, 70);   }       /* frame++;     if(frame<=10) LEDSTRIP_PATTERN_0();     if(10     if(20     if(frame>30) frame=1;    */   //delay(1); } /******************************************************************************* * Function Name  : send_1M_pattern * Description    : Transmit pattern to whole 1 meter strip *                  * Input          : pointer to ROM pattern; pattern length; frame rate *                  * Output         : None * Return         : None *******************************************************************************/ void send_1M_pattern(const unsigned long data[][10], int pattern_no, int frame_rate) {   int i=0;   int j=0;   uint32_t temp_data;   for (i=0;i   {     noInterrupts();     for (j=0;j<10;j++)     {       temp_data=pgm_read_dword_near(&data;[i][j]);       send_strip(temp_data);     }     interrupts();     delay(frame_rate);   } } /******************************************************************************* * Function Name  : send_strip * Description    : Transmit 24 pulse to LED strip *                  * Input          : 24-bit data for the strip *                  * Output         : None * Return         : None *******************************************************************************/ void send_strip(uint32_t data) {   int i;   unsigned long j=0x800000;     for (i=0;i<24;i++)   {     if (data & j)     {       DATA_1;       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");          __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       /*----------------------------*/       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");        __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");        __asm__("nop\n\t");        __asm__("nop\n\t");        /*----------------------------*/            DATA_0;     }     else     {       DATA_1;       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");          DATA_0; /*----------------------------*/             __asm__("nop\n\t");       __asm__("nop\n\t");       __asm__("nop\n\t");      /*----------------------------*/             }     j>>=1;   }   } /******************************************************************************* * Function Name  : reset_strip * Description    : Send reset pulse to reset all color of the strip *                  * Input          : None *                  * Output         : None * Return         : None *******************************************************************************/ void reset_strip() {   DATA_0;   delayMicroseconds(20); }

Question by ray33_ 


Oculus GO - The little sideloading guide

It seems making an Instructable these days requires lots of pictures, detailed steps and tons of instructions.So before I try to paste my attempt here, I will point something out for the support team:1. There is little point in including pictures of a VR headset or how to plug a USB cable in. Same for images showing a DOS window and the command typed in it - they are the same as in the instructions...2. With little to no option to create an Instructable that requires actual code usage and properly embedded picture, let alone good editing options: How do you suggest one would accomplish this taks?3. With no category to post such Instrucables it is my personal opinion that these catergories need quite some updates! They are still the same as years ago despite life evolving around it...If you just went into the mobile VR world then you might feel a bit restricted compared to what you know from your smartphone.Over the months firmware updates provided us with some much needed things but a bit is still left out. In this Ible I will try to show way to get a bit more out of your GO. Be aware that a lot of it still requires a bit of manual work and a computer.If you are just curious then please read on and you might still find something interesting that you did not know yet.Getting started...One thing we certainly need is a way to access the GO and to install additional apps on it that are not available in the store.For this we need to activate the developer options. Unlike your normal Android device this step works only from the device you paired with your GO. Go into the settings and there look for the developer mode. Once you try to activate it Oculus requires you to sign up for a developer account. All this of course needs to be confirmed through Email activation, you know just to make it complicated and get more info about you ;) From there it is straight forward and like on any Android. Activate USB debugging, pair with your computer by USB cable and on the GO authorise the connection. Please also tick the box to make this permanent as otherwise you will be prompted every time. In case you are not so familiar with this just Google how to use ADB on Android - it is simple. I will add the required files and drivers in a later step dedicated to it.If you need more help getting the right options done or where to find them, please consider the great help for this offered on the Oculus developer sites. It makes sense to spent some time there as you find a lot of good info that might come in handy once you really want to get serious.ADB - A must have...You will find the drivers and all, as said, a bit later. ADB is the Android Debug Bridge. It allows us to get access to the (user)available file systems, do some basic tests and if supported even flash a firmware or make a backup.If you already used ADB for another Android device then you will only need the drivers for the GO. Otherwise you need to set up the enviroment for the Debug Bridge first. In the downloads will be a simple installer for this purpose. It is vital that you authorise your computer on the GO, best to tick the box to make it permanent.If you open a command prompt where you have ADB installed you can do some simple tests. Setting all required paths and system variables in Windows would allow you to access ADB functions from any folder on your computer. The later might be easier if you do not want to copy all related files into your ADB folder. Makes no real difference though and is up to your preferences.The command ADB devices should show you now that your GO is connected by listing it. If nothing shows up then please check the USB debugging option is set in the developer options. A reboot might help too in some cases. With this sorted we are good to go, almost at least...How to install "unknown" apps?As you might have noticed there is no playstore and all available stuff in the official store is VR based.Getting some essential apps on it seems to be impossible.Again the help offered by Oculus in the developer sections is a vital source, so please don't be afraid to read there ;) There are two basic ways of doing things on a device with so many restrictions.1. Just use ADB install packetname Where packetname is the filename for the app in question, for example Netflix.apk. With all apps you need in one place this is quickly done.2. Use a dedicated app installer or manager for the job. I will include one that actually works with the downloads. Same fore more detailed instructions.The thing is though that only apps designed and signed for VR will show up in your normal launcher. All other (supported) Android apps will show up in "unknown sources" in your library. Apps not supported for this purpose won't show anywhere! For them you need a dedicated launcher, which will be placed in the "unknown sources" section ;)Why do I spoon feed you here you might wonder? To be honest: If you already read some terms and basics it will be much easier to remember. Repetition is the key ;) I see little point in providing a simple to follow list of intructions as a week later you would struggle to do it again without the list in front of you.Our first unknown apps!Deciding what you might need in apps is one thing, knowing in what order you can safe hours of your life is another. I simply don't think you want to juggle with ADB whenever you want a new app that is not available in the official store. So for starters we will need something that is able to install apps for us. And since we can't use it without something to find and start it we also need an app starter. Basically like HALauncher for Android TV.The detailed instructions for this can be found with the downloads. First the app starter is installed, it will provide us with a living room like view onto a big screen. On the screen you will find all apps that are otherwise invisible to you. Some might tempt you to try them out - just don't! Unless you really know what you are doing you have a good chance to do something bad. Use the apps you know and the apps you added but none of the tempting system apps you might see.The APK installer will show up there too and is used to make installing apps a bit easier. You can copy them now onto your GO's internal storage and use the app installer to install them - how easy is that? Another option I included is the Aurora store - a fork of the YALP store and able to work without any playstore requirements. Downside is that the VR controllers are not fully supported yet as it is more aimed at TV sets. A BT touchpad works though if the controller or a gamepad fail. I only included Aurora as it could be a nice alternative one day with full VR support. Just search or browse for all the apps available in the playstore and install what you like. Be aware though that not everything will work with the remote. Some games and apps can be operated with a game controller though.It is getting nicer already ;)By now you might have already installed some things as you just could not wait to skip to the downloads.Well, can't really blame you, can I?Anyways, we now have the option to install more apps that we know from our non-VR Android devices. Oculus might make it harder in the future though - or they see it the same way and offer ready to go options one day. Till then it is up to you....Youtube VR might be nice but it is also still quite buggy and lacks some basic features. So getting a modded Youtube app could be a way out if you need comments for example. Kodi is still a must have for many Android users, especially the sport nuts with us. A filemanager is also something most Android users value. I will include some but again it comes down to what YOU prefer here. And with a basic way to install apps now you can also remove them again if you decide they don't work as expected.Get a bit used to the app launcher and how to install apps. Sideloading is fine for those used to it but some might prefer to just copy some apps on the GO and them use the installer with the remote. In the near future we will get support for external sorage, so using a USB stick or SD card in a reader will make the USB cable obsolete for file transfers. Some headsets already support it, so chances are by the time you read this yours will too. Although it still is a good way to keep your GO charged while copying big files ;)Precautions and Words of WisdomIt all sound nice and easy now but there are dangers you need to be aware of! Installing apps or games that are not fully designed for the GO or VR use can mean crashes. A lot will work but that does not mean it will keep doing so. A firmware update could one day end the support for sideloaded apps that are "non-VR". Especially messing with the app launcher can mean sudden disaster. Things you normally can not see are often hidden from you for a good reason. I will take no responsiblity for problems you caused by misusing system apps !Console emulators are a lot of fun and there are ways to even stream them from your PC in reasonable quality on a low end computer. But these and some demanding games also cause a lot of CPU usage. As the system is not optimised for 2D content it can mean that your battery runs out faster. In some cases you might not see the warning to charge, so be aware of time when immersing yourself.Stay away from any app or game that requires playstore components! Play Games for leaderboards might be no issue, especially if you don't need this feature. Online gaming like multiplayer actions will not work if it requires Google services for it! Similar story for hardware you don't have. If it is only designed for touchscreens than it might not work with the remote. And if it does not support gampads either... Apps that only support the wrong display orientation are a no go too.What Non-VR Stuff Actually Works on the GO?A lot and it will be possible to do even more. There are already streaming options for your own videos like Skybox, Moonplayer and they all support DLNA servers too. So watching normal, 3D or VR movies from a media server is no problem at all already. Getting games to work is another story all up. ALVR is a good platform to stream VR games from your PC to the GO. Unlike the Rift you won't even need an overpowered gaming PC for it. Virtual Desktop is a paid app but well worth the money if the support and features keep going as they do right now. With it you can use your computer or laptop from the GO. Watch movies, surf the net, play games. The GO more or less becomes a normal Windows computer only that you have the screen right in front of you.It will certainly be possible to code a simple VR app that works as a shortcut for non-VR apps. Like how right now you get the pic and description for a VR exerience and a button that starts the stream in the player. Downside is the requirement to certify such an "app" to make it visible in the normal launcher.Downloads and Instructions....Finally you get to the point where you can actually download something :)To make it all a bit easier and to ensure I won't miss a vital bit I did a factory reset on my GO to start from scratch :(Things might change in the future, so I will include the instructions as texfiles with the download.If I see a real requirement for screenshots I will include them with corresponding filenames.I think this way it is easier than scrolling through an Instructable as you can just print it all directly.Those without an account (yet) might value this too.Based on the feedback, questions and general comments I will change the contents of the download accordingly.Same for download links to avoid bloating up the download with outdated files.Easier for you (if you read this a few months from now) to download the newest files directly from the source.So don't be too disappointed if the download seems to contain less than what you expected.What seems to be missing will have links in the instructions.No files will come from unverified or unsecure sources!Whatever I include in the downloads directly will be checked for malware of all kinds.The same standards are true for the sources I provide.So no clickbait, ad sponsored re-directors or such crap.Please read the detailed instructions carefully, then read them again while actuall following the steps on your GO or computer.Do not blindly read it and jump onto doing it the first read!For ADB commands just copy and paste them - I might write some batch files though, so check for them in the instructions and make use of them.Things might not work out as planned, so if in doubt double check all the steps taken.What is in the provided instructions is tested on my GO's and works on the firmware version current of this writing.Download the guide and files from FilefactoryIn case the PDF in the download is not detailed enough, just ask in the comments ;)

Topic by Downunder35m   |  last reply


QUICK: Ideas for getting drone out of tree! [EDIT: already got it down, but ideas are welcome!]

Ok, so I have built up my $400 FPV quadcopter, and just last night, I was able to get it in the air working flawlessly! I then proceeded to have fun with FPV on a small TV monitor. I quickly got the hang of it, and decided to venture up and around the back yard. However, there was one problem I have been neglecting, which of course, it bit my ass as you can tell from the title. From countless hours of debugging and stress-testing previous weeks to find the intermittent issue with the ESCs, I finally pinned down the issue and was able to reprogram the ESCs, as well as calibrate them properly. (turned out when I first built the quad many moones ago, I unknowingly entered programming mode in the past and changed stuff I had no intention to change!) So eventually, I punctured one of the cells on the battery, and did not realize until a few days ago. I found after close inspection that it was most likely due to a crash which dislodged the battery from the strap, and it scraped up against the video transmitter shielding and heatsink. I removed and discarded the damaged cell, so I was left with a 2S battery. It is BARELY enough to lift the quad. And very slowly at that. However, I could not wait for the new battery to come! I just HAD to fly it to see if I got it to work! :D So today, I have been practicing full-on FPV, and unknowingly flew above a tree. I thought I was next to our chicken house,  and was looking directly at it, hoping to land directly in front of it. However, I did not know I was as close as I was to the tree directly below me. By the time I saw it it in the mobius camera, a slammed the throttle as high as possible, but by that time it was too late. That stupid 2S battery that I have not bothered to replace just did not have the umph to pop the quad up into the air higher, and as it discharged to below 6.98V based on the video feedback data, and the quad just kept descending even at full throttle due to the voltage being too low to effectively power the motors. So there it went tumbling and got snagged on to a thin limb. I lost remote control, so I could not get it unstuck like I did before from a previous flight. But I still surprisingly had FPV working, with the minimOSD sending down GPS data and battery voltage level. So I get to watch the battery voltage trickle down 1 mv at at time. (Welp, time to pop the kettlecorn and watch the 2S battery progressively deep-discharge and get more damaged by the minute!) It did, however, rise back up to 7.4V unloaded (telling me that the internal resistance must be pretty high, so I would not to too bothered too much to throw away the 2S battery entirely!)  Nor did I bother to watch it to see how low and how long it will take to discharge below the safe limit. I packed up all monitor and ground gear to get it out of the cold. So here it stands; stuck real high. I have tried climbing up 14-18 feet onto the tree, but it was still a good 12 feet up. I tried a rope to the trunk and shook the hell out of the tree. The limb that the quad was stuck on did not move much, and the tree was dampening the vibrations too much, even after hitting a resonance peak (technically a harmonic of the resonant frequency), where I could clearly see 2 "standing waves" in the trunk, but that got tiring real quick,and the winter sun has set and things were getting darker by the minute. I did not budge the quad.  I eventually resorted to shooting the limb with a 22 rifle, and on the 3rd shot, I got it to fall down!!! .......... 3 feet, that is, until it got stuck on an even LARGER branch, and now it is really stuck on it. It is on its side on a small fork in the tree, and it is snagged on that now. I can't shoot the base of the branch to break it, because it is like 4 inches in diameter, and on the forked branch right where it is caught, the quadcopter is sitting directly on! If I shoot it, there is a good chance of hitting the quadcopter and destroying the lipo battery causing it to catch fire, or hit electronics or the camera with the beautiful 1080p HD footage of the crash! Again, shaking the tree violently does not do much to budge it. Perhaps someone in the community has an idea on how to knock it down? 

Question by -max-   |  last reply


How to make Flip Clock Numbers and build a "like"-counter around it?

Hey All So I've got this client, who's absolutely crazy about the "FLIKE" (A physical like counter.). But he can't have it for another couple of months, and he'd like it to be a little more custom... Long story short, I might end up making a similar product in a few weeks. it will probably consist out of 5 digits and if it's up to me (not sure what the client wants) I'd stuff them behind a long picture frame. Something like this but actually mechanical and not just a picture of it:  http://www.notonthehighstreet.com/thedriftingbear/product/personalised-framed-vintage-flip-clock-print So I started googling every hardware piece I needed and it turns out it's a huge pain to find Flip Clock Numbers / Flip Board Numbers... whatever you want to call them. (What's the right name btw?) You can't just buy these things, let alone in a custom size. So the idea is to build them myself. I found this on wikipedia, which gives a clue about the inside: http://en.wikipedia.org/wiki/File:Analog_clock_with_digital_display.png So I'm figuring out what needs to go in it to make this work. (I'll end up making an instructable about it) The numbers themselves are going to be made out of vinyl stickers. You can easily buy those from ebay in about any size if you look for them. The stickers will be put on to plastic boards. But I'm not totally sure what kind I should get. They should be thin and must be able to stand up straight, yet "easy" to fold. I'll probably get them lasercut, but you should be able to cut them by hand as well. Currently I'm thinking about gluing small metal or carbon rods on the back of those letters. Although I'm not sure if that would be strong enough. Would it be enough to file one side of the rods to get a bigger contact surface? (What do you guys think?) I'm planning of putting the half letters in a drum of ABS or PLA. it should be shaped like this:  |--------| I'm thinking about 3D printing this. But no idea how it'll do... One side of the drum will be connected to a small stepper motor (5.625° with 1/64 reduction). I don't have real experience with stepper motors, but this resolution seems more than sufficient. The other side will be connected to a metal or plastic positioner. Each digit might end up with it's own "unit" so I can swap them separately if they'd break. I've got great experience with lasercut plexi, so I might use that because it's more accurate than wood and I might have some lying around. I was first thinking about 1 stepper motor and a set of gears. I decided not to do that in the end because I don't have good experience with making gears and I can never find the right sizes online. Also, it'll make everything way more complex. So each motor will have it's own controller connected to it. Those controllers would have to talk to an ATMega or something. (I'm planning on using an arduino to prototype, but then just swap the chip and make a stand-alone version without usb etc) The ATMega has to be connected to the internet of course to get the current number of likes, so I'd connect it to a raspberry pi via I²C. I'm not familiar with the GPIO pins on the pi so I figured this would be a save and convenient way to handle this. The ATMega is robust, and I love the Arduino bootloader. A sketch is written in no time, but I have no idea how to start writhing this code for the GPIO pins. So why the Raspberry Pi? First off, this thing might end up being wireless, and since a wifi module for the arduino costs as much as a Pi, I figured this would be easier. The plan is to make the pi run python script that could ask the number of likes from the facebook API. Once returned, it'll send +1 or +5 or +10 over I²C. The arduino shifts the numbers to the correct position and replies with the total number it's displaying (3012 for instance). The PI can then recheck if everything is in sync. As for the set up. Since we have Pi, we can put on a LAMP stack (I know, this is overkill, but it wouldn't hurt either). So for initial set-up, we'd connect the counter to ethernet, browse to it on a different computer via "http://counter.local". And we'd be presented with a web interface. You'll be able to set the URL of the page u want to get the likes from, set and reset the number that is displayed on the counter, and the WIFI settings. The WIFI settings can be saved in the wpa_supplicant.conf file and on reboot it'll automatically connect to this network. From now on the whole system is manageable over wifi via a html interface. For debugging I might enable ssh though. So I guess you've got the whole outline now. I'd like to get your feedback on this! And this for the mechanics, electronics, and software side of things! 

Question by woutervddn   |  last reply


Help for realising a linefollower tankbot

Hello, I want to realize a linefollowing tank bot. I got this following parts: - Arduino Mega 2560 - Arduino MotorShield Rev03 - Pololu QTR-8RC Array - Pololu RP5 Tankchassis (6V DC Motors) Now all parts are together and the code must be completed. Therefore I found a really nice PID-based tutorial for linefollower: http://letsmakerobots.com/blog/enigmerald/pid-tutorials-line-following I create a program, but after calibrating the sensors, the bot doesn't drive on the line. It makes no sense were it drives. Most time it do 90° turns and so on. Do you find a better solution for my code? [code] #include #include   /////////////////////////// // define constants   // /////////////////////////// #define AUTO_CALIB  false      // Autokalibrierung aktivieren #define DEBUG_ENABLE   true               // false=keine Serial Ausgaben #define NUM_SENSORS    8                  // Anzahl der verwendeten Sensoren #define TIMEOUT        2500               // waits for 2500 microseconds for sensor outputs to go low #define EMITTER_PIN    QTR_NO_EMITTER_PIN         // Default: kein Emitterpin definiert #define MOTOR_SPEED    100               // PWM Signal 0-255 (Basismotorgeschwindigkeit) #define MOTOR_MAX_SPEED 255       // PWM Signal für Maximalgeschwindigkeit #define KP     0.2                    // KP-Wert für PID Regler #define KD     5                     // KD-Wert für PID Regler ( Beachte: Kp < Kd) #define SERVO_PIN1  11       // PWM Ausgang für Servo1 #define SERVO_PIN2  12       // PWM Ausgang für Servo2 #define CALIB_LED   13       // LED Ausgang für Kalibrierungsphase ////////////////////////// // define variables     // ////////////////////////// // Zuweisung der Sensoren 0-7 an die digitalen IO's 22-29 QTRSensorsRC qtrrc((unsigned char[]) {22, 23, 24, 25, 26, 27, 28, 29}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); unsigned int sensorValues[NUM_SENSORS]; int MotorLeftSpeed=3;                  // PWM pin for speed control left int MotorRightSpeed=11;                // PWM pin for speed control right int MotorLeftDirection=12;            // digital pin for direction control left int MotorRightDirection=13;            // digital pin for direction control right int MotorLeftBrake=9;                  // digital pin for brake control left int MotorRightBrake=8;                 // digital pin for brake control right int lastError = 0; ///////////////////// // Initialisierung // ///////////////////// void setup() {     // Initialisierung verschiedner IOs   pinMode(CALIB_LED, OUTPUT);    // Definiert LED Ausgang für Kalibierungsphase       // Initialisierung linker Motor   pinMode(MotorLeftDirection, OUTPUT);      // Definiert Ausgang für den linken Motor   pinMode(MotorLeftBrake, OUTPUT);          // Definiert Bremse für den linken Motor   pinMode(MotorLeftSpeed, OUTPUT);   // Definiert Geschwindigkeitsausgang für linken Motor   // Initialisierung rechter Motor   pinMode(MotorRightDirection, OUTPUT);     // Definiert Ausgang für den rechten Motor   pinMode(MotorRightBrake, OUTPUT);         // Definiert Bremse für den rechten Motor     // Initialisierung Servo Motoren   servo1.attach(SERVO_PIN1);     // Zuweisung PWM PIN für Servo1   servo2.attach(SERVO_PIN2);     // Zuweisung PWM PIN für Servo2   if (DEBUG_ENABLE)   {    Serial.begin(9600);    Serial.print("Debug Modus aktiviert:\n");     }     delay(500);     digitalWrite(CALIB_LED, HIGH);    // turn on Arduino's LED to indicate we are in calibration mode   for (int i = 0; i < 400; i++)   // make the calibration take about 10 seconds   {     qtrrc.calibrate();           // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call)   } delay(20);      // The 20 ms delay in the calibration code is intended to make the routine take a reasonable amount of time.     digitalWrite(CALIB_LED, LOW);     // turn off Arduino's LED to indicate we are through with calibration       if (DEBUG_ENABLE)    {    // print the calibration minimum values measured when emitters were on       for (int i = 0; i < NUM_SENSORS; i++)    {   Serial.print(qtrrc.calibratedMinimumOn[i]);   Serial.print(' ');    }    Serial.println();       // print the calibration maximum values measured when emitters were on    for (int i = 0; i < NUM_SENSORS; i++)    {   Serial.print(qtrrc.calibratedMaximumOn[i]);   Serial.print(' ');    }    Serial.println();    Serial.println();   }   delay(1000);   } /////////////////// // Main Program  // /////////////////// void loop() {   // read calibrated sensor values and obtain a measure of the line position from 0 to 5000 // To get raw sensor values, call: // qtrrc.read(sensorValues); instead of unsigned int position = qtrrc.readLine(sensorValues); // Variable positon zeigt die genaue Position (0-7000) an   unsigned int position = qtrrc.readLine(sensorValues); // get calibrated readings along with the line position, refer to the QTR Sensors Arduino Library for more details on line position. int error = position - 3500;  // 3500 is the desired position   if (DEBUG_ENABLE)   {    // print the sensor values as numbers from 0 to 1000, where 0 means maximum reflectance and    // 1000 means minimum reflectance, followed by the line position    for (unsigned char i = 0; i < NUM_SENSORS; i++)    {     Serial.print(sensorValues[i]);     Serial.print('\t');    }    Serial.print(position);    // comment this line out if you are using raw values   } int motorSpeed = KP * error + KD * (error - lastError); lastError = error; int rightMotorSpeed = MOTOR_SPEED + motorSpeed; int leftMotorSpeed  = MOTOR_SPEED - motorSpeed;     if (rightMotorSpeed > MOTOR_MAX_SPEED ) rightMotorSpeed = MOTOR_MAX_SPEED;    // Verhindert dass die Maximalgeschwindigkeit überschritten wird if (leftMotorSpeed > MOTOR_MAX_SPEED ) leftMotorSpeed  = MOTOR_MAX_SPEED;    // Verhindert dass die Maximalgeschwindigkeit überschritten wird if (rightMotorSpeed < 0) rightMotorSpeed  = 0;          // Verhindert einen negativen Geschwindigkeitswert if (leftMotorSpeed < 0) leftMotorSpeed   = 0;          // Verhindert einen negativen Geschwindigkeitswert   {   // Ansteuerung der Motoren durch PID Berechnung   digitalWrite(MotorRightBrake, LOW);     // Motorbremse rechts deaktivieren   digitalWrite(MotorLeftBrake, LOW);     // Motorbremse links deaktivieren   digitalWrite(MotorRightDirection, HIGH);   // Motor rechts im Uhrzeigersinn  --> fährt vorwärts   digitalWrite(MotorLeftDirection, LOW);    // Motor links gegen den Uhrzeigersinn  --> fährt vorwärts   analogWrite(MotorRightSpeed, rightMotorSpeed);  // Motorgeschwindigkeit rechts in Abhängigkeit des PID Reglers   analogWrite(MotorLeftSpeed, leftMotorSpeed);  // Motorgeschwindigkeit links in Abhängigkeit des PID Reglers }           } [/code]

Topic by julianpe   |  last reply


Problem in arduino code... you'll have to run this one to understand - Word Clock? Answered

I have been writing this code for the Word clock. I am trying to customize the code to fit into an atmega8, and use DS1307 RTC. Both of these is fine, but what is wrong is that when I upload my code and try to set the time by using the buttons, the time is not setting properly. I can increment minutes with the minutes button to 16, but not further. Hours works fine, but if, lets say the time is 6:36 on the arduino, then If I press the hour button, I find that time changes to 7:31. Five minutes less than what I expected. What am I overlooking here?  I advise to run the code and understand the problem. On the other hand Binary sketch size: 7164 bytes (of a 7168 byte maximum), this is just 4 bytes short of max. Can that be a part of the problem Code: #include // Display output pin assignments #define MTEN  Display1=Display1 | (1<<0)  #define HALF Display1=Display1 | (1<<1) #define QUARTER Display1=Display1 | (1<<2) #define TWENTY Display1=Display1 | (1<<3) #define MFIVE Display1=Display1 | (1<<4) #define MINUTES Display1=Display1 | (1<<5) #define PAST Display1=Display1 | (1<<6) #define UNUSED1 Display1=Display1 | (1<<7) #define TO Display2=Display2 | (1<<0) #define ONE Display2=Display2 | (1<<1) #define TWO Display2=Display2 | (1<<2) #define THREE Display2=Display2 | (1<<3) #define FOUR Display2=Display2 | (1<<4) #define HFIVE Display2=Display2 | (1<<5) #define SIX Display2=Display2 | (1<<6) #define UNUSED2 Display2=Display2 | (1<<7) #define SEVEN Display3=Display3 | (1<<0) #define EIGHT Display3=Display3 | (1<<1) #define NINE Display3=Display3 | (1<<2) #define HTEN Display3=Display3 | (1<<3) #define ELEVEN Display3=Display3 | (1<<4) #define TWELVE Display3=Display3 | (1<<5) #define OCLOCK  Display3=Display3 | (1<<6) #define UNUSED3 Display3=Display3 | (1<<7) #define DS1307_I2C_ADDRESS 0x68  // This is the I2C address #if defined(ARDUINO) && ARDUINO >= 100   // Arduino v1.0 and newer   #define I2C_WRITE Wire.write   #define I2C_READ Wire.read #else                                   // Arduino Prior to v1.0   #define I2C_WRITE Wire.send   #define I2C_READ Wire.receive #endif int  hr=12, mn=00, scnd=0; static unsigned long msTick =0;  // the number of Millisecond Ticks since we last                                  // incremented the second counter int  count; boolean selftestmode; boolean  DS1307Present=false;       // flag to indicate that the 1307 is there..    1 = present char Display1=0, Display2=0, Display3=0; // hardware constants static unsigned int LEDClockPin=5;    //11 d5 ok static unsigned int LEDDataPin=3;    //5 d3 static unsigned int LEDStrobePin=4;   //6 d4 static unsigned int MinuteButtonPin=6;  //d6 12 static unsigned int HourButtonPin=7;    //d7 13 static unsigned int PWMPin = 11; char buf[50]; // time output string for debugging byte decToBcd(byte b) {  return ( ((b/10) << 4) + (b%10) );} // Convert binary coded decimal to normal decimal numbers byte bcdToDec(byte b) {  return ( ((b >> 4)*10) + (b%16) );} void getTime() {   //read from chip and store in hr, mn, scnd   Wire.beginTransmission(DS1307_I2C_ADDRESS);   I2C_WRITE((uint8_t) 0x00);   Wire.endTransmission();     Wire.requestFrom(DS1307_I2C_ADDRESS, 3);   scnd = bcdToDec(I2C_READ());   mn =  bcdToDec(I2C_READ());   hr =  bcdToDec(I2C_READ()); } void setTime() {   //to be paranoid, we're going to first stop the clock   //to ensure we don't have rollovers while we're   //writing:   writeRTCreg(0,0x80);   //now, we'll write everything *except* the second   Wire.beginTransmission(DS1307_I2C_ADDRESS);   I2C_WRITE((uint8_t) 0x01);   I2C_WRITE(mn);   I2C_WRITE(hr);   Wire.endTransmission();   //now, we'll write the seconds; we didn't have to keep   //track of whether the clock was already running, because   //scnd already knows what we want it to be. This   //will restart the clock as it writes the new seconds value.   writeRTCreg(0,scnd); } byte readRTCreg(byte adr) {    if(adr > 0x3F) { return 0xff; }   Wire.beginTransmission(DS1307_I2C_ADDRESS);   I2C_WRITE(adr);   Wire.endTransmission();   Wire.requestFrom(DS1307_I2C_ADDRESS, 1);   return I2C_READ(); } void writeRTCreg(byte adr, byte val) { if(adr > 0x3F) { return; }    Wire.beginTransmission(DS1307_I2C_ADDRESS);    I2C_WRITE(adr);    I2C_WRITE(val);    Wire.endTransmission(); } void print_DS1307time() {   /* Format the time and date and insert into the temporary buffer */   snprintf(buf, sizeof(buf), "RTC time: %02d:%02d:%02d",   hr, mn, scnd);   /* Print the formatted string to serial so we can see the time */   Serial.println(buf); } void setup() {   // initialise the hardware   // initialize the appropriate pins as outputs:   pinMode(LEDClockPin, OUTPUT);   pinMode(LEDDataPin, OUTPUT);   pinMode(LEDStrobePin, OUTPUT);       //pinMode(BrightnessPin, INPUT);   pinMode(MinuteButtonPin, INPUT);   pinMode(HourButtonPin, INPUT);   digitalWrite(MinuteButtonPin, HIGH);  //set internal pullup   digitalWrite(HourButtonPin, HIGH); //set internal pullup   pinMode(PWMPin, OUTPUT);     Serial.begin(9600);   Wire.begin();    // test whether the DS1302 is there   Serial.print("Verifying DS1307 ");   // start by verifying that the chip has a valid signature   if (readRTCreg(0x20) == 0x55) {     // Signature is there - set the present flag and mmove on     DS1307Present=true;     Serial.println("Valid Signature");   }   else   {     // Signature isnt there - may be a new chip -     //   do a write to see if it will hold the signature     writeRTCreg(0x20,0x55);     if (readRTCreg(0x20) == 0x55) {       // We can store data - assume that it is a new chip that needs initialisation /*      // Start by clearing the clock halt flag.           //"Bit 7 of register 0 is the clock halt (CH) bit.           //When this bit is set to a 1, the oscillator is disabled."             byte _reg0_sec = decToBcd(scnd);             _reg0_sec = _reg0_sec & ~0x80;             writeRTCreg(0,_reg0_sec); */       // Set the time and date on the chip       scnd = 0;       mn = 0;       hr = 12;       setTime();       // set the DS1302 present flag       DS1307Present=true;       Serial.println("present - new chip initialised.");     }     else  Serial.println("absent");   }    msTick=millis();      // Initialise the msTick counter     selftest();   selftestmode=false;   if (DS1307Present) {     // Get the current time and date from the chip    getTime();     }     displaytime();        // display the current time } void ledsoff(void) { Display1=0; Display2=0; Display3=0; } void WriteLEDs(void) { // Now we write the actual values to the hardware shiftOut(LEDDataPin, LEDClockPin, MSBFIRST, Display3); shiftOut(LEDDataPin, LEDClockPin, MSBFIRST, Display2); shiftOut(LEDDataPin, LEDClockPin, MSBFIRST, Display1); digitalWrite(LEDStrobePin,HIGH); delay(2); digitalWrite(LEDStrobePin,LOW); } void selftest(void){   Serial.print("TEST");   analogWrite(PWMPin, 255);     ledsoff(); MTEN; WriteLEDs(); delay(500);   ledsoff(); HALF; WriteLEDs(); delay(500);   ledsoff(); QUARTER; WriteLEDs(); delay(500);   ledsoff(); TWENTY; WriteLEDs(); delay(500);   ledsoff(); MFIVE; WriteLEDs(); delay(500);   ledsoff(); MINUTES; WriteLEDs(); delay(500);   ledsoff(); PAST; WriteLEDs(); delay(500);   ledsoff(); TO; WriteLEDs(); delay(500);   ledsoff(); ONE; WriteLEDs(); delay(500);   ledsoff(); TWO; WriteLEDs(); delay(500);   ledsoff(); THREE; WriteLEDs(); delay(500);   ledsoff(); FOUR; WriteLEDs(); delay(500);   ledsoff(); HFIVE; WriteLEDs(); delay(500);   ledsoff(); SIX; WriteLEDs(); delay(500);   ledsoff(); SEVEN; WriteLEDs(); delay(500);   ledsoff(); EIGHT; WriteLEDs(); delay(500);   ledsoff(); NINE; WriteLEDs(); delay(500);   ledsoff(); HTEN; WriteLEDs(); delay(500);   ledsoff(); ELEVEN; WriteLEDs(); delay(500);   ledsoff(); TWELVE; WriteLEDs(); delay(500);   ledsoff(); OCLOCK; WriteLEDs(); delay(500); } void displaytime(void){   // start by clearing the display to a known state   ledsoff();     Serial.print("It is ");   // now we display the appropriate minute counter   if ((mn>4) && (mn<10)) {     MFIVE;     MINUTES;     Serial.print("Five Minutes ");   }   if ((mn>9) && (mn<15)) {     MTEN;     MINUTES;     Serial.print("Ten Minutes ");   }   if ((mn>14) && (mn<20)) {     QUARTER;       Serial.print("Quarter ");   }   if ((mn>19) && (mn<25)) {     TWENTY;     MINUTES;     Serial.print("Twenty Minutes ");   }   if ((mn>24) && (mn<30)) {     TWENTY;     MFIVE;     MINUTES;     Serial.print("Twenty Five Minutes ");   }    if ((mn>29) && (mn<35)) {     HALF;     Serial.print("Half ");   }   if ((mn>34) && (mn<40)) {     TWENTY;     MFIVE;     MINUTES;     Serial.print("Twenty Five Minutes ");   }    if ((mn>39) && (mn<45)) {     TWENTY;     MINUTES;     Serial.print("Twenty Minutes ");   }   if ((mn>44) && (mn<50)) {     QUARTER;     Serial.print("Quarter ");   }   if ((mn>49) && (mn<55)) {     MTEN;     MINUTES;     Serial.print("Ten Minutes ");   }   if (mn>54) {     MFIVE;     MINUTES;     Serial.print("Five Minutes ");   }   if ((mn <5))   {     switch (hr) {     case 1:       ONE;       Serial.print("One ");       break;     case 2:       TWO;       Serial.print("Two ");       break;     case 3:       THREE;       Serial.print("Three ");       break;     case 4:       FOUR;       Serial.print("Four ");       break;     case 5:       HFIVE;       Serial.print("Five ");       break;     case 6:       SIX;       Serial.print("Six ");       break;     case 7:       SEVEN;       Serial.print("Seven ");       break;     case 8:       EIGHT;       Serial.print("Eight ");       break;     case 9:       NINE;       Serial.print("Nine ");       break;     case 10:       HTEN;       Serial.print("Ten ");       break;     case 11:       ELEVEN;       Serial.print("Eleven ");       break;     case 12:       TWELVE;       Serial.print("Twelve ");       break;     }   OCLOCK;   Serial.println("O'Clock");   }   else     if ((mn < 35) && (mn >4))     {       PAST;       Serial.print("Past ");       switch (hr) {     case 1:       ONE;       Serial.println("One ");       break;     case 2:       TWO;       Serial.println("Two ");       break;     case 3:       THREE;       Serial.println("Three ");       break;     case 4:       FOUR;       Serial.println("Four ");       break;     case 5:       HFIVE;       Serial.println("Five ");       break;     case 6:       SIX;       Serial.println("Six ");       break;     case 7:       SEVEN;       Serial.println("Seven ");       break;     case 8:       EIGHT;       Serial.println("Eight ");       break;     case 9:       NINE;       Serial.println("Nine ");       break;     case 10:       HTEN;       Serial.println("Ten ");       break;     case 11:       ELEVEN;       Serial.println("Eleven ");       break;     case 12:       TWELVE;       Serial.println("Twelve ");       break;       }     }     else     {       // if we are greater than 34 minutes past the hour then display       // the next hour, as we will be displaying a 'to' sign       TO;       Serial.print("To ");       switch (hr) {       case 1:         TWO;        Serial.println("Two ");        break;       case 2:         THREE;       Serial.println("Three ");         break;       case 3:         FOUR;       Serial.println("Four ");         break;       case 4:         HFIVE;       Serial.println("Five ");         break;       case 5:         SIX;       Serial.println("Six ");         break;       case 6:         SEVEN;       Serial.println("Seven ");         break;       case 7:         EIGHT;       Serial.println("Eight ");         break;       case 8:         NINE;       Serial.println("Nine ");         break;       case 9:         HTEN;       Serial.println("Ten ");         break;       case 10:         ELEVEN;       Serial.println("Eleven ");         break;       case 11:         TWELVE;       Serial.println("Twelve ");         break;       case 12:         ONE;       Serial.println("One ");         break;       }     }    WriteLEDs();    } void incrementtime(void){   // increment the time counters keeping care to rollover as required   scnd=0;   if (++mn >= 60) {     mn=0;     if (++hr == 13) {       hr=1;      }   }    // debug outputs   Serial.println(); //  if (DS1307Present) //  print_DS1307time(); //  else{ //  Serial.print("Arduino Time: " );   Serial.print(hr);   Serial.print(":");   Serial.print(mn);   Serial.print(":");   Serial.println(scnd); //  } } void loop(void) {     //selftest(); int aread = sq(analogRead(3)/4)+3;   //Uncomment the following line and comment the next one in order to   //  enable dimming via a potentiometer connected to pin 0:   analogWrite(PWMPin, aread>255 ? 255:aread);   //analogWrite(PWMPin, 255);       // heart of the timer - keep looking at the millisecond timer on the Arduino     // and increment the seconds counter every 1000 ms     if ( millis() - msTick >999) {         msTick=millis();         scnd++; /*        // Flash the onboard Pin13 Led so we know something is hapening!         digitalWrite(13,HIGH);         delay(100);         digitalWrite(13,LOW);    */    }                 //test to see if we need to increment the time counters     if (scnd==60)     {       incrementtime();       displaytime();     } if (DS1307Present) {     // Get the current time and date from the chip      getTime();     }     // test to see if a forward button is being held down     // for time setting     if ( (digitalRead(MinuteButtonPin) ==0 ) && scnd!=1)       // the forward button is down       // and it has been more than one second since we       // last looked     {       mn=(((mn/5)*5) +5);       scnd=0;       incrementtime();       scnd++;  // Increment the second counter to ensure that the name       // flash doesnt happen when setting time       if (DS1307Present) {       // Set the time on the chip       setTime();     }     delay(100);       displaytime();     }     // test to see if the back button is being held down     // for time setting     if ((digitalRead(HourButtonPin)==0 ) && scnd!=1)     {       /*       minute=(((minute/5)*5) -5);       second=0; // decrement the minute counter       if (minute<0) {         minute=55;         if (--hour <0) hour=12;       }       */             mn = (mn/5)*5;  //round minute down to previous 5 min interval       if (++hr == 13) {         hr=1;        }       incrementtime();       scnd++;  // Increment the second counter to ensure that the name       // flash doesnt happen when setting time        if (DS1307Present) {       // Set the time and date on the chip       setTime();     }     delay(100);       displaytime();     } }

Question by pro2xy   |  last reply


The future of mobile operating system or the end for "hackers" and rooting?

For mayn years it was almost logical to get full root access on your new smartphone or tablet.The other fraction might now it as "jailbreaking"...No one really needs it unless they are not happy with they way the mnufacturer designed the operating system and features.The removal of bloat, apps the user never needs, is still the most common reason for rooting.Custom ROM's offering a different experience are right behind.Now we also have TV's, entertainment boxes of all kinds, even from our ISP's directly.The main provider for the operating system is now Google with only a few "competitors" left.Apple has a strong hold of the mobile and tablet sector too but is not really presented in other areas.Android is still open source but Google heavily modifed it to suit the needs of data collecting and security for features like banking, access control and so on.What is good for the normal user and perfect for those with security in mind can be really bad for those actually just using a device.No matter why you buy a new phone from your provider, you almost never buy it for the added apps and services.Rooting has become more and more difficult.One reason of course is constant security updates and removing possible access options for even simple things like getting USB debugging and an unlocked bootloader.People dedicated to find ways to remove provider locks, creating custom firmwares or the basic tools required to work with firmwares were called hackers.If you buy a new car and decide to modify it with a new engine, seats or whatever than no one will stop you.So why don't we have the same rights for our electronic companions?I wouldn't call it hacking, I would call it actually owning and controlling your device instead of Google letting control you - or Apple, but who cares....The other reason is dead simple: Those guys who started it all have retired or found employoment with those they fooled for so many years.Chainfire should ring a bell for anyone ever concerned with rooting.The master is gone now and only a few people are willing to take his legacy.For Asian devices the community over there is better off but for our market region right now Magisk seems to be the only option left for modern devices.The sneaky ways to lock us out....Security comes at a price, simple as.You can offer secrity for money transfers if the device is not trustworthy.Same for online streaming - you want the money for what you give and prevent that someone is able to make unwanted recordings without encryption.The list goes on with access control system and literally everything we use our devices for that involves some security.Even with the lates PIE systems Google's own devices are still quite friendly in terms of gaining root access.Different story though if a manufacturer makes full use of all the latest addition at Google's disposal.Device security no longer starts with the boot we see.It is now possible to create a hardware based tree of trust.This means any modification to anything will cause a failure.This locks out all "tools" able to read out partitions and vital data while a device is in fastboot mode.And of course said fastboot can be fully disabled as well now.For security reason a so called A/B configuration is used.Updates come over the air and are applied to the dormant system.Next start will boot the new system and then update the old one, no requirement to manually apply and update.The recovery can also be abandoned and replaced by a system using a copy on the device itself that is updated through OTA updates with the firmware.So both ways to gain official access can be full removed from the user.From there we get encryption, hash checks and literally everything working in its own user space - a full SELinux enviroment at the highest level.There are already devices utilising a lot of this and so far the only way to get any sort of insight was done by those intercepting OTA updates on a router level.And apart from quickly changing the encryption with the next updates nothing was gained.Is it all coincidence?Of course not.Well known leaks were kept open for years.Kernel updates gave improvements and closed really old leaks but never all known ways.With the retirement of the best rooting experts these holes were suddenly closed.Checks of latest kernel releases showed that there is no known vulenerabilities anymore that can be misused to gain access.And those finding new ones and making them available for us are bascally gone now.Encryptions and packing algorithms changed, same thing for the actual handling of partitions and rights.Anyone with a decent understanding of how the old ways worked will be able to figure it out with some time wasted on it.From there however the outcome is often dark.The tools needed to work with these new files are not always updated anymore.The developer simply moved on and most of the time without publishing his source codes.And the still best way to protect your firmware from tampering is to encrypt it.In the old days it was enough to sign a ZIP file with a release key not available to the public.Custom recoveries allowed us to get around this.This still works to some extent but now we also get additional checks starting from the bootloader.A modified system will be detected and stopped and a stock system will stop i a modified boot is detected.Even using a custom recovery by flashing or through fastboot is preventable now.Right now the only way for most new devices is a total wipe and the installation of an unsecure firmware with everything.As you already guessed this is to prevent now as well.So does all this rooting stuff actually concern you?Of course not!If you never had any need for rooting or no clue what to do differently with a rooted device than you are a happy camper.But your neighbour or friend might think differently.You see, I have two problems when it comes to "stock" devices.a) I have no clue what data they collect from me and what it might be used for.b) I do not like being forced to agree to terms that are endless and of questionable content just to use the damn thing.For crying out loud: In most cases it is now impossible to even set up a new device without working internet and a Google account.....

Topic by Downunder35m 


I need help for my electric imp/arduino project....

Hey, I have been working on a project centered around what chris nafis has already done with the grove dust sensor. So far, I have managed to get the dust sensor hooked up to an arduino and I have been getting it to display data, but that's about it. My next step was to get an elecrric im on sparkfun's imp shield to read serial data from the arduino in the form of numbers and then output it to COSM. However, for some reason, this does not seem to want to work on the leval of the imp. I followed most of jimb0's instructions on sparkfun for imps and arduino, but this does not seem to work. I have an arduino leonardo outputting serial data with serial1 at 19200 through pins 1 and 0 to the shield, which it then supposed to connect an imp running a program to patch this to a cosm node. I know nothing about squirrel, just using this code to do things: // Transmit data between UART and Input/OutputPorts on the impee // by: Jim Lindblom //     SparkFun Electronics // date: September 26, 2012 // license: BeerWare //          Please use, reuse, and modify this code as you need. //          We hope it saves you some time, or helps you learn something! //          If you find it handy, and we meet some day, you can buy me a beer or iced tea in return. local rxLEDToggle = 1;  // These variables keep track of rx/tx LED toggling status local txLEDToggle = 1; // impeeIn will override the InputPort class. // Whenever data is received to the impee, we'll jump into the set(c) function defined within class impeeIn extends InputPort {     name = "UART Out";     type = "number";         // This function takes whatever character was sent to the impee     // and sends it out over the UART5/7. We'll also toggle the txLed     function set(c)     {         hardware.uart57.write(c);         toggleRxLED();     } } local impeeInput = impeeIn();  // assign impeeIn class to the impeeInput local impeeOutput = OutputPort("UART In", "number");  // set impeeOutput as a string function initUart() {     hardware.configure(UART_57);    // Using UART on pins 5 and 7     hardware.uart57.configure(19200, 8, PARITY_NONE, 1, NO_CTSRTS); // 19200 baud worked well, no parity, 1 stop bit, 8 data bits } function initLEDs() {     // LEDs are on pins 8 and 9 on the imp Shield     // They're both active low, so writing the pin a 1 will turn the LED off     hardware.pin8.configure(DIGITAL_OUT_OD_PULLUP);     hardware.pin9.configure(DIGITAL_OUT_OD_PULLUP);     hardware.pin8.write(1);     hardware.pin9.write(1); } // This function turns an LED on/off quickly on pin 9. // It first turns the LED on, then calls itself again in 50ms to turn the LED off function toggleTxLED() {     txLEDToggle = txLEDToggle?0:1;    // toggle the txLEDtoggle variable     if (!txLEDToggle)     {         imp.wakeup(0.05, toggleTxLED.bindenv(this)); // if we're turning the LED on, set a timer to call this function again (to turn the LED off)     }     hardware.pin9.write(txLEDToggle);  // TX LED is on pin 8 (active-low) } // This function turns an LED on/off quickly on pin 8. // It first turns the LED on, then calls itself again in 50ms to turn the LED off function toggleRxLED() {     rxLEDToggle = rxLEDToggle?0:1;    // toggle the rxLEDtoggle variable     if (!rxLEDToggle)     {         imp.wakeup(0.05, toggleRxLED.bindenv(this)); // if we're turning the LED on, set a timer to call this function again (to turn the LED off)     }     hardware.pin8.write(rxLEDToggle);   // RX LED is on pin 8 (active-low) } // This is our UART polling function. We'll call it once at the beginning of the program, // then it calls itself every 10us. If there is data in the UART57 buffer, this will read // as much of it as it can, and send it out of the impee's outputPort. function pollUart() {     imp.wakeup(0.00001, pollUart.bindenv(this));    // schedule the next poll in 10us         local byte = hardware.uart57.read();    // read the UART buffer     // This will return -1 if there is no data to be read.     while (byte != -1)  // otherwise, we keep reading until there is no data to be read.     {         //  server.log(format("%c", byte)); // send the character out to the server log. Optional, great for debugging         impeeOutput.set(byte);  // send the valid character out the impee's outputPort         byte = hardware.uart57.read();  // read from the UART buffer again (not sure if it's a valid character yet)         toggleTxLED();  // Toggle the TX LED     } } // This is where our program actually starts! Previous stuff was all function and variable declaration. // This'll configure our impee. It's name is "UartCrossAir", and it has both an input and output to be connected: imp.configure("UartCrossAir", [impeeInput], [impeeOutput]); initUart(); // Initialize the UART, called just once initLEDs(); // Initialize the LEDs, called just once pollUart(); // start the UART polling, this function continues to call itself // From here, two main functions are at play: //      1. We'll be calling pollUart every 10us. If data is sent from the UART, we'll send out out of the impee. //      2. If data is sent into the impee, we'll jump into the set function in the InputPort. // // The end It's not mine, but I modified it slightly t work with numbers instead of strings. I an then using this arduino code on a leonardo: ;int pin = 10; unsigned long final; unsigned long duration; unsigned long starttime; unsigned long sampletime_ms = 30000; unsigned long lowpulseoccupancy = 0; float ratio = 0; float concentration = 0; void setup() {   Serial1.begin(19200);    while (!Serial) {     ;    }   pinMode(10,INPUT);   starttime = millis(); } void loop() {   duration = pulseIn(pin, LOW);   lowpulseoccupancy = lowpulseoccupancy+duration;   if ((millis()-starttime) > sampletime_ms)   {     ratio = lowpulseoccupancy/(sampletime_ms*10.0);  // Integer percentage 0=>100     concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve     final = concentration*35     ;Serial.println(concentration);     lowpulseoccupancy = 0;     starttime = millis();   } };int pin = 10; unsigned long final; unsigned long duration; unsigned long starttime; unsigned long sampletime_ms = 30000; unsigned long lowpulseoccupancy = 0; float ratio = 0; float concentration = 0; void setup() {   Serial1.begin(19200);    while (!Serial) {     ;    }   pinMode(10,INPUT);   starttime = millis(); } void loop() {   duration = pulseIn(pin, LOW);   lowpulseoccupancy = lowpulseoccupancy+duration;   if ((millis()-starttime) > sampletime_ms)   {     ratio = lowpulseoccupancy/(sampletime_ms*10.0);  // Integer percentage 0=>100     concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve     final = concentration*35     ;Serial.println(concentration);     lowpulseoccupancy = 0;     starttime = millis();   } } I would really like some help, as this is my science fair project and I am the only person that I know that knows about Imp, and sadly we don't have any hackerspaces around where I live in alaska.

Topic by qquuiinn   |  last reply


Help With Arduino Robot Arm Record & Playback With SD Card, Bluetooth

Hi, I need some help please with the following code - lots of errors occur when I try to verify it. The author is unavailable for help & the code appears to be in the public domain. Check out the clip, it looks awesome! https://www.youtube.com/watch?time_continue=1&v;=7A1WL60wMe0 https://github.com/Dileepmeom/Arduino-Robotic-Arm- //# Arduino-Robotic-Arm---Copt-Cat //This project controls the Cartesian robotic arm using Arduino, Motion sequence can be recorded and played back just like //Industrial robot does /* COPY CAT Servo controlled Robot 5-axis Cartesian robot This software logs the angular movement of joints by reading the servo angles and stores it in the SD card, reproduces the movement by the reading back from the SD card. The circuit: analog sensors on analog ins 0, 1, and 2 SD card attached to SPI bus as follows: ** MOSI - pin 11 ** MISO - pin 12 ** CLK - pin 13 ** CS - pin 4 created 24 Nov 2010 modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. */ include include define TRUE 1 define FALSE 0 // On the Ethernet Shield, CS is pin 4. Note that even if it's not // used as the CS pin, the hardware CS pin (10 on most Arduino boards // 53 on the Mega) must be left as an output or the SD library // functions will not work. const int chipSelect = 4; // constants won't change. They're used here to // set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin const int servo3 = 5, servo4 = 6,servo5 = 5; // PWM for servo 3 // variables will change: int buttonState = 0; // variable for reading the pushbutton status int recievedchar = 0,dataON=0; int SDdata = 0; Servo myservo1; // create servo object to control a servo Servo myservo2; // create servo object to control a servo Servo myservo3; // create servo object to control a servo Servo myservo4; // create servo object to control a servo Servo myservo5; // create servo object to control a servo int servo1angle = 0,servo2angle = 0; unsigned long current_servo_micros, prev_servo_micros; unsigned long currentMillis,previousMillis = 0; int scheduler = 0; int servointerval = 20; int S3_microlocal; char servoON=0; void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } pinMode(buttonPin, INPUT_PULLUP); Serial.print("Initializing SD card..."); // make sure that the default chip select pin is set to // output, even if you don't use it: pinMode(10, OUTPUT); // see if the card is present and can be initialized: if (!SD.begin(chipSelect)) { Serial.println("Card failed, or not present"); // don't do anything more: return; } Serial.println("card initialized."); } void loop() { long servo3ticks = 1000, servo4ticks = 1000, servo5ticks = 1000; // interval for servo cyle time / / read the state of the pushbutton value: buttonState = digitalRead(buttonPin); recievedchar = Serial.read(); // make a string for assembling the data to log: String dataString = ""; String arraystring = ""; String SDstring = ""; char firstseperator=0; unsigned long sensorarray[10]; int servoangle[5]; char arrayindex = 0; // open the file. note that only one file can be open at a time, // so you have to close this one before opening another. if(dataON == TRUE) { // read three sensors and append to the string: for (int analogPin = 0; analogPin < 5; analogPin++) { int sensor = analogRead(analogPin); sensorarray[analogPin] = sensor; dataString += String(sensor); if (analogPin < 4) { dataString += ","; } } File dataFile1 = SD.open("datalog.txt", FILE_WRITE); // if the file is available, write to it: if (dataFile1) { if(buttonState == HIGH) { // print to the serial port too: // Serial.println(dataString); /////////////////////////// debug code ///////////////////// for (arrayindex= 0; arrayindex < 5; arrayindex++) { int arrayvalue = sensorarray[arrayindex]; //arraystring += String(arrayvalue); } servo1angle = map(sensorarray[0], 102, 433, 0, 170); arraystring += servo1angle; arraystring += ","; servo2angle = map(sensorarray[1], 84, 468, 0, 180); arraystring += servo2angle; arraystring += ","; servo3ticks = map(sensorarray[2], 90, 393, 0, 150); arraystring += servo3ticks; arraystring += ","; servo4ticks = map(sensorarray[3], 107, 445,0, 180); arraystring += servo4ticks; arraystring += ","; servo5ticks = map(sensorarray[4], 151, 406, 10, 140); arraystring += servo5ticks; arraystring += ","; // Serial.println(arraystring); //// WRITE TO SD CARD // dataFile1.println(arraystring); dataFile1.close(); ///////////////////////////////////////////////////////////////// delay(10); } else { dataFile1.close(); // print to the serial port too: Serial.println("No signal for writing"); } } // if the file isn't open, pop up an error: else { Serial.println("error opening datalog.txt"); } } // the reading's most significant digit is at position 15 in the reportString: ////// switch case starts ///////////////////////// switch (recievedchar) { case 'D': { dataON = TRUE; Serial.print("Recording"); Serial.print("\n"); myservo1.detach(); myservo2.detach(); myservo3.detach(); myservo4.detach(); myservo5.detach(); break; } case 'S': { dataON = FALSE; Serial.print("Stopped"); Serial.print("\n"); break; } case 'R': { myservo1.attach(5); // attaches the servo on pin 9 to the servo object myservo2.attach(3); // attaches the servo on pin 9 to the servo object myservo3.attach(8); // attaches the servo on pin 9 to the servo object myservo4.attach(7); // attaches the servo on pin 9 to the servo object myservo5.attach(9); // attaches the servo on pin 9 to the servo object File dataFile1 = SD.open("datalog.txt"); Serial.print("Playing Back Motions"); Serial.print("\n"); // if the file is available, write to it: if (dataFile1) { while (dataFile1.available()) { SDdata = dataFile1.read(); SDstring += (char)SDdata; // if(isDigit(SDdata)) // { // SDstring += (char)SDdata; // } // else // { // // int Sensordata = (inString.toInt()); // SDstring += ("_"); // } if(SDdata == '\n') { digitalWrite(servo4, LOW); String reportString = SDstring; // Serial.print("\n"); // Serial.println(reportString); // Serial.print("\n"); int seperator[5]={0}; int n=0,startfrom=0; for(n=1;n<=5;n++) { seperator[n]= reportString.indexOf(',',startfrom); startfrom = seperator[n]+1; // Serial.print(seperator[n]); // Serial.print("\n"); } seperator[0]=-1; for(int count=0;count<=4;count++) { String sens1data = ""; for(int index = (seperator[count]+1); index < seperator[count+1]; index++) { char mostSignificantDigit =SDstring.charAt(index); sens1data += String(mostSignificantDigit); // Serial.print(index); // Serial.print(","); } servoangle[count+1] = sens1data.toInt(); // Serial.print(servoangle[count+1]); // Serial.print(sens1data); // Serial.print("\n"); } delay(15); SDstring = ""; } // myservo1.write(0); // myservo2.write(100); // myservo3.write(100); // myservo4.write(100); // myservo5.write(10); myservo1.write(servoangle[1]); myservo2.write(servoangle[2]); myservo3.write(servoangle[3]); myservo4.write(servoangle[4]); myservo5.write(servoangle[5]); } dataFile1.close(); myservo1.detach(); myservo2.detach(); myservo3.detach(); myservo4.detach(); myservo5.detach(); } // if the file isn't open, pop up an error: else { Serial.println("error opening datalog.txt"); } break; } case 'E': { if(SD.exists("datalog.txt")) { Serial.print("datalog.txt file found, preparing to delete"); SD.remove("datalog.txt"); Serial.print("\n"); Serial.print("file deleted..."); } break; } } }

Topic by steve444   |  last reply


How to get data from a load sensor through bluetooth module on an Android App/Arduino?

I am creating a mobile android application which gets data from a load sensor connected to HC-06 Bluetooth module and sends the data to a mobile application. The mobile app has two activities one for listing the bluetooth devices available and the other is the main activity to get data from the load sensor. I have managed to connect/pair with the Bluetooth module but I am unable to get data from it. The main activity consists of a button 'btnScan' that will get the data, and a text field to display the data. Can someone please help?  Here is the MainActivity File package com.uniproj.senseplate; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.UUID; import android.app.Activity; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.widget.Toast;   public class MainActivity extends Activity {       Button btnscan;   TextView txtArduino, txtString, txtStringLength, calorie;   Handler bluetoothIn;   final int handlerState = 0;             //used to identify handler message   private BluetoothAdapter btAdapter = null;   private BluetoothSocket btSocket; //= null;   private StringBuilder recDataString = new StringBuilder();      private ConnectedThread mConnectedThread;       // SPP UUID service - this should work for most devices   private static final UUID BTMODULEUUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");     // String for MAC address   private static String address; @Override   public void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       //Link the buttons and textViews to respective views                    btnscan = (Button) findViewById(R.id.scanBtn);                 txtString = (TextView) findViewById(R.id.txtString);     txtStringLength = (TextView) findViewById(R.id.testView1);       calorie = (TextView) findViewById(R.id.sensorView1);     bluetoothIn = new Handler() {         public void handleMessage(android.os.Message msg) {             if (msg.what == handlerState) {          //if message is what we want              String readMessage = (String) msg.obj;                                                                // msg.arg1 = bytes from connect thread                 recDataString.append(readMessage);              //keep appending to string until ~                 int endOfLineIndex = recDataString.indexOf("~");                    // determine the end-of-line                 if (endOfLineIndex > 0) {                                           // make sure there data before ~                     String dataInPrint = recDataString.substring(0, endOfLineIndex);    // extract string                     txtString.setText("Data Received = " + dataInPrint);                                 int dataLength = dataInPrint.length();       //get length of data received                     txtStringLength.setText("String Length = " + String.valueOf(dataLength));                                         if (recDataString.charAt(0) == '#')        //if it starts with # we know it is what we are looking for                     {                      //get sensor value from string between indices 1-5                      String weight = recDataString.substring(1, 5);                      //update the textviews with sensor values                      calorie.setText(weight + "kg");                            }                     recDataString.delete(0, recDataString.length());      //clear all string data                    // strIncom =" ";                     dataInPrint = " ";                 }                        }         }     };           btAdapter = BluetoothAdapter.getDefaultAdapter();       // get Bluetooth adapter     checkBTState();        // Set up onClick listeners for button to scan for data     btnscan.setOnClickListener(new OnClickListener() {       public void onClick(View v) {         mConnectedThread.read("1");       }     }); }   private BluetoothSocket createBluetoothSocket(BluetoothDevice device) throws IOException {             return  device.createRfcommSocketToServiceRecord(BTMODULEUUID);       //creates secure outgoing connecetion with BT device using UUID   }       @Override   public void onResume() {     super.onResume();         //Get MAC address from DeviceListActivity via intent     Intent intent = getIntent();         //Get the MAC address from the DeviceListActivty via EXTRA     address = intent.getStringExtra(DeviceListActivity.EXTRA_DEVICE_ADDRESS);     //create device and set the MAC address     BluetoothDevice device = btAdapter.getRemoteDevice(address);          try {         btSocket = createBluetoothSocket(device);     } catch (IOException e) {      Toast.makeText(getBaseContext(), "Socket creation failed", Toast.LENGTH_LONG).show();     }      // Establish the Bluetooth socket connection.     try     {       btSocket.connect();     } catch (IOException e) {       try       {         btSocket.close();       } catch (IOException e2)       {      //insert code to deal with this       }     }     mConnectedThread = new ConnectedThread(btSocket);     mConnectedThread.start();         //I send a character when resuming.beginning transmission to check device is connected     //If it is not an exception will be thrown in the write method and finish() will be called     //mConnectedThread.write("x");   }     @Override   public void onPause()   {     super.onPause();     try     {     //Don't leave Bluetooth sockets open when leaving activity       btSocket.close();     } catch (IOException e2) {      //insert code to deal with this     }   } //Checks that the Android device Bluetooth is available and prompts to be turned on if off   private void checkBTState() {     if(btAdapter==null) {      Toast.makeText(getBaseContext(), "Device does not support bluetooth", Toast.LENGTH_LONG).show();     } else {       if (btAdapter.isEnabled()) {       } else {         Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);         startActivityForResult(enableBtIntent, 1);       }     }   }     //create new class for connect thread   private class ConnectedThread extends Thread {         private final InputStream mmInStream;         @SuppressWarnings("unused")   private final OutputStream mmOutStream;               //creation of the connect thread         public ConnectedThread(BluetoothSocket socket) {          btSocket = socket;             InputStream tmpIn = null;             OutputStream tmpOut = null;             try {              //Create I/O streams for connection                 tmpIn = socket.getInputStream();                 tmpOut = socket.getOutputStream();             } catch (IOException e) { }                   mmInStream = tmpIn;             mmOutStream = tmpOut;         }                 public void run() {             byte[] buffer = new byte[1024];              int bytes;             // Keep looping to listen for received messages             while (true) {                 try {                     bytes = mmInStream.read(buffer);                     bluetoothIn.obtainMessage(handlerState, bytes, -1, buffer).sendToTarget();                 } catch (IOException e) {                     break;                 }             }         }                 //write method         public void read(String input) {             byte[] bytes = input.getBytes();//converts entered String into bytes             try {                 mmInStream.read(bytes);//write bytes over BT connection via outstream             } catch (IOException e) {               //if you cannot write, close the application              Toast.makeText(getBaseContext(), "Connection Failed", Toast.LENGTH_LONG).show();              finish();                            }          }      } } Here is the Arduino file #include int led = 13; int button = 12; LiquidCrystal lcd(9, 8, 4, 5, 6, 7); // Pins used for inputs and outputs******************************************************** float sensorValue1; float containerValue; char inbyte = 0; int flag; const int numReadings = 50; int readings[numReadings]; int index = 0; int total = 0; int average = 0; //******************************************************************************************* void setup() {     pinMode(led, OUTPUT);   digitalWrite(led, HIGH);   Serial.begin(9600);     for (int thisReading = 0; thisReading < numReadings; thisReading++)   {       readings[thisReading] = 0;   }     lcd.begin(16, 2); //change to 16, 2 for smaller 16x2 screens   lcd.clear();   lcd.print("hello, world!");   delay (1000);   lcd.clear();   delay (500); } void loop() {   digitalWrite(led, HIGH);   readSensor2();    //DONE       printLCD();       //DONE   return; sendAndroidValues();   //when serial values have been received this will be true   if (Serial.available() > 0)   {     inbyte = Serial.read();     if (inbyte == '0')     {       //LED off       digitalWrite(led, LOW);     }     if (inbyte == '1')     {       //LED on       digitalWrite(led, HIGH);     }   }     //delay by 2s. Meaning we will be sent values every 2s approx   //also means that it can take up to 2 seconds to change LED state   delay(2000); void readSensor2() {   total = total - readings[index];     readings[index] = analogRead(A0);     total = total + readings[index];     index = index + 1;     if (index >= numReadings)   {      index = 0;   }     average = total / numReadings;        //sensorValue1 = (analogRead(A0) - 330)* i;    //delay(200);         Serial.println(average);    delay(100);          if( digitalRead(button) == HIGH && flag == 1)   {     flag = 0;     containerValue = 0;      }   else if (digitalRead(button) == HIGH && flag != 1) {   flag = 1;                        //when the button is pressed the initially sesnsor     containerValue = sensorValue1;      delay(10);   }     //Serial.println(digitalRead(button));    delay (1000);    } //sends the values from the sensor over serial to BT module void sendAndroidValues() {   //puts # before the values so our app knows what to do with the data Serial.print('#');   //for loop cycles through 4 sensors and sends values via serial   Serial.print(sensorValue1);   Serial.print('+');     //technically not needed but I prefer to break up data values     //so they are easier to see when debugging Serial.print('~'); //used as an end of transmission character - used in app for string length Serial.println(); delay(5000);        //added a delay to eliminate missed transmissions } void printLCD() {   lcd.setCursor(4, 0);   lcd.print("   GRAMS    ");   lcd.setCursor(4, 1);   lcd.print(sensorValue1); }

Question by AyoS1   |  last reply


500W electric scooter control and instrumentation with Arduino mega

1. Introduction DC 500W motor control with an Arduino mega to limit starting current and to vary the speed of the scooter. The battery is in 24V, 10A.h. The following table summarizes their characteristics: https://i58.servimg.com/u/f58/17/56/35/17/a014.jpg https://i58.servimg.com/u/f58/17/56/35/17/a111.jpg 2. Bibliography: Link download : sketch_escooter_feed_back_reel_V1.ino https://drive.google.com/file/d/0B_fB3GAsM02FSlRTWHdyRkhuUW8/view?usp=sharing escooter_ampli_SIMULINK.mdl https://drive.google.com/file/d/0B_fB3GAsM02FOW9OdmlhdDhJZGc/view?usp=sharing escooter feed back ISIS.DSN https://drive.google.com/file/d/0B_fB3GAsM02FOXdRWFN5OWRMQkE/view?usp=sharing youtube  :  "study trotinette electric e-scooter 100W et 350W, wiring"  youtube https://www.youtube.com/watch?v=QqJ2-YiE8Tg&index;=75&list;=PLfZunVn_gcq7EOurXuWU2sRFmh6CbiUiL Article: «Study of electric scooters 100W and 500W (Arduino), Revue 3EI 2017» Pdf? Book «I realize my electric vehicle» at DUNOD 3. Open loop program To test the programming, we simulate the program in ISIS, as can be seen in the following figure. In addition, we have an LCD display to display data (duty cycle corresponding to the PWM at 32Khz, motor current, motor voltage, action on the pushbuttons, 4 push buttons are used. BP1 to manually increment the duty cycle, BP2 decrement it. BP3 set the duty cycle to 0, corresponding to the brake contact. The speed of the motor is practically proportional to the duty cycle https://i58.servimg.com/u/f58/17/56/35/17/a211.jpg We made our own current amplifier called a step-down chopper but it is possible to buy a shield There are many cards for Arduino to control DC motors especially of low powers and also of great powers as can be observed on the following links.http://www.robotpower.com/products/MegaMotoPlus_info.html http://www.robotshop.com/en/dc-motor-driver-2-15a.html https://www.pololu.com/file/0J51/vnh3sp30.pdf https://i58.servimg.com/u/f58/17/56/35/17/a310.jpg But all these chopper shields measure the current internally but there is no current limitation. In order to have a current limitation, an analog current loop is required using specialized AOP or IC or a fast digital current loop. But what should be the value of the limitation current? The choice of the current value is normally for the 1-hour operation service in order to be able to carry out relatively long climbs without reaching the critical temperature of the engine. In our case, the limitation current must be Limiting motor = Power / Upper battery = 500W / 24V = 20A In addition, the power transistor of the chopper can only support 50A in our case. But in open loop, it has no current regulation, so as not to exceed the maximum current, a ramp of the duty cycle will be used. A 0.1 second interruption routine will be used to measure the voltage of the current (sample measurement, sample). This sampling time is arbitrary but does not allow to be faster than the rise time of the current because the electric time constant of the motor is L / R = 1.5 ms. Open loop operation with a 25.5s (8bit) ramp and 0.1s interrupt routine provides a good understanding of the operation of a DC motor drive. The display will only be done every 0.2s to have a stability of the digits on the screen. In addition, a digital filtering will be done on the current and the voltage on 4 values therefore on 0.4s. [b] Algo open loop [/b] Interrupt Routine All 0.1S Read voltage and current Loop loop (push button scan) If BP1 = 1 then increment PWM If BP2 = 1 then decrement PWM If BP3 = 1 then PWM = 0 Displaying variables every 0.2s Code: [Select] // include the library code: #include #include #include #define SERIAL_PORT_LOG_ENABLE 1 #define Led     13       // 13 for the yellow led on the map #define BP1     30       // 30 BP1 #define BP2     31       // 31 BP2           #define BP3     32       // 32 BP3 #define LEDV    33       // 33 led #define LEDJ    34       // 34 led #define LEDR    35       // 35 led #define relay   36       // 36 relay #define PWM10    10      //11   timer2    LiquidCrystal lcd(27, 28, 25, 24, 23, 22); // RS=12, Enable=11, D4=5, D5=4, D6= 3, D7=2, BPpoussoir=26 // Configuring variables unsigned   int UmoteurF = 0;  // variable to store the value coming from the sensor unsigned   int Umoteur = 0; unsigned   int Umoteur2 = 0; unsigned   int Umoteur3 = 0; unsigned   int Umoteur4 = 0; unsigned   int ImoteurF = 0;  unsigned   int Imoteur = 0; unsigned   int Imoteur2 = 0; unsigned   int Imoteur3 = 0; unsigned   int Imoteur4 = 0;            byte Rcy=0 ;    // 8bit duty cycle unsigned    int temps; // the setup function runs once when you press reset or power the board void setup() {   pinMode(Led, OUTPUT);   // Arduino card   pinMode(LEDV, OUTPUT);   pinMode(LEDR, OUTPUT);   pinMode(LEDJ, OUTPUT);   pinMode (PWM10,OUTPUT);     // Pin (10) output timer2   //  digitalWrite(LEDV,LOW);   Timer1.initialize(100000);         // initialize timer1, and set a 0,1 second period =>  100 000   Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt   lcd.begin(20, 4);    Serial1.begin(9600);   TCCR2B = (TCCR2B & 0b11111000) | 0x01;         //pin 10  32khz    http://playground.arduino.cc/Main/TimerPWMCheatsheet                                                   //http://www.pobot.org/Modifier-la-frequence-d-un-PWM.html   //   analogWriteResolution(bits)      https://www.arduino.cc/en/Reference/AnalogWriteResolution lcd.setCursor(0,1); lcd.print("Rcy"); lcd.setCursor(10,1); lcd.print("Um"); lcd.setCursor(5,1); lcd.print("Im"); lcd.setCursor(10,1); lcd.print("Um"); lcd.setCursor(20,1); // 4 lines display * 20 characters lcd.print("BP1+"); lcd.setCursor(25,1); lcd.print("BP2-"); lcd.setCursor(29,1); lcd.print("BP3=0"); } // Interruptions  tous les 0.1s void callback()  { temps++; //toogle state ledv for check   if ( digitalRead(LEDV)== 1 ) {digitalWrite(LEDV,LOW);}     else {digitalWrite(LEDV,HIGH);}     analogWrite(PWM10,Rcy);   // frequency Umoteur=analogRead(A0); Imoteur=analogRead(A1); Imoteur2=Imoteur; Imoteur3=Imoteur2; Imoteur4=Imoteur3; ImoteurF=(Imoteur4+Imoteur3+Imoteur2+Imoteur)/4 ; Umoteur2=Umoteur; Umoteur3=Umoteur2; Umoteur4=Umoteur3; UmoteurF=(Umoteur4+Umoteur3+Umoteur2+Umoteur)/4 ;   }// End routine // Loop corresponding to main function void loop() {    // BP + LED   if ((digitalRead(BP1))==1) {     lcd.setCursor(20,0);      // Column line     lcd.print("BP1");     digitalWrite(LEDR, LOW);        digitalWrite(LEDJ, LOW);     Rcy++;                        // PWM incrementation     if ( Rcy>254)  {Rcy=254;}     delay(100);               //8bits * 100ms = 25S increment 25ssecond slope     }        if ((digitalRead(BP2))==1) {     lcd.setCursor(20,0);     lcd.print("BP2");             Rcy--;      if ( Rcy<2)  {Rcy=2;}  // PWM almost at 0, engine stop         delay(100);      digitalWrite(LEDR, HIGH);     digitalWrite(LEDJ, HIGH);     }   if ((digitalRead(BP3))==1) {     lcd.setCursor(20,0);     lcd.print("BP3");      Rcy=2;               // PWM almost at 0, engine stop     } if (temps>=2)  { lcd.setCursor(0,0); lcd.print("                "); // Erase line lcd.setCursor(0,0);     lcd.print(Rcy); lcd.setCursor(5,0); ImoteurF=(ImoteurF)/20;     //resistance (5/1024)*(10/0.25ohm) si ACS712 66mV/A                            // For resistance 1ohm (ImoteurF) / 20; Simulation 5/25 lcd.print(ImoteurF); lcd.setCursor(10,0); UmoteurF=UmoteurF*10/38;                              //10/38   10/30 simula if (Umoteur>ImoteurF){UmoteurF=UmoteurF-ImoteurF;  }  //U-R*I lcd.print(UmoteurF); temps=0; }// End if time    } // End loop https://i58.servimg.com/u/f58/17/56/35/17/dsc_0614.jpg Since there is a limit of 9000 characters in the forum below Open loop program feature previous The interrupt routine lasts only 250 microseconds, the loop of the main program which scans the action of push buttons is 13micros and the display time of all data is 11ms. Thus, it is possible to improve the sampling period and thus the speed of the regulation of the current. The Arduino makes it possible to make the instrumentation of the scooter so to know the power, the consumption in Ah and Wh, to measure the speed, to know the consumption according to Wh / km, to measure the temperature of the engine, Have a safe operation. But for now we will see how to limit the current 4. Closed loop program, limited current control The sampling period will increase to 0.01 seconds (interrupt routine) If the current is less than the desired value, then the duty cycle can be increased or decreased to the desired value which is the setpoint. On the other hand, if the motor current is greater than the limiting value, there is a rapid decrease in the duty cycle. So as not to exceed the value of the duty cycle if it is saturated to 254 maximum and to the minimum value 6. Code: [Select] if (Imoteur<4000)                    // No current limitation at (20A * 10) * 20 = 4000   {if (consigne>Rcy)   {Rcy=Rcy+1;}   // Pwm ramp + 1 * 0.01second pure integrator    if (consigne    if ( Rcy>254)  {Rcy=254;}           // Limitation of duty cycle    analogWrite(PWM10,Rcy);   // Frequency 32kHz timer2}         } if (Imoteur>4000)  { Rcy=Rcy-5;              // No current filtering, to be faster                     if ( Rcy<6)  {Rcy=5;}       // Rcy is not signed, nor the PWM therefore Rcy minimum must not be less than 6                   analogWrite(PWM10,Rcy);   // Frequency 32kHz timer2}                        } 5. Closed Loop Program, Limited Current Control with Acceleration Handle An acceleration handle provides a 0.8V voltage when not operated and a 4.5V voltage when the handle is fully engaged. Instead of using pushbuttons to increase or decrease the speed setpoint, an acceleration handle will be used Code: [Select] Upoignee=analogRead(A3); // The relation in Upoign and the setpoint which corresponds to the duty cycle corresponds to if (Upoignee>100) { consigne=(Upoignee/2);     //0=a*200+b    et 255=a*800+b                      consigne= consigne-100;                   }                            else { consigne=0;   }               if (Upoignee<100) { consigne=0;  }     // redundancy     6. Temperature and safety program of the motor with the current measurement The outdoor temperature measurement can be easily performed by the LM35 component which charges 0.01V by degrees Celsius Code: [Select] temperature=analogRead(A2); //lm35 0.01V/°C temperature=temperature/2;       // Temperature coefficient lcd.setCursor(5,2); lcd.print("      "); lcd.setCursor(5,2); lcd.print(temperature);   // Display in ° C lcd.setCursor(9,2);      // Erasing secu display lcd.print("     ");   if (temperature>80 ) {lcd.setCursor(9,2);         // If motor external temperature is above 80 ° C                      lcd.print("secuT");                       Rcy=0;} In addition, thermal safety by measuring the motor current will be added. If the limitation current is greater than 10s then the motor will no longer be powered for 30s. A "secu" display will appear on the LCD display. This safety makes it possible to cut the motor on slope too high and when blocking the engine but it would be necessary to add the measurement of the speed in the latter case Code: [Select] if (timesecurite>=10000 ) {flagarret=1;      // If limitation current for a current of more than 10s                               timerepos=0;                               consigne=0;                               Rcy=0;                                 timesecurite=0;}       //   Then stop engine during a downtime    if (flagarret==1 ) {lcd.setCursor(9,2);         // If limiting current for a current of more than 20s                      lcd.print("secU");  }     //   Then stopping the motor for a stop time and display                                                     if (timerepos>=30000 &&  flagarret==1) {flagarret=0;                                           lcd.setCursor(9,2);      // After a rest time here of 30s                                            lcd.print("       ");   }   The display can be observed if the temperature is above 80 ° C https://i58.servimg.com/u/f58/17/56/35/17/a017.jpg Thermal safety by measuring the motor current (digital thermal relay) which allows to know the image of the internal temperature of the engine would be ideal. But for this, it is necessary to know well the thermal modeling of the motor. 7. Measurement of the energy capacity of the battery The energy capacity of a battery is in A.H, we will display the value in mA.H to have a high accuracy. The capacity will be in A.Second in the following equation. So to have in mA.H, it will be divided by capacity by3600. Capacity (A.s) n = I * Te + Cn-1 with Te = 0.01s and I multiplied by 10 So in the interrupt routine Code: [Select] capacity=ImoteurF+capacity ; And in the display Code: [Select] lcd.setCursor(0,3); // Display of energy capacity lcd.print("C mA.h="); capacity1=capacity/(18000);   //18000=3600*5  5=> Current measurement coefficient lcd.print(capacity1); To check a current of 10A with an adjustable resistor and after 30s, the capacity must be 83mA.H 8. Power and modeling with SIMULINK Modeling helps to understand the vehicle and its control. In addition, it is possible to compile the control part directly into the Arduino program from simulation under Simulink. But it will not be possible to simulate the instrumentation with the LCD display. In the following figure, we can observe the simulation of the programming of the chopper with the current limitation with Simulink. In the following figure, the green box shows the duty cycle control to vary the speed and the red border the current limitation. The controller of the control is here a simple integrator but it is possible to carry out a multitude of control. https://i58.servimg.com/u/f58/17/56/35/17/azub_c15.jpg In the previous figure, it can be observed that the current is well limited to 25A from 2s to 9.5s. Then, the current reaches 10.8A under established speed regime at 22.5km / h. The dynamics are similar to the tests carried out. With a slope of 5%, the cyclic ratio reaches only 100% as can be seen in the following figure. The speed will reach painfully 19km / h with a current of 24A and a motor power of 580W. See article: Study of electric scooters 100W and 500W (Arduino), 9. First conclusion It is easy to control a 500W DC motor with an Arduino and some components So repair many scooters that are in DC motors. But it takes some knowledge (automatic, engine) to know how to properly manage the engine and limit its current so as not to damage it The display of the speed, the distance, the operating time to know the Watt.km / km can also be realized with a menu 2. The .ino program as an attached file, But it is not possible to put an attached file in ISIS electronic labcenter? What is this forum? It would be desirable that the compiler could generate the.cof to debug in Isis and test the program line by line .... Arduino still has to make a lot of effort to be on the same level as other microcontrollers 10. speed measurement (tachometer) Velocity measurement is carried out using a hall effect sensor SS495 or A1324 which counts each revolution of the wheel. It is enough to enter the perimeter of the wheel of the scooter (130mm of radius therefore 0.816m in the case To have the speed, it is enough just to divide the number of turn of wheel on an arbitrary time of 1s to have a minimum speed of 0.81m / s therefore of 2.93 km / h. In addition, an average filter with 3 values will be used to display the speed. At 25km / h, there will be 8.5 laps. To count the turns, an external interrupt routine will be used on input INT0 21 of the mega card. http://www.locoduino.org/spip.php?article64 To simulate the speed, a pulse on input 21 will be used with a duty cycle of 10%. https://i58.servimg.com/u/f58/17/56/35/17/a018.jpg Code: [Select] void INT0b21() {   Tspeed++;   // External interruption to count the number of turns } // In the set up declare the interrupt routine when the 5V edge of the magnet detection is done   attachInterrupt(digitalPinToInterrupt(21), INT0b21, RISING );  // External interruption // In loop if (temps09>=5)  {        // 1 second loop lcd.setCursor(13,2);      // Erasing speed lcd.print("kph     "); lcd.setCursor(16,2); speed1=Tspeed*2937;      //1tour*816*3.6/1s=2.937km/h speed2=speed1;           //Tspeed (rate/seconde) speed3=speed2; speedF=(speed1+speed2+speed3)/3000;   // To put in kph lcd.print(speedF,1);    // Display to the nearest tenth Tspeed=0;   // Reset counter temps09=0;  //reset time } To improve the accuracy of the velocity measurement, it is possible that the sampling time of the velocity measurement is dependent on the velocity. For example: For speeds less than 10km / h sample at 1second, but above 10km / h sample at 2 seconds. 11. Distance measurement for autonomy The distance corresponds to the total number of turns of the wheel multiplied by the perimeter of the wheel. So do not set the number of turns to 0 for each sample. On the other hand, the reset of the distance will be done when pressing the reset of the Arduino Mega. The distance display will be displayed to the nearest second. At 32km / h, it will take 2 minutes to do 1km as can be seen in the following figure: https://i58.servimg.com/u/f58/17/56/35/17/a019.jpg Code: [Select] void INT0b21() {   Tspeed++;   // External interruption to count speed   nbrRate++; } lcd.setCursor(13,4);      lcd.print("km      ");  // distance=(nbrRate*816)/1000;  //distance m distance=distance/1000;  //distance km lcd.setCursor(15,4);      lcd.print(distance,1);  You can observe the electrical installation with the chopper, the arduino, and the display when the program is set up https://i58.servimg.com/u/f58/17/56/35/17/dsc_0613.jpg 12. Synthesis The RAM space is used only at 4% and ROM space at 3%, for an Arduino mega. So we could take an arduino a little smaller. But, there are 8 Lipo cells to make the 24V power supply to power the engine via the chopper. Therefore, the voltage measurement of each element will be on the Arduino with a JST connector. This measurement makes it possible to know if a cell with an internal resistance which begins to pose a problem and to know if the balancing of each cell has indeed been carried out. It is possible to switch to 36V with 12 cells also with the arduino mega without using an external shield that multiplex 24 analog inputs on input A0 It is possible to send all data to a smartphone via Bluetooth HC06 via pins 20, 21, RX1 and TX1. But the application under android realized under JAVA Studio can not be shared on this forum. This part will not be explained. After having made the instrumentation of this scooter, a study should be carried out on the precision of the measurements, it is possible to read "Instrumentation of a low-power electrical motor vehicle" eco marathon "type Revue 3EI N ° 81, July 2015 http://www.fichier-pdf.fr/2015/09/07/instrumentation-vehicule-faible-consommation-eco-marathon/

Topic by Iutgeiisoissons