ds18b20 temperature sensor and arduino

I am currently writing this simple code to check the temp sensor
[code]#include <One Wire . h> int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2 //Temperature chip i/o OneWire ds(DS18S20_Pin); // on digital pin 2 void setup(void) { Serial.begin(9600); } void loop(void) { float temperature = getTemp(); Serial.println(temperature); delay(100); //just here to slow down the output so it is easier to read }[/code] I m getting "sketch_feb27a:14: error: 'getTemp' was not declared in this scope"
can someone tell me why?

Help with Multiple Ultrasonic Sensors

Hi guys,

I'm trying to create a robot using three HC-SR04 ultrasonic sensors and my Arduino Pro Mini but I've run into a few problems. In short the robot's function is as follows:

1. The robot is dual wheeled, with an H-bridge (SN754410) driving each wheel.
2. There's one HC-SR04 sensor on each side of the robot, the left one activates the left wheel motor when it detects a hand in front of it, vice versa for the right side.

i.e. To make the robot go forward, we place our hands near the left and right side of the robot, to make it turn right, we remove the right hand and keep the left one in place, vice versa for turning left, etc.

3. A third HC-SR04 is located the top of the robot, such that it activates a third motor when the user's hand is hovering above the robot.

My test code is as follows:
[code] #include <NewPing.h> #define SONAR_NUM 3 // Number of sensors. #define MAX_DISTANCE 20 // Maximum distance (in cm) to ping. NewPing sonar[SONAR_NUM] = { // Sensor object array. NewPing(4, 5, MAX_DISTANCE), // Each sensor's trigger pin, echo pin, and max distance to ping. NewPing(6, 7, MAX_DISTANCE), NewPing(8, 9, MAX_DISTANCE) }; #define ena1 10 //trigger for left motor H-bridge //#define ena2 11 //trigger for right motor //#define ena3 12 //for top motor long sensors[3]; //array to store sensor distances void setup() { Serial.begin (115200); pinMode(ena1, OUTPUT); //pinMode(ena2, OUTPUT); //pinMode(ena3, OUTPUT); } void loop() { for (uint8_t i = 0; i < SONAR_NUM; i++) { // Loop through each sensor and display results. delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings. sensors[i] = sonar[i].ping_cm(); } Serial.println(sensors[0]); if (sensors[0] > 0 && sensors[0] <= 20){ Serial.println("detected"); digitalWrite(ena1, HIGH); }else{ Serial.println("NA"); digitalWrite(ena1,LOW); } }[/code] As you can see, I'm using the NewPing.h library to collect the sensor data. After each iteration of the for loop, the distances detected by the sensors are stored in a sensor array. When a hand is placed about 15-20 cm away from a sensor, the arduino sends a digital "HIGH" trigger signal to the respective H-bridge, activating the respective motor (I only have one of these pins, "ena1", enabled in my code, the other two are commented for the test).

To test my code, I simply connected the H-bridge trigger pin "ena1" to an LED, this pin is activated by the sensor whose distance data is stored in variable "sensors[0]". However, after I compile and upload my code, I notice that the LED simply flickers faintly as I put my hand in front of the sensor. As if the LED is being turned on and off very fast.

The output from the serial monitor is as follows:
[code]15 detected 0 NA 16 detected 0 NA 14 detected 0 NA[/code] As you can see, by putting my hand about ~15cm in front of the sensor, the sensor returns the correct distance and the "ena1" pin is set to high (as evidenced by "detected" being printed to the screen).

However, the sensor always returns a "0" value at the next iteration of the main loop (while my hand is still in front of the sensor), subsequently setting the "ena1" pin to LOW again, which might explain why the LED is being turned on and off so fast.

I'm not sure why this is happening... Interestingly, by removing the digitalWrite lines from the code, the sensor returns the correct values (i.e. no "0" value when my hand is in front of the sensor).

Any ideas on how I can fix this?

Thanks in advance!

Driving two Ultrasonic sensor with Arduino

everyone. I've got a problem while I try to use Arduino uno to drive two HC-SR04 ultrasonic sensor. While a try to display two measured value from each sensor, one of them work fine but the other displays value 0.
[code]int trigPin=12; // this pin work as the output of the two trig pin of the two sensor int echoPin1=8; int echoPin2=13; void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin1, INPUT); pinMode(echoPin2, INPUT); } void loop() { float duration1, distance1, duration2, distance2; digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); //trig:10 microsecond TTL pulse duration1 = pulseIn(echoPin1, HIGH); duration2 = pulseIn(echoPin2, HIGH); distance1 = duration1/2/29.1; distance2 = duration2/2/29.1; Serial.print(distance1); Serial.print(','); Serial.println(distance2); delay(20); }[/code] The situation is that on the Serial Monitor, "distance1" shows correct value however "distance2" is always 0.

I've found that while "duration1" and "duration2" exchange their order(which means duration2 runs first, then duration1 runs.), the result becomes that distance1 shows 0 but distance2 shows correct value.

It seems there are some problems while I using the function "pulseIn", is that right?

Could anyone help me fix this problem, thanks!

Ultrasonic Sensor Library for Proteus

Can anyone help me.I want to simulate my project(obstacle avoidance robot using ultrasonic sensor) on proteus isis v7.6 but i dont know where to find ultrasonic sensor on this platform.Some sites says i have to add the sensor's library,but i just can figure this out!!!

I don't get ladder logic.

I have done some machine language programming and some of the other higher
level programming. I think I have a good understanding of how computers work. Does a
ladder logic symbol relate to a specific routine in the PLC?

I have a PLC I am trying to learn to programm and ladder logic is not making a lot
of sense. I hope some one here can point me in a direction of a good tutorial, a book
or a web site.

How do I get started with C-more///CLICK integration?

Hi,

I am a PLC 'noob' trying to teach myself how to set up the Click PLC and associated hardware.

Thanks for your help!

Matlab internal rate of return

You'll have to be easy on me, I am new to matlab and SO. I am having an issue using the matlab solver to calculate internal rate of return(IRR). I saw that the financial toolbox in matlab had a function for this, however I don't believe I have it installed and did not want to get the trial version on their site.

Given the simple nature of my particular IRR calculation, I figured it would be easy enough to simply code in matlab. It is the same yearly cashflow, so what I put into matlab was as follows:
[code]syms x k; IRR = solve(investment == yrSavings* symsum((1+x)^-k,1, nYears));[/code] It doesn't fail, and in fact gives a number. The only problem is the the result is incorrect! I type in the IRR manually and it never equals the investment. Using wolframalpha I found the actual solution, went back and manually typed in wolframalpha's answer, and the symsum function returned the correct result. I'm not sure what's up with the solver!

How can I use the Arduino platform with Proteus ISIS?

How can I use the Arduino platform with Proteus ISIS need details please guide me because I'm the newbie

Adding arduino library in Proteus 8

I dont have library folder, when i install proteus 8. Where do i add arduino library. At internet solution for proteus 7 is given but when i installed proteus 8 it does not have library folder.

Making an animated relay in proteus

Hi all,
I am trying to make an animated relay work to switch on the bulb in my circuit. When a input is given to the pic16f877A, it is to make the relay on the bulb. I have fixed everything correctly( according to me...). But i can't make the relay work when i execute (F12). The lcd included works well though. Pls help. I will include the coding and the picture of the circuit. Also what do the blue and red square lights that appear in the proteus simulation.
Pls do help me.
Thanks
S.Trinetra

p.s
relay is set to 5V. It is still not working.
Do u notice the power terminal connected to one part of the relay and diode. Must have a certain value? I can't seem to insert any value.
Do u think that there is something wrong with the code in Mplab?
Must ac source and bulb be connected to the transistor and ground?
[code] #include<htc.h> #include <pic.h> __CONFIG ( 0x3F32 ); #define data PORTD //Pins to the LCD D0-D7 #define rs RC2 //rs of LCD #define rw RC0 //rw of LCD #define en RC3 //e of LCD #define in RE0 //input for RFID // The above pins can be changed according to whicheva u choose void initialize(); void busy(); void display(unsigned char one[], unsigned char two[]); void command(unsigned char var); void send_data(unsigned char var); void string(unsigned char *var); unsigned char text1[]={"RFID PROJECT"}; unsigned char text2[]={"PLACE YOUR CARD"}; unsigned char text3[]={"CARD ACCEPTED"}; unsigned char text4[]={"CARD REJECTED"}; unsigned char text5[]={" "}; //Additional text can be placed above. and can be called according to how //u the calling in the code void main(void) { int i, d; ADCON1 = 0x06; TRISC=0x00; TRISD=0X00; TRISE=0x01; initialize(); display(text1, text2); while(1) { if (in==1) { RC1=1; display(text3, text5); busy(); } else { RC1=0; display(text4, text5); busy(); } } } void initialize() { data=0x38; rs=0; rw=0; en=1; en=0; busy(); data=0x0E; rs=0; rw=0; en=1; en=0; busy(); data=0x01; rs=0; rw=0; en=1; en=0; busy(); data=0x06; rs=0; rw=0; en=1; en=0; busy(); } void busy() { unsigned char i,j; for(i=0;i<50;i++) for(j=0;j<255;j++); } void command(unsigned char var) { data=var; rs=0; rw=0; en=1; en=0;busy(); } void send_data(unsigned char var) { rs=1;rw=0; en=1; data=var; en=0; busy(); } void string(unsigned char *var) { while(*var) send_data(*var++); } void display(unsigned char one[], unsigned char two[]) { command(0x80); string(one); command(0xC0); string(two); busy(); } [/code]
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir