Hi again,
At first I followed the guide from sparkfun so I used their code. However, as I mentioned in the first part (enter configuration and edit name) everything works fine. I cannot work in the second part (Hello Arduino! etc.).
I also tried using the code I created for the project, which is the following:
//Motor
#include <Servo.h>
//Thermometer
#include <OneWire.h>
//Motor
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
//Thermometer
int DS18S20_Pin = 12; //DS18S20 Signal pin on digital 2
// Pressure Sensor
int FSR_Pin = A0; //analog pin 0
//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 2
void setup()
{
//Motor
myservo.attach(9); // attaches the servo on pin 9 to the servo object
// initialize serial:
Serial.begin(9600);
//Thermistor
Serial.println("Thermistor temperature measurement:");
Serial.println("\n Vo Rt T (C)");
}
void loop()
{
while (Serial.available()) {
char inChar = (char)Serial.read();
switch(inChar) {
case 'u':
for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15);
}
break;
case 't2':
{int ThermistorPin = 1; // Analog input pin for thermistor voltage
int Vo; // Integer value of voltage reading
float R = 9870.0; // Fixed resistance in the voltage divider
float logRt,Rt,T;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
Vo = analogRead(ThermistorPin);
Rt = R*( 1023.0 / (float)Vo - 1.0 );
logRt = log(Rt);
T = ( 1.0 / (c1 + c2logRt + c3logRtlogRtlogRt ) ) - 273.15;
Serial.print(" "); Serial.print(Vo);
Serial.print(" "); Serial.print(Rt);
Serial.print(" "); Serial.println(T);
delay(200);
}
break;
case 'd':
for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
break;
case 'p':
{
int FSRReading = analogRead(FSR_Pin);
Serial.println(FSRReading);
delay(250); //just here to slow down the output for easier reading
}
break;
case 't':
float temperature = getTemp();
Serial.println(temperature);
delay(100); //just here to slow down the output so it is easier to read
break;
}
Serial.println(inChar);
}
}
//returns the temperature from one DS18S20 in DEG Celsius
float getTemp(){
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;
}
if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1000;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for (int i = 0; i < 9; i++) { // we need 9 bytes
data = ds.read();
}
I connect with the Bluetooth from a Mac through CoolTerm and when I send commands (e.g. u,d, etc) the TX light of Coolterm lights up, but it does not receive anything (the RX light does not light).
I also tried using only the pre-maid arduino code for a servo motor but the same problem occurs.
Spiros