Go Down

### Topic: Esplora problems (Read 16354 times)previous topic - next topic

#### moussaprince

##### Nov 07, 2013, 06:32 pm
Hello, I just bought a new esplora, everything works fine except 2 stuff:

-The temperature sensor always give "-50" in degrees with this simple script:
/*
Esplora Temperature Sensor

This  sketch shows you how to read the Esplora's temperature sensor
You can read the temperature sensor in Farhenheit or Celsius.

Created on 22 Dec 2012
by Tom Igoe

This example is in the public domain.
*/
#include <Esplora.h>

void setup()
{
Serial.begin(9600);      // initialize serial communications with your computer
}

void loop()
{
// read the temperature sensor in Celsius, then Fahrenheit:

// print the results:
Serial.print("Temperature is: ");
Serial.print(celsius);
Serial.print(" degrees Celsius, or ");
Serial.print(fahrenheit);
Serial.println(" degrees Fahrenheit.");
Serial.println("     Fahrenheit = (9/5 * Celsius) + 32");

// wait a second before reading again:
delay(1000);
}

-The joystick (when i use the mouse example) works but always goes right

#### einzig

#1
##### Nov 14, 2013, 07:28 am
For the Joystick going right try this

the code below is to read the data from the joysticks x axis

-----------------------------------------
#include <Esplora.h>
#include <SPI.h>

void setup() {

Serial.begin(9600);

}

void loop()
{

Serial.println(xAxis);

}
--------------------------------------------------------------------------

i tried it on 2 esploras
the one that worked fine with the example was giving me a 10 read on stand by
while the one movin to the right was giving me -12 on stand by

so just changed the values from the code in the example EsploraTFTEtchASketch on the loop

if (xAxis<13 && xAxis>-13){
xPos=xPos;

#### moussaprince

#2
##### Nov 14, 2013, 08:08 pm
Thanks for ur answer, I understood what the problem was:) so the joystick problem is now solved:
PS: I found a nice mouse woking sketch in the net:

/*
Esplora Calibrated Joystick Mouse

WARNING: this sketch will take over your mouse movement. If you lose control
of your mouse do the following:
1) unplug the Esplora.
3) hold the reset button down while plugging your Esplora back in
4) while holding reset, click "Upload"
5) when you see the message "Done compiling", release the reset button.

that doesn't take control of the mouse.

Instructions:

Made by Michael on 16 May 2013
*/

#include <Esplora.h>

int JoyX;                                        // These Variables are global
int JoyY;
int activate = 0;

void setup()
{
Esplora.writeRGB(0, 0, 10);                   // Signal Esplora is waiting to calibrate
while(start == HIGH) {                         // Wait until button is pressed
}
JoyX = Esplora.readJoystickX();                // Set drift variable X
JoyY = Esplora.readJoystickY();                // Set drift variable Y
Esplora.writeRGB(10, 0, 0);                   // Calibration is done, waiting to run
}

void loop()
{
xValue = xValue - JoyX;                        // Remove drift on X position
yValue = yValue - JoyY;                        // Remove drift on Y position

int mousespeed = map(slide, 0, 1023, 10, 0);                  // Max Mouse Speed is Calculated from slider
int mouseX = map( xValue,-512, 512, mousespeed, -mousespeed);  // map the X value to a range of movement for the mouse X, Changes input range to include new values
int mouseY = map( yValue,-512, 512, -mousespeed, mousespeed);  // map the Y value to a range of movement for the mouse Y, Changes input range to include new values

if(button3 == LOW){                          // Check if the Enable/Disable button is pressed
if(activate == 1) activate = 0;
else activate = 1;
delay(500);
}

if(activate == 1){                               // Check if mouse is enabled

Esplora.writeRGB(0 , 10, 0 );                 // Set light to green
Mouse.begin();                                 // take control of the mouse

if(JoyButton == LOW || button2 == LOW) Mouse.press(MOUSE_LEFT);       // Test if Left click is activated
else Mouse.release(MOUSE_LEFT);

if(button1 == LOW) Mouse.press(MOUSE_MIDDLE);                             // Middle Button
else Mouse.release(MOUSE_MIDDLE);

if(button4 == LOW)  Mouse.press(MOUSE_RIGHT);      // Right Button
else Mouse.release(MOUSE_RIGHT);

Mouse.move(mouseX, mouseY, 0);                 // move the mouse

}

else {
Mouse.end();
Esplora.writeRGB(255, 0, 0 );
}

delay(10);                                  // a short delay before moving again

}

But I still have the temperature sensor problem:( how to solve it?

#### einzig

#3
##### Nov 15, 2013, 07:19 pm
it nicely work, changed the speed of it since it was to slow

is the flat side of your sensor facing you?

#### moussaprince

#4
##### Nov 16, 2013, 07:45 am
-Yh you can change the mouse speed with the linear potentiometer

- Yep the temperature sensor is facing me like in that pic: http://farm9.staticflickr.com/8044/8134573901_63952a4f17.jpg

And when I do: