Can an HC-05 Bluetooth module be used as an audio receiver? Answered

Of course there are specific BT audio receivers, but I like to save money.... 

Question by DangerousTim   |  last reply


SENSOR- Ultrasonic HC-SR04 (Interfacing HC-SR04 with 8051)

Hi friends, I am doing a project based on obstacle detector. It is a outdoor project hence i choose to buy an ultrasonic sensor to work efficiently on both bright sun light as well as dark nights. Now my problem is i am not able to interface this sensor with my controller. Anyone please tell me what input i must give to trig input of that sensor and what kind of output i get form the echo pin. also tell me how can i interface this sensor with the AT89S52. i have attached the user manual which i downloaded from internet.  Please help me with your valuable comments, Thanks in advance.

Topic by knachuthan   |  last reply


Interfacing HC 05 with Atmega?

Somebody please tell me the code to turn ON and OFF a Led on atmega8 board using hc 05 Bluetooth module Some what like this

Question by Mayoogh_Girish   |  last reply


Bluetooth (HC-06) with ATtiny85

Hi everyone,      I've been playing around with the HC-06 Bluetooth module for a while now and have had great success with it so far.  However, I have been using the Arduino Uno and Pro Mini, which have quite a few unused pins in my applications.  In order to downsize I'm trying to use the Atmel ATtiny85 chip.  I have used it many times in the past so I'm at least a bit familiar with its functions and limits.  For some reason I cannot get the Bluetooth module to work with the ATtiny85.  After many long and frustrating hours spent in vain, I decided to ask you all for help.  Does anyone know of any good tutorials or code for using the ATtiny85 with the HC-06 module?  It would be great if I could use the app Ardudroid to control the ATtiny85, but any help would be greatly appreciated.   Thanks ~Dudes

Topic by dudes   |  last reply


Hc-05 and Arduino connection

Hello to everyone.I have make a bleutooth robot which i can control it via android(tablet) and i have a problem with the code.I want from the robot to stop when connection lost or bluetooth disconnected.Now when the connection lost the robot go ahead and falls on the objects.How to add this line on the code?Can you help me please?The STATE pin of HC-05 when is HIGH is connected and when is LOW is disconnected.I put this on my code but it doesn't stop.Thank you for your time The bluetooth that i use is HC-05 My code: #include Servo SERVO_1; // Initialize Servo1 // Motor Control Variables int PWM1 = 9; int ENABLE1 = 8; int PWM2 = 5; int ENABLE2 = 7; int PWM3 = 3; int ENABLE3 = 4; int PWM4 = 6; int ENABLE4 = 12; int STATE=2; void setup() {   SERVO_1.attach(10);   Serial.begin(9600);   pinMode(ENABLE1, OUTPUT);  //Δήλωση όλων των μεταβλητών ως έξοδος   pinMode(ENABLE2, OUTPUT);  //Δήλωση όλων των μεταβλητών ως έξοδος   pinMode(ENABLE3, OUTPUT);  //Δήλωση όλων των μεταβλητών ως έξοδος   pinMode(ENABLE4, OUTPUT);  //Δήλωση όλων των μεταβλητών ως έξοδος   pinMode(STATE, INPUT); } void loop() {    if(digitalRead(STATE)== HIGH)   // see if there's incoming serial data:   if (Serial.available() > 0) {     // read the oldest byte in the serial buffer:     int incomingByte = Serial.read();     // action depending on the instruction     // as well as sending a confirmation back to the app     switch (incomingByte) {       case 'F':         moveForward();         Serial.println("Going forward");         break;       case 'L' : // Case 'L' is received,         SERVO_1.write (180); // Στρίψε Αριστερά.         SERVO_1.attach(10);         break;       case 'N':         turnright();         Serial.println("Turning right");         break;       case 'M':         turnleft();         Serial.println("Turning left");         break;       case 'O' : // Case 'L' is received,         SERVO_1.write (0); // Στρίψε Αριστερά.         SERVO_1.attach(10);         break;       case 'B':         moveBackward();         Serial.println("Going forward");         break;       case 'P':         SERVO_1.write(90); // Στρίψε Αριστερά.         SERVO_1.attach(10);         break;       case 'S':         moveNone();         Serial.println("Stopping");         break;       default:         // if nothing matches, do nothing         break;     }   } } void moveForward() {   // turn the driving motor on to go forwards at set speed   digitalWrite(ENABLE1, HIGH);   digitalWrite(ENABLE2, HIGH);   digitalWrite(ENABLE3, HIGH);   digitalWrite(ENABLE4, HIGH);   analogWrite(PWM1, 255);   analogWrite(PWM2, 255);   analogWrite(PWM3, 255);   analogWrite(PWM4, 255); } void moveBackward() {   // turn the driving motor on to go backwards at set speed   digitalWrite(ENABLE1, LOW);   digitalWrite(ENABLE2, LOW);   digitalWrite(ENABLE3, LOW);   digitalWrite(ENABLE4, LOW);   analogWrite(PWM1, 255);   analogWrite(PWM2, 255);   analogWrite(PWM3, 255);   analogWrite(PWM4, 255); } void turnright() {   digitalWrite(ENABLE1, HIGH);   digitalWrite(ENABLE2, HIGH);   digitalWrite(ENABLE3, LOW);   digitalWrite(ENABLE4, LOW);   analogWrite(PWM1, 255);   analogWrite(PWM2, 255);   analogWrite(PWM3, 255);   analogWrite(PWM4, 255); } void turnleft() {   digitalWrite(ENABLE1, LOW);   digitalWrite(ENABLE2, LOW);   digitalWrite(ENABLE3, HIGH);   digitalWrite(ENABLE4, HIGH);   analogWrite(PWM1, 255);   analogWrite(PWM2, 255);   analogWrite(PWM3, 255);   analogWrite(PWM4, 255); } void moveNone() {   // turn the driving motor off   digitalWrite(ENABLE1, 0);   digitalWrite(ENABLE2, 0);   digitalWrite(ENABLE3, 0);   digitalWrite(ENABLE4, 0);   analogWrite(PWM1, 0);   analogWrite(PWM2, 0);   analogWrite(PWM3, 0);   analogWrite(PWM4, 0);   SERVO_1.detach(); }

Question by dimitrakis1992   |  last reply


Help regard ESP 8266 or HC 05? Answered

Hi guys! :3 So I'm in need of some help regarding this project https://www.instructables.com/id/Make-A-Simple-Bidepal-Humanoid-Robot/ According to the project, you need to reprogram the robot for every function but it would be very tedious and time consuming to program it again and again. So, I thought that it would be nice to use a HC 05 or ESP 8266 (along with arduino) with a program to control whether it's walking, kicking or dancing etc. so I could control it through my mobile. The problem is that I have zero skills on developing software for the mobile, arduino or esp. I would love it if anyone could help me by making a small program. Also, would it be better to use the Bluetooth module or ESP? I would prefer ESP as it's cheaper but not by alot so if the Bluetooth module has benefits, I can buy that. Thanks in advance. :)

Question by SA-DIY   |  last reply


How to reduce range on HC-05 BT module to 3 feet only?

I'm trying to design and build a rf shield to encase the hc-05 bluetooth module in order to reduce the range adjustably. For the first use I want to reduce the range to around 3 feet. Any tips?

Question by dmagryta124   |  last reply


Can I control a robot with a wireless controller with bluetooth modules?

I'm working on a Hexapod right now, but I haven't found a way to control it wirelessly. I have tried working with nrf24L01 modules but just can't find a way for it to work.... Right now I have 2 HC-05 and 1 HC-06, can I do it? My plan is to control the hexapod (controlled by an Arduino) with a controller with another Arduino that has a joystick, along with 2 buttons to switch mode or rest mode. I'm still relatively new to Arduino so I have no idea how to search the way to control Arduinos using the 2 pins TXD and RXD. Also, which information can I send on these bluetooth modules (integer, boolean, etc)? I really appreciate if someone can help me start on how to use these things

Question by Shizen   |  last reply


Arduino servos not being supplied enough power by 9V battery?

Hey guys, I'm working on my first instructable which is an robotic snake which you control via the HC-06 bluetooth module and an arduino. I'm using an arduino bluetooth app on my smartphone, but this isn't the problem. There are three servos which I am supplying power to, two continuous rotation servos for movement and one ordinary servo. I'm powering it through a 9V battery thing I got off of the adafruit store, which has the plug that goes into the power supply. When I try to control it like this, the servos twitch and barely move. The ordinary one doesn't as far as I can tell. However, when I supply power through my computer cable, the bluetooth still works from my phone, and the servos go at an ordinary rate. I'm supplying the two continuous rotation servos and the normal one through the 5 volt pin, and the bluetooth module through the 3.3 volt one. Can anyone tell me why it isn't working, or an alternate technique of powering it?

Question by RedCthulu   |  last reply


Need help controlling two servos using arduino, bluetooth, and android.

Hi folks.  I am back.  I haven't been very active on here for the past several months, but I did move to a different continent.  Anyway, I need a little help from of those smart arduino folks out there.  I am looking for an app and arduino code to control two servos using an android device via Bluetooth.  There are a ton of instructables on controlling motors via Bluetooth, and there are also several tutorials on controlling one servo via Bluetooth, but what I want to know, is how to control two servos.  I am looking for something like this but able to control two servos.  I did try an app that uses an accelerometer to control two motors, but I want to be able to control them by a slide or nob.  If someone knows of a link that could be the solution to my problem I would be grateful for it. Any help would be greatly appreciated.  Thanks, th3_jungle_inv3ntor  -   actually I left the jungle :(

Topic by th3_jungle_inv3ntor   |  last reply


How to use Bluetooth Module - HC-05 Device as audio receiver?

I want to connect Bluetooth Module - HC-05 (or HC-06) to my home theater to receive stereo audio signal from laptop. please give me the full guidelines.

Question by smandal13   |  last reply


How to send information between 2 HC-05? Answered

I need to send a number from 1 Arduino to another using 2 HC-05. I have followed the AT setup and connection in this video https://www.youtube.com/watch?v=hyME1osgr7s. I have successfully connected 2 HC-05 module but I can't get the master to send a relatively large number to the slave. I uploaded my code and result--serial command is the slave's (Basically I want the slave to receive the number and print onto serial screen, but it doesn't happen) Another question is if I want to send 3 integers in a row (Like 23, 34, 56) and let the other receive as 3 different integers (int1=23, int2=34, int3 = 56), how do I do that? Btw, how do I suppose to upload the files to Arduino properly? When I have the TX->RX0; RX->TX1 (Bluetooth pin to Arduino pin), I can't upload the file. I have to disconnect and upload, then it seems to upload but doesn't work properly. Thanks in advance.

Question by Shizen   |  last reply


What does the "state" pin do on the HC-05 Bluetooth module?

Hi all, What is the function of the state pin on the HC-05 6-pin serial bluetooth module?

Question by dmagryta124   |  last reply


Are the JY MCU and the HC 05 bluetooth module the same?

If not, how are they different? do they works with all android phones? what librabries or software do i use for controlling these with arduino???

Question by DangerousTim   |  last reply



What is the program code for arduino obstacle avoiding robot it has IR remote and receiver module with HC-SR04 sensor?

It has HC-SR04 ultrasonic sensor , arduino uno R3, L293D motor driver , and Infrared remote and Infrared receiver module.

Question by KodakH1   |  last reply


Fire fighting Robot controlled wirelessly via hc-12 using a Joystick

Hi all!I would like share videos of my project "fire fighting Robot". Here are the links ! Enjoy!!!

Topic by weFwe123 


How to power servo without driver/arduino?

Hi, I'm trying to make a servo motor spin without using a driver or micro controller, I just want to power it directly. It doesn't need to move a specific distance, or be precise. How would I wire this up? The idea is to power it on by using a HC-05 Bluetooth module, either directly, or by optocoupler. It would have to trigger the servo on whenever a Bluetooth device that has already been paired connects to the HC-05 module (in wireless range), and then off when a Bluetooth device disconnects (out of range). My idea is to use an app that automatically plays an audio file through the HC-06 when it connects (this app already exists), and that audio file happens to be the correct frequency to act as a PWM signal. Is this even possible?

Question by dmagryta124   |  last reply


Can you tell me the code for arduino robot that has HC-SR04 Ultrasonic sensor , L293D , IR receiver module and remote?

It is a arduino obstacle avoiding robot , that has arduino uno R3 , L293D motor driver , HC-SR04 ultrasonic sensor , IR remote and receiver module on 2wD chassis.

Question by KodakH1   |  last reply


arduino ultrasonic communication

I was thinking about using the ultrasonic  module (hc-sr04) for communication for two or more arduino.the way i was thinking of do to turn a 8 bit number into single bits(i have no idea on how to do that) and send them one at time(with delay) to a another arduino which turn it back into a number also  has a master arduino  and slave arduinos 

Topic by act casual   |  last reply



Arduino bluetooth HC-05 game controller to control Android games

I got a new project to make a pretty unconventional (fitness) game controller using Arduino to control Android games. The ideea is the following: using the Android VR technology (Cardboard or Dive) it was pretty simple to create a basic game (3d world to walk around) using Unity3D and Dive SDK. If you put on the Google Cardboard, the VR experience begins. But still so few devices are on the market, which give you back the control over your smartphone, which now is fixed in front of your eyes. I want to use this and make a fitness app which will be controlled by running on a treadmill (or using a workout bike). Something like the old Nintendo Wii and the running game from Sports. Or a game like Temple Run, in which running the treadmill faster, gets you faster in the game. For this I would like to create a game controller which records the leg movements, direction, body position, etc. which would then influence the actions in the game. A lot of details I still need to work out. So the question is, does anybody know of a guide or tutorial on how to create a game controller like this, using an Arduino a bluetooth module like HC-05. The controller should not be bound to a specific game or 3rd party app, should work like a usual game controller for android (connecting to some bluetooth android game profile?). There are many android game controllers out there which dont need a special android driver/3rd app to control any game. So this has to work somehow. So how can I programm an Arduino to send (once paired) the same events a bluetooth gamecontroller (or bt keyboard or mouse) sends, which doesn't need any 3'rd party Android app to be able to send basic key pressed events to a random game. Best regards, F

Topic by fcfelix   |  last reply


robot that talks back ?

Hi so i'm building a Robot controlled by voice using my android phone and HC-05 Serial Bluetooth Module(Hi so i'm building a Robot controlled by voice using my android phone and HC-05 Serial Bluetooth Module so my question is how can i make the robot talk back to me ) so my question is how can i make the robot talk back to me simple things for exemple when i talk to the robot using my phone it will say YES SIR or tell jokes 

Question by omarb22   |  last reply


About RN-42 bluetooth (with two arduino MICRO and one laptop)

Hi, there. I have a question about RN-42 bluetooth module. I want to make a bluetooth HID device (keyboard and mouse) and ,because of my direction of team project, it has two pieces. One arduino MICRO (using RN-42) is going to be master and the other MICRO (using HC-05) is going to be slave. Actually their roles can be changed! The goal is to connect RN-42 to my laptop while RN-42 is also connected to HC-05 and use this as a bluetooth keyboard. Now, Is it possible that RN-42 module has multiple connections?

Topic by 태현김3   |  last reply


Code for controlling the brightness of LED using Bluetooth module HC-05-v1.0?

I am using arduino ATmega328 micro-controller. i tried some analog coding to control the brightness via Bluetooth module but the output value of the LED is constant. The code I used is, int ledPin = 5;  int fadeValue = 0; void setup() {     pinMode(ledPin,OUTPUT);     Serial.begin(9600);     delay(100); } void loop() {   // fade in from min to max in increments of 5 points:     if (Serial.available() > 0)     {            fadeValue = (int) Serial.read();            Serial.println(fadeValue-48);            for(int i=0;i<=fadeValue;i+=5)                analogWrite(ledPin, i);                    } }

Question by santhoshpl3   |  last reply


Voltage Regulator circuit

I am trying to power Bluetooth module and the Arduino using a 9V battery. So tried to use a voltage regulator (KA7805) with 25volt 100miro farad and 63V 1 micro farad capacitors. I checked the circuit connecting these components using multimeter, it showed 5.06V as the output. But the problem comes when I connect the Bluetooth module to this output, which turns off after quickly. I checked the voltage at the bluetooth which is reducing quickly from 5V-2.5V in a matter of seconds and since the operating voltage of Bluetooth module HC-05 is 3.6V-7V, it turns off. I am not clear why this circuit behaving this way. Same output when I connected to the Arduino, it works seamlessly. Please let me know what are the mistakes that I need to rectify for this work. Thanks in advance

Topic by Bhanu Kishan 


Back that Arduino Up

Hello instructables, I am a student at High Tech High North County and we are working with arduinos in our Engineering class. Our project is to create a reverse sensor for a motor vehicle, we are having trouble finding a way to set up the sensor with the arduino. The sensor we are using is HC-SR04 Ultrasonic Ping range sensor. If you have any idea on how to do this, please reply. Thanks.

Topic by hthnc-student   |  last reply


Arduino bluetooth control

So, I've been on a project where i am trying to use a generic bluetooth gamepad to control dc motors through a HC05 bluetooth module connected to an arduino. I have no idea on where to start. I did some research about it but there dosent seem to be much information thats appropriate for this project. here is what im using now: -ipega bluetooth controller -arduino mega 2560 -HC-05 bluetooth module

Topic by thomasmanman   |  last reply


How can I use a digital camera to obtain DSLR looking footage?

I recently bought a new video camera, the Panasonic HC-V750. Don't get me wrong, its an amazing camera and I love it, but I made the mistake of spending 500 bucks on this instead of a DSLR. I am trying to make a short film and want it to look professional. However, I know that this is almost always achieved using a DSLR and nifty editing/lighting techniques. I have the editing and lighting techniques down, but is there any way to adjust my video camera so that I can get DSLR-like quality? Like adjusting shutter or something? I know that the advantages of a DSLR are their large sensors and supreme ability to capture light using these sensors. Can I achieve this, at least a little, with my video camera? I can adjust the white balance, shutter, iris, and focus, on my camera. Any links and/or help is greatly appreciated!

Question by Adum24   |  last reply


sketch for arduino obstacle robot using seed motor shield v2.0?

Hi everybody, im barely started writing sletch so i need help, i build a obstacle robot and i used  arduino uno r3 seeed motor shield v2.0 one servo tamiya twin motor gear box hc-sr04 sensor  so i dont really know how to start writind the sketch.....

Question by salvador.lopez1   |  last reply


Arduino Bluetooth to Visual Forms

Hey folks I hav a problem: I am trying to make a GUI in visual forms which displays Data received from an Arduino via Arduino sent with a HC-06 Blutooth module, the data is a 10 cell integer array which should be displayed in 10 textboxes. my problem is how do I retrieve the data from the computer's bluetooth in Visual Forms/Studio. thank you for your help

Topic by Red-Fox   |  last reply


How can i separate mac & store memory in arduino ''+INQ:1D:FE:720479,7A020C,7FFF"

I want to make Door lock in a different way.please anybody suggest me,when i come back in my room, it is self unlock the door lock, use arduino & HC 05,my Bluetooth run at command mode ,at first collect the last pair Bluetooth mac and it is compared with +inq mac address ,if my phone mac is available then unlock the door automatically .

Question by nazmulmilon   |  last reply


How to stop a servo using conditional if?

I'm using an Arduino Uno, Ultrasonic sensor (HC-SR04) a Servo motor (SG90 Tower Pro). I would like to rotate the servo continuously from 0 to 180 and back to 0. I would like to stop the servo whenever the ultrasonic sensor detects an object  at a distance of 40 cm or less. I know how to rotate the servo and how to detect an object using the ultrasonic sensor, but I couldn't combine the two. Can you kindly help me on how to do so?

Question by iSmartov   |  last reply


music shield V2 with bluetooth can't receive message

I wnat to receive messages from phone and add variable to change songs. Why the program can't receive message.Can't enter the while loop when I send message. How can I change the program? (mega2560,HC-06 Bluetooth and music shield V2) music shield V2 must include Music_Shield-master library #include #include #include #include #include SoftwareSerial BTSerial(10, 11); // RX | TX char a; int i=0; void setup() {    Serial.begin(9600);             BTSerial.begin(9600);  // HC-06 current bound rate (default 9600)                         player.begin();                      //will initialize the hardware and set default mode to be normal.    player.setPlayMode(PM_REPEAT_ONE); //set mode to repeat playing a song    player.playOne("1.aac");          //play a song with its name                 player1.begin();                      //will initialize the hardware and set default mode to be normal.    player1.setPlayMode(PM_REPEAT_ONE);    player1.playOne("2.aac");         player.digitalControlEnable();                        Serial.println("Let's DEMO");         } void loop() {                if(i%2==0)         {           player.play();           Serial.println("player play");           delay(5000);         }         else         {           player1.play();           Serial.println("player1 play");           delay(5000);         }       //////////bluetooth         while(BTSerial.available())         {             byte inByte = BTSerial.read();             a=inByte;                 }                 if(a=='g')         {              Serial.print("receive g message");              i++;              //delay(1000);         }         if(a=='t')         {              Serial.print("receive t message");              i++;              //delay(1000);         }               }

Question by 竣凱詹 


Making a gamepad with the HC05 bluetooth module.

Hi guys! this is my first post here at Instructables :D I really hope someone will be able to help me! Basically the problem is described in the attached image. To be short, we have: - 1x smartphone (Android) - 1x bluetooth module (HC05 with breakout board GW-040 4 pin SPI) - some buttons and arrows... I've already managed to get the HC05 recognized by Windows as a gamepad (modifying the tag using AT commands). The real problem is that i'm stuck with that. I would like to understand how i can connect some buttons (let's say four) that will actually behave like arrows while playing. As far as i understood i need to use the PIO pins but unfortunately my knowledge stops here. Theoretically the code behind this is simple: when the button is pressed the circuit is close and a signal is received by the HC05 who sends the corresponding command via bluetooth. So if the up arrow is pressed, that pin will receive 1 (closed circuit) and the HC05 will send "UP_Arrow" as an instruction to the smartphone. The problem is how do i write down this code and put it into the HC05? since the gamepad tag is "universal" i guess there is some default code for things like this. I think it's the same thing they did with the MOGA... I also read that i could need a SPI-USB Download (something like this ) to use the BlueSuite, that seems like the software needed for this operation. Thanks for any advice!! P.S.: Some useful links i found while searching.. http://dextersstory.tistory.com/3 http://dextersstory.tistory.com/10 http://dextersstory.tistory.com/11 http://dextersstory.tistory.com/16 http://www.martyncurrey.com/arduino-with-hc-05-bluetooth-module-at-mode/ https://developer.mbed.org/users/edodm85/notebook/HC-05-bluetooth/ https://www.sparkfun.com/datasheets/Wireless/Bluetooth/rn-42-ds.pdf http://cdn.sparkfun.com/datasheets/Wireless/Bluetooth/RN-HID-User-Guide-v1.0r.pdf http://ww1.microchip.com/downloads/en/DeviceDoc/bluetooth_cr_UG-v1.0r.pdf

Topic by HarryValenti   |  last reply


free energy!!!!!

Just take a look here http://www.youtube.com/watch?v=RkLfpXpO5sQ cant this be increased in number and make energy just have a look a scenario cant 12volt dc motor be driven with 5 such wheels with more strong magnets. motor http://www.google.com.pk/imgres?hl=en&client;=firefox-a&hs;=RKo&sa;=X&rls;=org.mozilla:en-US:official&biw;=1024&bih;=667&tbs;=isz:m&tbm;=isch&prmd;=imvns&tbnid;=cJRbQTZiqa21GM:&imgrefurl;=http://www.submarineboat.com/rov_joystick_for_props.htm&docid;=uxrFBCiE5M-zVM&imgurl;=http://www.submarineboat.com/images/rov/motor_dc.JPG&w;=500&h;=320&ei;=q55WUNjSDKr04QSZ6ID4Dg&zoom;=1&iact;=hc&vpx;=450&vpy;=191&dur;=3657&hovh;=180&hovw;=281&tx;=163&ty;=96&sig;=108762749557294498357&page;=1&tbnh;=120&tbnw;=187&start;=0&ndsp;=15&ved;=1t:429,r:2,s:0,i:77 what is expected

Topic by SARWAR_SARWAR   |  last reply


VU Meter Help?

I can only find an LM324 for a U meter. and the only schematic i could find was confusing....http://www.google.com/imgres?imgurl=http://www.zen22142.zen.co.uk/Circuits/Audio/Vumeter.gif&imgrefurl=http://www.acidmods.com/forum/index.php%3Ftopic%3D35382.0&usg=__JKJHEVkfZz92hhYo8rDxJaU9Roc=&h=401&w=407&sz=10&hl=en&start=0&zoom=1&tbnid=BowIq_ZQanGTBM:&tbnh=134&tbnw=138&prev=/images%3Fq%3Dlm324%2Bvu%2Bmeter%26um%3D1%26hl%3Den%26sa%3DN%26biw%3D1440%26bih%3D807%26tbs%3Disch:1&um=1&itbs=1&iact=hc&vpx=124&vpy=167&dur=818&hovh=223&hovw=226&tx=139&ty=123&ei=mrB9TLTbDYSClAffhOjrCw&oei=mrB9TLTbDYSClAffhOjrCw&esq=1&page=1&ndsp=28&ved=1t:429,r:0,s:0.....<br> So if someone could either explain that circuit or help me with a new one, I'd much appreciate it!<br> <br> THANKS!

Question by fretwreckef94   |  last reply


I'm thinking of selling my telescope of eBay, would you buy it? Answered

I'm selling an orion starblast 4.5" telescope: www.google.ca/imgres?imgurl=http://eridanusoptics.com/store/images//telescopes/eqmounted/OR9798.jpg&imgrefurl;=http://eridanusoptics.com/store/index.php%3Fmain_page%3Dproduct_info%26products_id%3D333&usg;=__fD6BTgmBfp6XqGZOFCZIjfwgw0o=&h;=500&w;=500&sz;=40&hl;=en&start;=0&zoom;=1&tbnid;=kScIj7bBieqngM:&tbnh;=149&tbnw;=149&prev;=/images%3Fq%3Dorion%2Bstarblast%2B4.5%26um%3D1%26hl%3Den%26client%3Dfirefox-a%26sa%3DN%26rls%3Dorg.mozilla:en-US:official%26biw%3D1280%26bih%3D768%26tbs%3Disch:1&um;=1&itbs;=1&iact;=hc&vpx;=347&vpy;=69&dur;=432&hovh;=225&hovw;=225&tx;=135&ty;=88&ei;=K5Z1TJiLOoOC8gb54r3yBQ&oei;=K5Z1TJiLOoOC8gb54r3yBQ&esq;=1&page;=1&ndsp;=25&ved;=1t:429,r:1,s:0 It also comes with a 25mm eyepiece and a 10mm eyepiece and also a x2 barlow lense. The price I am going for is $350, tell me if you would buy it or not.

Question by solarblade90   |  last reply


Momentary switch to Bluetooth

I'd like to make a number of smallish (say 0.75x1x2 inches) battery-powered Bluetooth boxes each of which connects to a momentary switch, and sends an RFCOMM or HID signal via Bluetooth on depression and another on release, and which will to communicate with an Android device. Because I want to make several of these, I want something super cheap and super simple to make.  (The purpose is to make a simple wireless touch detection system for foil and epee fencing. Without on-target detection, it's not going to be great, but it will be an improvement over refereeing fully dry bouts, since at least one will have proper impact and lockout timing.) Here are options I've been thinking about: 1. One thing that would *almost* do the job is to buy one of those $3-5 ebay Bluetooth phone camera remotes, and just wire my switch to it. The only problem is that according to the ads I've seen, these Bluetooth phone camera remotes go to sleep in 2-10 minutes when paired (exact timing seems to depend on the model), and I would really rather avoid this (the 10 minutes is almost acceptable). If anybody knows of a way of keeping them paired and awake for a longer period of time (say, 15 minutes or permanently), I would love to hear. This would be the cheapest and simplest solution, and it comes with a case and battery (some units are even USB chargeable).  2. On the other extreme of the price range, I happen to have some extra Brainlink modules with an atxmega and an RN-42 module inside, and it wouldn't take long to customize the firmware to do the job. But the modules sell for $39 (though sometimes on sale for $20), and that seems overkill for something so simple. And they are a touch larger than I like (about 3 inches diameter, and an awkward shape). 3. Another option might be to use a cheap serial Bluetooth module without additional hardware, and wire the switch directly to CTS. Unfortunately, I don't think the cheap HC-06 modules support CTS, though I think the HC-07 does support it (but I don't know if I can access it as it's probably not one of the pins on the header). Moreover, there are two unanswered questions on Stackexchange on how to access CTS/RTS status from Android, so this might require using a laptop as the base station (which isn't ideal). 4. A very cheap microcontroller with a UART (or just bit-banging) plus a cheap Bluetooth module. This increases the complexity of the project, but might be the way to go. More specific recommendations are welcome, as I have no experience with the hardware side of dealing with a microcontroller (on the software side, I've spent a fair amount of time tweaking the firmware of the Brainlink unit).

Topic by arpruss 


Turn my Raspberry Pi 0W into a bluetooth HID gamepad

Hello there ! I've been trying to get through this for weeks... many projects are quite similar but I have never found one that answers my problem. As the title says, I want to turn my Raspeberry Pi 0 W into a bluetooth HID gamepad. I figured out that another way is possible. Indeed you can create your own bluetooth HID device with either the Adafruit BlueFruit Ez-Key or a the RN-42 module (or even the HC-05 with the RN-42 firmware). But I want neither of these solutions. I want to use my Raspberry Pi 0 W in a way that it will be recognized as a bluetooth gamepad. Creating the gamepad is fine, I used the GPIO of the Pi for the inputs. But once the gamepad is physically done, how to make my Pi appear as a gamepad ? I've seen that you can use hciconfig in the terminal of Raspbian in order to change the class of the Pi and set it as a gamepad but I must admit that I didn't understand everything. And it's important that it appears as a gamepad and not as a keyboard. In a nutshell, I would like to turn my old wired nes controller in a bluetooth one, and play on another Pi where Recalbox is installed. (That's why you must appear as a gamepad and not as a keyboard, because Recalbox only works with bluetooth gamepads). Thank you in advance if someone takes his time to help me with this because I can't take it anymore haha ! 

Topic by frowngo 


new to arduino, want to run a dual display for 2 sensors

I'm new to the Arduino community.  wanting to set up a dual radar setup with 2 ultrasonic sensors,  (Ultrasonic Sensor Module HC-SR04), and outputting to a pair of 7 segment displays ( two 7 segment displays each).  I've found a code to do a single could use a lot of help to output two at the same time, basically 2 lanes without 2 units.  im using an arduino mega, ordered a unor3 and hopefully it can be made to run on one or the other. code is as follows: /* HC-SR04 Sensor    The circuit:     * VCC connection of the sensor attached to +5V     * GND connection of the sensor attached to ground     * TRIG connection of the sensor attached to digital pin 2     * ECHO connection of the sensor attached to digital pin 4  */    /*  This is a radar ping sensor that calcultates the speed of an  object traveling away or towards the sensor. I took some of this  code for the HC-SR04 Sensor implementation by Tautvidas Sipavicius. The rest  is original code from me. I know that the seven segment display  code is not the best to look at or the most optimized but it  serves its purpose just fine and is easy to understand.    Written by Matthew Ladd  */   const int trigPin = 2; const int echoPin = 4;   void setup() {   // initialize serial communication:   Serial.begin(9600);   //First 7 segment (ones place)   pinMode(30,OUTPUT);//F   pinMode(31,OUTPUT);//G   pinMode(32,OUTPUT);//E   pinMode(33,OUTPUT);//D   pinMode(34,OUTPUT);//C   pinMode(35,OUTPUT);//B   pinMode(36,OUTPUT);//A   //Second 7 segment (tens place)   pinMode(37,OUTPUT);//F   pinMode(38,OUTPUT);//G   pinMode(39,OUTPUT);//E   pinMode(40,OUTPUT);//D   pinMode(41,OUTPUT);//C   pinMode(42,OUTPUT);//B   pinMode(43,OUTPUT);//A } void zerofirst(){   digitalWrite(30,LOW);   digitalWrite(31,HIGH);   digitalWrite(32,LOW);   digitalWrite(33,LOW);   digitalWrite(34,LOW);   digitalWrite(35,LOW);   digitalWrite(36,LOW); } void onefirst(){   digitalWrite(30,HIGH);   digitalWrite(31,HIGH);   digitalWrite(32,HIGH);   digitalWrite(33,HIGH);   digitalWrite(34,LOW);   digitalWrite(35,LOW);   digitalWrite(36,HIGH); } void twofirst(){   digitalWrite(30,HIGH);//F   digitalWrite(31,LOW);//G   digitalWrite(32,LOW);//E   digitalWrite(33,LOW);//D   digitalWrite(34,HIGH);//C   digitalWrite(35,LOW);//B   digitalWrite(36,LOW);//A } void threefirst(){   digitalWrite(30,HIGH);//F   digitalWrite(31,LOW);//G   digitalWrite(32,HIGH);//E   digitalWrite(33,LOW);//D   digitalWrite(34,LOW);//C   digitalWrite(35,LOW);//B   digitalWrite(36,LOW);//A } void fourfirst(){   digitalWrite(30,LOW);//F   digitalWrite(31,LOW);//G   digitalWrite(32,HIGH);//E   digitalWrite(33,HIGH);//D   digitalWrite(34,LOW);//C   digitalWrite(35,LOW);//B   digitalWrite(36,HIGH);//A } void fivefirst(){   digitalWrite(30,LOW);//F   digitalWrite(31,LOW);//G   digitalWrite(32,HIGH);//E   digitalWrite(33,LOW);//D   digitalWrite(34,LOW);//C   digitalWrite(35,HIGH);//B   digitalWrite(36,LOW);//A } void sixfirst(){   digitalWrite(30,LOW);//F   digitalWrite(31,LOW);//G   digitalWrite(32,LOW);//E   digitalWrite(33,LOW);//D   digitalWrite(34,LOW);//C   digitalWrite(35,HIGH);//B   digitalWrite(36,LOW);//A } void sevenfirst(){   digitalWrite(30,HIGH);//F   digitalWrite(31,HIGH);//G   digitalWrite(32,HIGH);//E   digitalWrite(33,HIGH);//D   digitalWrite(34,LOW);//C   digitalWrite(35,LOW);//B   digitalWrite(36,LOW);//A } void eightfirst(){   digitalWrite(30,LOW);//F   digitalWrite(31,LOW);//G   digitalWrite(32,LOW);//E   digitalWrite(33,LOW);//D   digitalWrite(34,LOW);//C   digitalWrite(35,LOW);//B   digitalWrite(36,LOW);//A } void ninefirst(){   digitalWrite(30,LOW);//F   digitalWrite(31,LOW);//G   digitalWrite(32,HIGH);//E   digitalWrite(33,HIGH);//D   digitalWrite(34,LOW);//C   digitalWrite(35,LOW);//B   digitalWrite(36,LOW);//A } void zerosecond(){   digitalWrite(37,LOW);   digitalWrite(38,HIGH);   digitalWrite(39,LOW);   digitalWrite(40,LOW);   digitalWrite(41,LOW);   digitalWrite(42,LOW);   digitalWrite(43,LOW); } void onesecond(){   digitalWrite(37,HIGH);   digitalWrite(38,HIGH);   digitalWrite(39,HIGH);   digitalWrite(40,HIGH);   digitalWrite(41,LOW);   digitalWrite(42,LOW);   digitalWrite(43,HIGH); } void twosecond(){   digitalWrite(37,HIGH);//F   digitalWrite(38,LOW);//G   digitalWrite(39,LOW);//E   digitalWrite(40,LOW);//D   digitalWrite(41,HIGH);//C   digitalWrite(42,LOW);//B   digitalWrite(43,LOW);//A } void threesecond(){   digitalWrite(37,HIGH);//F   digitalWrite(38,LOW);//G   digitalWrite(39,HIGH);//E   digitalWrite(40,LOW);//D   digitalWrite(41,LOW);//C   digitalWrite(42,LOW);//B   digitalWrite(43,LOW);//A } void foursecond(){   digitalWrite(37,LOW);//F   digitalWrite(38,LOW);//G   digitalWrite(39,HIGH);//E   digitalWrite(40,HIGH);//D   digitalWrite(41,LOW);//C   digitalWrite(42,LOW);//B   digitalWrite(43,HIGH);//A } void fivesecond(){   digitalWrite(37,LOW);//F   digitalWrite(38,LOW);//G   digitalWrite(39,HIGH);//E   digitalWrite(40,LOW);//D   digitalWrite(41,LOW);//C   digitalWrite(42,HIGH);//B   digitalWrite(43,LOW);//A } void sixsecond(){   digitalWrite(37,LOW);//F   digitalWrite(38,LOW);//G   digitalWrite(39,LOW);//E   digitalWrite(40,LOW);//D   digitalWrite(41,LOW);//C   digitalWrite(42,HIGH);//B   digitalWrite(43,LOW);//A } void sevensecond(){   digitalWrite(37,HIGH);//F   digitalWrite(38,HIGH);//G   digitalWrite(39,HIGH);//E   digitalWrite(40,HIGH);//D   digitalWrite(41,LOW);//C   digitalWrite(42,LOW);//B   digitalWrite(43,LOW);//A } void eightsecond(){   digitalWrite(37,LOW);//F   digitalWrite(38,LOW);//G   digitalWrite(39,LOW);//E   digitalWrite(40,LOW);//D   digitalWrite(41,LOW);//C   digitalWrite(42,LOW);//B   digitalWrite(43,LOW);//A } void ninesecond(){   digitalWrite(37,LOW);//F   digitalWrite(38,LOW);//G   digitalWrite(39,HIGH);//E   digitalWrite(40,HIGH);//D   digitalWrite(41,LOW);//C   digitalWrite(42,LOW);//B   digitalWrite(43,LOW);//A } long distanceOverTime(long first,long second){  return ((first-second)/.1)*.0223693629;//taking cm/s to mph } long holder;//store the cm from last time through loop. long temp;//used to store the speed value after changes int counter; void loop() {   // establish variables for duration of the ping,   // and the distance result in inches and centimeters:   long duration, inches, cm;   int tens;   int ones;   long Speed;   // The sensor is triggered by a HIGH pulse of 10 or more microseconds.   // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:   pinMode(trigPin, OUTPUT);   digitalWrite(trigPin, LOW);   delayMicroseconds(2);   digitalWrite(trigPin, HIGH);   delayMicroseconds(10);   digitalWrite(trigPin, LOW);     // Read the signal from the sensor: a HIGH pulse whose   // duration is the time (in microseconds) from the sending   // of the ping to the reception of its echo off of an object.   pinMode(echoPin, INPUT);   duration = pulseIn(echoPin, HIGH);     // convert the time into a distance   inches = microsecondsToInches(duration);   cm = microsecondsToCentimeters(duration);   Speed=distanceOverTime(holder,cm);   holder=cm;//after speed caclulation so take the cm value for another calculation   Speed=abs(Speed);   if(Speed!=0 || counter==10){     temp=Speed;     counter=0;   }else{     counter++;   }   if(temp>=100){    zerofirst();    zerosecond();   }else{     ones=temp%10;     tens=temp/10;   }   if(ones == 0){     zerofirst();   }else if(ones==1){     onefirst();   }else if(ones==2){     twofirst();   }else if(ones==3){     threefirst();   }else if(ones==4){     fourfirst();   }else if(ones==5){     fivefirst();   }else if(ones==6){     sixfirst();   }else if(ones==7){     sevenfirst();   }else if(ones==8){     eightfirst();   }else if(ones==9){     ninefirst();   }   if(tens == 0){     zerosecond();   }else if(tens==1){     onesecond();   }else if(tens==2){     twosecond();   }else if(tens==3){     threesecond();   }else if(tens==4){     foursecond();   }else if(tens==5){     fivesecond();   }else if(tens==6){     sixsecond();   }else if(tens==7){     sevensecond();   }else if(tens==8){     eightsecond();   }else if(tens==9){     ninesecond();   }       Serial.print(inches);   Serial.print(" in, ");   Serial.print(cm);   Serial.print(" cm, ");   Serial.print(Speed);   Serial.print(" mph");   Serial.println();     delay(100); }   long microsecondsToInches(long microseconds) {   // According to Parallax's datasheet for the PING))), there are   // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per   // second).  This gives the distance travelled by the ping, outbound   // and return, so we divide by 2 to get the distance of the obstacle.   // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf   return microseconds / 74 / 2; }   long microsecondsToCentimeters(long microseconds) {   // The speed of sound is 340 m/s or 29 microseconds per centimeter.   // The ping travels out and back, so to find the distance of the   // object we take half of the distance travelled.   return microseconds / 29 / 2; } again, all your help and thought are appricated

Topic by herb1977   |  last reply


Automatic Irrigation using d1 mini

Hi Everyone, I reviewed different automatic irrigation system projects here in instructables and other sites as well and i decided to gather parts to do a simple small project myself. One thing that comes hard is the programming part as I don't know any programming language. I'm looking for some help with code merging, explanation and some general guidance. Could you please let me know, point me to right direction and tell me what you think and if requirements are actually achievable? What I would like to achieve: Intention of this project is to have manual and auto irrigation system which will: 1. Measure soil moisture and dependently on the value activate the usb pump which will water the plant (preferably analog output that will show the measurements in %) 2. Manual activating the pump via hardware button and via mobile phone with internet connection 3. Distance sensor which should measure how much water is left in the tank 4. Email notification with info when to water the plants and soil sensor data regardless of the automatic process that has already started 5. Email notification with info about the water in the tank when it’s near empty 6. Dashboard preferably inside the network (not using third party like blynk or others) with access from the internet (I have QNAP that I think can be used). 7. If possible – have amazon echo (Alexa) read the sensor data to tell me the values and comment if the plant should or shouldn’t be watered or the tank should be refiled or not as well as ability to ask Alexa to start or stop the irrigation Hardware: D1 mini: https://wiki.wemos.cc/products:d1:d1_mini Wemos V2 Relay shield: http://hobbycomponents.com/shields/865-wemos-v2-relay-shield My relay is slightly modified: 2 small wires soldered to the vcc and ground so that when it receives the signal on d1 pin it opens and current flows to female usb connector supposedly activating the usb water pump. All this can be stacked together even with soldered wires YL-69 sensor: http://www.oddwires.com/yl-69-soil-hygrometer-humidity-soil-moisture-detection-sensor/ Ultrasonic Distance Sensor (HC-SR04): https://thepihut.com/products/ultrasonic-distance-sensor-hcsr04 USB mini water pump: www.goo.gl/yUABDd Button x4 if needed: Board x4 if needed: sample codes used in other projects: https://randomnerdtutorials.com/guide-for-soil-moisture-sensor-yl-69-or-hl-69-with-the-arduino/ https://create.arduino.cc/projecthub/nekhbet/using-the-yl-39-yl-69-soil-humidity-sensor-with-arduino-968268 https://community.blynk.cc/t/irrigation-relay-with-timer-esp8266-wip/700 Alexa enabled homemade cat feeder example: https://www.hackster.io/darian-johnson/alexa-powered-automated-cat-feeder-9416d4 Thank you very much in advance for your help and support.

Topic by wube   |  last reply


Converting delay to millis.? need help !!!! Answered

/* * Hi Everyone.  I am just starting with Arduino uno. I was wondering if you could help me? I would like to replace "delay" with  "millis()"   My Project Out Line. *  "LED Light" On/Off with delay using "Relay Module" and "Bluetooth Hc-05" *   working fine with "delay sketch" but I cannot schedule 2 Events at the same time. *   So remodifing sketch using "Millis" *   original sketch link: https://docs.google.com/document/d/1GpPH8rG_bR2Vp282nv7kyB1Zwa0shtpDcAj3-_txnxE/pub   what will happen is when I send a command A to H the relay will be switched on and if I send a to h the relay will be switched off.   I have programmed it so that   A is relay one on (latched)   B is relay two on (latched)   C is relay one on for 30 Minutes   D is relay two on for 1 Hr   E is relay one on for 2 Hrs   F is relay two on for 5 Hrs   G is relay one on for 1 second, then relay two on then both off   H will switch relay one on and off for 1000 times   the relays switch on when the digital pin is grounded. and the relay switches off when the digital pin goes high   here is the code */ //========================================== // On and Off Times (as int, max=32secs) const unsigned int onTime = 1000; const unsigned int offTime = 500; // Tracks the last time event fired unsigned long previousMillis = 0; // Interval is how long we wait int interval = onTime; // Used to track if LED should be on or off boolean LED2state = true; //========================================== char val;         // variable to receive data from the serial port int ledpin = 2;  // LED connected to pin 2 (on-board LED) const int LED = 13; //  ####### Setup ####### void setup() {   pinMode(ledpin = 2, OUTPUT); // pin 2 (on-board LED) as OUTPUT   pinMode(ledpin = 3, OUTPUT); // pin 3 (on-board LED) as OUTPUT   Serial.begin(9600);       // start serial communication at 115200bps   pinMode(LED, OUTPUT); } //  ####### loop ####### void loop() {   if ( Serial.available() )      // if data is available to read   {     ;   }   val = Serial.read();         // read it and store it in 'val'   //  #####  Simple LED ON/OFF with out Delay #####   if ( val == 'a' )              // if 'a' was received led 2 is switched off   {     digitalWrite(ledpin = 2, HIGH);    // turn Off pin 2   }   if ( val == 'A' )              // if 'A' was received led 2 on   {     digitalWrite(ledpin = 2, LOW);  // turn ON pin 2   }   if ( val == 'b' )              // if 'b' was received led 3 is switched off   {     digitalWrite(ledpin = 3, HIGH);    // turn Off pin 3   }   if ( val == 'B' )              // if 'B' was received led 3 on   {     digitalWrite(ledpin = 3, LOW);  // turn ON pin 3   } //else (ledpin = 3, LOW)        //set led pin 3 to low state   // Need Help   //  #####  Simple LED ON/OFF with Delay using Millis #####   if ( val == 'C' )              // if 'C' was received led 2 on for 30 Minutes   {     digitalWrite(ledpin = 2, LOW);  // turn ON pin 2     // Grab snapshot of current time, this keeps all timing     // consistent, regardless of how much code is inside the next if-statement     unsigned long currentMillis = millis();     // Compare to previous capture to see if enough time has passed     ((unsigned long)(currentMillis - previousMillis) >= interval); {       // Change wait interval, based on current LED state       if (LED2state) {         // LED is currently on, set time to stay off         interval = offTime;       } else {         // LED is currently off, set time to stay on         interval = onTime;       }       // Toggle the LED's state, Fancy, eh!?       LED2state = !(LED2state);       // Save the current time to compare "later"       previousMillis = currentMillis;       // wait 30 Minutes       digitalWrite(ledpin, HIGH);      // turn Off pin 2     }   } } //Thanks in advance  //Krish

Question by bvamsikr   |  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