Pages: [1]   Go Down
Author Topic: Esplora problems  (Read 13195 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
  int celsius = Esplora.readTemperature(DEGREES_C);
  int fahrenheit = Esplora.readTemperature(DEGREES_F);

  // 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
Logged

Mexico
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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()
{

  int xAxis = Esplora.readJoystickX();    // read the X axis
 
  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;
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
 2) open the EsploraBlink sketch
 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.
 
 This will stop your Esplora from controlling your mouse while you upload a sketch
 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
  int start = Esplora.readButton(SWITCH_3);      // Read First Button
  while(start == HIGH) {                         // Wait until button is pressed
    start = Esplora.readButton(SWITCH_3);
  }
  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()
{
  int xValue = Esplora.readJoystickX();          // read the joystick's X position
  int yValue = Esplora.readJoystickY();          // read the joystick's Y position
  xValue = xValue - JoyX;                        // Remove drift on X position
  yValue = yValue - JoyY;                        // Remove drift on Y position
  int JoyButton = Esplora.readJoystickButton();
  int button1 = Esplora.readButton(SWITCH_1);    // Read Buttons
  int button2 = Esplora.readButton(SWITCH_2);    // Read Buttons
  int button3 = Esplora.readButton(SWITCH_3);    // Read Buttons
  int button4 = Esplora.readButton(SWITCH_4);    // Read Buttons
  int slide = Esplora.readSlider();              // Read Slider Values

  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?


Logged

Mexico
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

it nicely work, changed the speed of it since it was to slow

is the flat side of your sensor facing you?
 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

-Yh you can change the mouse speed with the linear potentiometer smiley-wink

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

And when I do:

Serial.println(Esplora.readTemperature(DEGREES_C));

I get:

-50
-50
-50
-50
... etc all the time
Logged

Pages: [1]   Go Up
Jump to: