Hi all..
i just started with Arduino about a month ago and learned a lot about it since then.
I know how to set up a simple sketch and how to modify sketches found online. Now i am implenting Arduino into my car to monitor some temperatures with several DS18B20. Assigned on a single bus and hardcoded the addresses to its functions. All good.. read out through bluetooth with MIT created app. That is one sketch.
Now i made another app with MIT to control things like door lock and unlock, controlling hood latch and trunk an so forth.. also through bluetooth with it's own sketch.
Now the problem lies in combining both sketches to one and hoping someone would take a look at it:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(11,12);
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Addresses of 6 DS18B20s
uint8_t sensor1[8] = { 0x28, 0x67, 0xF4, 0x0D, 0x00, 0x00, 0x00, 0x7C };
uint8_t sensor2[8] = { 0x28, 0x1E, 0x4D, 0x0F, 0x00, 0x00, 0x00, 0xC9 };
uint8_t sensor3[8] = { 0x28, 0xFF, 0xB8, 0x0F, 0x00, 0x00, 0x00, 0xA3 };
uint8_t sensor4[8] = { 0x28, 0xFA, 0x46, 0x0B, 0x00, 0x00, 0x00, 0x42 };
uint8_t sensor5[8] = { 0x28, 0x09, 0xD9, 0x0A, 0x00, 0x00, 0x00, 0x3E };
uint8_t sensor6[8] = { 0x28, 0x98, 0x15, 0x49, 0x0C, 0x00, 0x00, 0x68 };
void setup(void)
{
Serial.begin(9600);
sensors.begin();
mySerial.begin(9600);
}
void loop(void)
{
int i;
if (mySerial.available())
{
i=mySerial.read();
Serial.println("DATA RECEIVED:");
if(i=='1')
{
Serial.println("Running Aux 3");
digitalWrite(3, HIGH);
delay(500);
digitalWrite(3, LOW);
delay(100);
}
if(i=='2')
{
Serial.println("Running Aux 4");
digitalWrite(4, HIGH);
delay(500);
digitalWrite(4, LOW);
delay(100);
}
if(i=='3')
{
Serial.println("Running Aux 5");
digitalWrite(5, HIGH);
delay(500);
digitalWrite(5, LOW);
delay(100);
}
if(i=='4')
{
Serial.println("Running Aux 6");
digitalWrite(6, HIGH);
delay(500);
digitalWrite(6, LOW);
delay(100);
}
if(i=='5')
{
Serial.println("Running Aux 7");
digitalWrite(7, HIGH);
delay(500);
digitalWrite(7, LOW);
delay(100);
}
if(i=='6')
{
Serial.println("Running Aux 8");
digitalWrite(8, HIGH);
delay(500);
digitalWrite(8, LOW);
delay(100);
}
if(i=='7')
{
Serial.println("Running Aux 9");
digitalWrite(9, HIGH);
delay(500);
digitalWrite(9, LOW);
delay(100);
}
if(i=='8')
{
Serial.println("Running Aux 10");
digitalWrite(10, HIGH);
delay(500);
digitalWrite(10, LOW);
delay(100);
}
}
{
sensors.requestTemperatures();
printTemperature(sensor1);
printTemperature(sensor2);
printTemperature(sensor3);
printTemperature(sensor4);
printTemperature(sensor5);
printTemperature(sensor6);
Serial.println();
delay(500);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
Serial.print(tempC, 1);
Serial.print("|");
}
}
keep getting: 'printTemperature' was not declared in this scope