Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Velosats
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Velosats

by adafruit_support_bill on Mon Jul 27, 2020 2:04 pm

Connect SDO on the LIS3DH board to 3Vo on the LIS3DH board.

adafruit_support_bill
 
Posts: 78979
Joined: Sat Feb 07, 2009 10:11 am

Re: Velosats

by animefruit on Mon Jul 27, 2020 2:24 pm

You mean like in this picture. So I connected SDO on the accelerometer to one of my rows on my breadboard that is connected to GND on my Arduino like you said before. How is that supposed to work? Would I just connect GND on my breadboard to 3vo on the accelerometer?

animefruit
 
Posts: 169
Joined: Tue Feb 25, 2020 1:04 pm

Re: Velosats

by animefruit on Mon Jul 27, 2020 2:27 pm

Here is my picture of what I think you are saying
Attachments
3D409067-A252-413F-80A5-2D04013DA0C4.jpeg
3D409067-A252-413F-80A5-2D04013DA0C4.jpeg (89.31 KiB) Viewed 27 times
4893CBFD-6226-4F0E-AAB7-4C6213337D9A.jpeg
4893CBFD-6226-4F0E-AAB7-4C6213337D9A.jpeg (89.31 KiB) Viewed 27 times
EDBC7A45-76A8-48E1-A5A2-48C636F91833.jpeg
EDBC7A45-76A8-48E1-A5A2-48C636F91833.jpeg (992.02 KiB) Viewed 27 times

animefruit
 
Posts: 169
Joined: Tue Feb 25, 2020 1:04 pm

Re: Velosats

by adafruit_support_bill on Mon Jul 27, 2020 3:00 pm

Yes, like your drawing.

adafruit_support_bill
 
Posts: 78979
Joined: Sat Feb 07, 2009 10:11 am

Re: Velosats

by animefruit on Mon Jul 27, 2020 3:11 pm

But I have to connect SDO to GND. So like this?
Attachments
EAEDBDFE-4993-4D5A-8794-FB19ACB4E525.jpeg
EAEDBDFE-4993-4D5A-8794-FB19ACB4E525.jpeg (168.63 KiB) Viewed 25 times

animefruit
 
Posts: 169
Joined: Tue Feb 25, 2020 1:04 pm

Re: Velosats

by adafruit_support_bill on Mon Jul 27, 2020 3:38 pm

No. If you connect it to GND it will be at 0x18. For 0x19, you need to connect it to 3Vo.

https://learn.adafruit.com/adafruit-lis ... -2960986-4

SDO - When in I2C mode, this pin can be used for address selection. When connected to GND or left open, the address is 0x18 - it can also be connected to 3.3V to set the address to 0x19

adafruit_support_bill
 
Posts: 78979
Joined: Sat Feb 07, 2009 10:11 am

Re: Velosats

by animefruit on Mon Jul 27, 2020 4:09 pm

You said it could also connect it to 3.3v to set it to 0x19. Could I connect it to 3.3v on the Arduino to do the same thing as connecting it to 3vo on the accelerometer?

animefruit
 
Posts: 169
Joined: Tue Feb 25, 2020 1:04 pm

Re: Velosats

by adafruit_support_bill on Mon Jul 27, 2020 4:23 pm

Yes you could. But long wires can pick up noise. It is better to just connect it to the 3V0 on the board.

adafruit_support_bill
 
Posts: 78979
Joined: Sat Feb 07, 2009 10:11 am

Re: Velosats

by animefruit on Mon Jul 27, 2020 11:25 pm

I connected it to 3.3 v on the Arduino. The 12c scanner says that there it found a 0x19 device. But when I put in my code that I did it says it couldn’t start b. What should I do?

animefruit
 
Posts: 169
Joined: Tue Feb 25, 2020 1:04 pm

Re: Velosats

by adafruit_support_bill on Tue Jul 28, 2020 7:21 am

The problem is most likely due to the wiring. i2c is designed for short distances. It is possible to get it to work up to a few feet, but you need to be very careful with your wiring.

First make sure that your wires are no longer than they really need to be. The total length including both sensors should not be more than 2 or 3 feet.

Next, you should use good quality twisted pair wires for each of the signals. This will help eliminate interference. CAT-5 ethernet cable works well for that. A CAT-5 cable has 4 twisted pairs.

Use one twisted pair for GND and SDA.
Use another twisted pair for GND and SCL.
Use a third twisted pair for GND and VIN.

adafruit_support_bill
 
Posts: 78979
Joined: Sat Feb 07, 2009 10:11 am

Re: Velosats

by animefruit on Tue Jul 28, 2020 11:20 pm

So the total length of all wires should not be more than 2-3 feet. So does that include the wires that arn't connected to anything. As you can see in some of my pictures, there is just some wires that are just hanging around doing nothing on my breadboard. Do those count? And are you sure my problem is because of my wiring. Because I put this on code with the 0x18 adress before than, and it worked perfectly fine with the other accelrometer connected too. So I would think that would mean it is a problem with the SDO connection. But when I soldered the SDO on the accelrometer to the 3vo on the accelrometer with a really small wire, it still didn't work o my actual code, although it did work on the 12c scanner again, which is good. But what do you think about my problem now that I told you that it workd perfectly with 0x18?

Just in case you think it is a code problem, here is my code:

Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LIS3DH.h>
#include <Adafruit_Sensor.h>
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3,POSITIVE);

// Used for software SPI
#define LIS3DH_CLK 13
#define LIS3DH_MISO 12
#define LIS3DH_MOSI 11
// Used for hardware & software SPI
#define LIS3DH_CS 10

// software SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS, LIS3DH_MOSI, LIS3DH_MISO, LIS3DH_CLK);
// hardware SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS);
// I2C
//Adafruit_LIS3DH lis_A = Adafruit_LIS3DH();
Adafruit_LIS3DH lis_B = Adafruit_LIS3DH(0x19);
Servo myservo;
int health=5000;
//int reading;
int reading2;
int pos;


void setup(void) {

  lcd.begin (16 ,2);
  lcd.clear();
 
  Serial.begin(9600);
 
   myservo.attach(9); //servo at digital pin 9
 myservo.write(0); //initial point for servo
 
  while (!Serial) delay(10);     // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("LIS3DH test!");

 //if (! lis_A.begin(0x18)) {   // change this to 0x19 for alternative i2c address
    //Serial.println("Couldnt start A");
   //while (1) yield();
 // }

  if (! lis_B.begin(0x19)) {   // change this to 0x19 for alternative i2c address
    Serial.println("Couldnt start B");
    while (1) yield();
  }
  Serial.println("LIS3DH found!");

   //lis_A.setRange(LIS3DH_RANGE_4_G);   // 2, 4, 8 or 16 G!
   lis_B.setRange(LIS3DH_RANGE_4_G);
  //Serial.print("Range = "); Serial.print(2 << lis_A.getRange());
  Serial.print("Range = "); Serial.print(2 << lis_B.getRange());
  Serial.println("G");

  // lis.setDataRate(LIS3DH_DATARATE_50_HZ);
 /* Serial.print("Data rate set to: ");
  switch (lis_A.getDataRate()) {
    case LIS3DH_DATARATE_1_HZ: Serial.println("1 Hz"); break;
    case LIS3DH_DATARATE_10_HZ: Serial.println("10 Hz"); break;
    case LIS3DH_DATARATE_25_HZ: Serial.println("25 Hz"); break;
    case LIS3DH_DATARATE_50_HZ: Serial.println("50 Hz"); break;
    case LIS3DH_DATARATE_100_HZ: Serial.println("100 Hz"); break;
    case LIS3DH_DATARATE_200_HZ: Serial.println("200 Hz"); break;
    case LIS3DH_DATARATE_400_HZ: Serial.println("400 Hz"); break;

    case LIS3DH_DATARATE_POWERDOWN: Serial.println("Powered Down"); break;
    case LIS3DH_DATARATE_LOWPOWER_5KHZ: Serial.println("5 Khz Low Power"); break;
    case LIS3DH_DATARATE_LOWPOWER_1K6HZ: Serial.println("16 Khz Low Power"); break;
*/

    switch (lis_B.getDataRate()) {
    case LIS3DH_DATARATE_1_HZ: Serial.println("1 Hz"); break;
    case LIS3DH_DATARATE_10_HZ: Serial.println("10 Hz"); break;
    case LIS3DH_DATARATE_25_HZ: Serial.println("25 Hz"); break;
    case LIS3DH_DATARATE_50_HZ: Serial.println("50 Hz"); break;
    case LIS3DH_DATARATE_100_HZ: Serial.println("100 Hz"); break;
    case LIS3DH_DATARATE_200_HZ: Serial.println("200 Hz"); break;
    case LIS3DH_DATARATE_400_HZ: Serial.println("400 Hz"); break;

    case LIS3DH_DATARATE_POWERDOWN: Serial.println("Powered Down"); break;
    case LIS3DH_DATARATE_LOWPOWER_5KHZ: Serial.println("5 Khz Low Power"); break;
    case LIS3DH_DATARATE_LOWPOWER_1K6HZ: Serial.println("16 Khz Low Power"); break;
  }
}
//}


void loop() {
  do
  {

   myservo.detach();
  //reading = lis_A.y;
  reading2 = lis_B.y;

/*if (reading < -800 ){
  reading=0;
}

 if(reading > -800){
  Serial.println(reading);
  lcd.println(reading);
 }
*/
if (reading2 < -800 ){
  reading2 =0;
}

 if(reading2 > -800){
  Serial.println(reading2);
  lcd.println(reading2);
 }

 
 
   
 /* lis_A.read();      // get X Y and Z data at once
  // Then print out the raw data
  //Serial.print("X:  "); Serial.print(lis.x);
Serial.print("  \tY:  ");Serial.print(lis_A.y);
  //Serial.print("  \tZ:  "); Serial.print(lis.z);
*/

 lis_B.read();      // get X Y and Z data at once
  // Then print out the raw data
  //Serial.print("X:  "); Serial.print(lis_B.x);
Serial.print("  \tY:  ");Serial.print(lis_B.y);
  //Serial.print("  \tZ:  "); Serial.print(lis_B.z);

  /* Or....get a new sensor event, normalized */
  sensors_event_t event;
  //lis_A.getEvent(&event);
  lis_B.getEvent(&event);

  /* Display the results (acceleration is measured in m/s^2) */
  //Serial.print("\t\tX: "); Serial.print(event.acceleration.x);
  //Serial.print(" \tY: "); Serial.print(event.acceleration.y);
  //Serial.print(" \tZ: "); Serial.print(event.acceleration.z);
  //Serial.println(" m/s^2 ");
//float totalAcceleration = sqrt((event.acceleration.x * event.acceleration.x) + (event.acceleration.y * event.acceleration.y) + (event.acceleration.z * event.acceleration.z));
  //Serial.println();
    //reading = analogRead(A4 & A5);
   
    Serial.print("Sensor Value=");
    //reading - 100;
    //health=health-reading;
    health=health-reading2;
    Serial.println(health);
    lcd.println(health);



     
   // if ( health< 10000){
  //delay(600);
//}

  delay(600);


} while(health>1);
myservo.attach(9);
//myservo2.attach(11);
  // attaches the servo on pin 9 to the servo object
  delay(15);
  myservo.write(1);
 // myservo2.write(1);
  // sets the servo position according to the scaled value
  delay(1000);
  // waits for it to get to the position
  myservo.detach();
 // myservo2.detach();
  delay(6000);//how long it pauses
  myservo.attach(9);
  //myservo2.attach(11);
  // attaches the servo on pin 9 to the servo object
  delay(15);
  myservo.write(179);
  //myservo2.write(179);
  // sets the servo position according to the scaled value
  delay(1000); // waits for it to get to the position
  myservo.detach();
  //myservo2.detach();
  delay(1000);
  health=5000;

}

animefruit
 
Posts: 169
Joined: Tue Feb 25, 2020 1:04 pm

Re: Velosats

by adafruit_support_bill on Wed Jul 29, 2020 5:35 am

So the total length of all wires should not be more than 2-3 feet. So does that include the wires that arn't connected to anything.

The SDA and SCL wires are the i2c bus. For best results, you should keep these as short as possible.

As you can see in some of my pictures, there is just some wires that are just hanging around doing nothing on my breadboard.

We really can't follow where any of those wires go in your photo. But any extraneous wires are just an antenna for noise and should be removed.

But when I soldered the SDO on the accelrometer to the 3vo on the accelrometer with a really small wire, it still didn't work o my actual code, although it did work on the 12c scanner again,

If the device responds to the scanner address but does not communicate, it could be that your wires are too long or it might be an issue in your code. To rule out a code issue use the example code from the library.

adafruit_support_bill
 
Posts: 78979
Joined: Sat Feb 07, 2009 10:11 am

Re: Velosats

by animefruit on Wed Jul 29, 2020 3:49 pm

So I did what you said and ran acceldemo for 0x19 and it worked. So this must mean that this is a coding problem. Right? Can you tell me what is wrong with my code for why it can not start b? Here is my code:
Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LIS3DH.h>
#include <Adafruit_Sensor.h>
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3,POSITIVE);

// Used for software SPI
#define LIS3DH_CLK 13
#define LIS3DH_MISO 12
#define LIS3DH_MOSI 11
// Used for hardware & software SPI
#define LIS3DH_CS 10

// software SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS, LIS3DH_MOSI, LIS3DH_MISO, LIS3DH_CLK);
// hardware SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS);
// I2C
//Adafruit_LIS3DH lis_A = Adafruit_LIS3DH();
Adafruit_LIS3DH lis_B = Adafruit_LIS3DH(0x19);
Servo myservo;
int health=5000;
//int reading;
int reading2;
int pos;


void setup(void) {

  lcd.begin (16 ,2);
  lcd.clear();
 
  Serial.begin(9600);
 
   myservo.attach(9); //servo at digital pin 9
 myservo.write(0); //initial point for servo
 
  while (!Serial) delay(10);     // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("LIS3DH test!");

 //if (! lis_A.begin(0x18)) {   // change this to 0x19 for alternative i2c address
    //Serial.println("Couldnt start A");
   //while (1) yield();
 // }

  if (! lis_B.begin(0x19)) {   // change this to 0x19 for alternative i2c address
    Serial.println("Couldnt start B");
    while (1) yield();
  }
  Serial.println("LIS3DH found!");

   //lis_A.setRange(LIS3DH_RANGE_4_G);   // 2, 4, 8 or 16 G!
   lis_B.setRange(LIS3DH_RANGE_4_G);
  //Serial.print("Range = "); Serial.print(2 << lis_A.getRange());
  Serial.print("Range = "); Serial.print(2 << lis_B.getRange());
  Serial.println("G");

  // lis.setDataRate(LIS3DH_DATARATE_50_HZ);
 /* Serial.print("Data rate set to: ");
  switch (lis_A.getDataRate()) {
    case LIS3DH_DATARATE_1_HZ: Serial.println("1 Hz"); break;
    case LIS3DH_DATARATE_10_HZ: Serial.println("10 Hz"); break;
    case LIS3DH_DATARATE_25_HZ: Serial.println("25 Hz"); break;
    case LIS3DH_DATARATE_50_HZ: Serial.println("50 Hz"); break;
    case LIS3DH_DATARATE_100_HZ: Serial.println("100 Hz"); break;
    case LIS3DH_DATARATE_200_HZ: Serial.println("200 Hz"); break;
    case LIS3DH_DATARATE_400_HZ: Serial.println("400 Hz"); break;

    case LIS3DH_DATARATE_POWERDOWN: Serial.println("Powered Down"); break;
    case LIS3DH_DATARATE_LOWPOWER_5KHZ: Serial.println("5 Khz Low Power"); break;
    case LIS3DH_DATARATE_LOWPOWER_1K6HZ: Serial.println("16 Khz Low Power"); break;
*/

    switch (lis_B.getDataRate()) {
    case LIS3DH_DATARATE_1_HZ: Serial.println("1 Hz"); break;
    case LIS3DH_DATARATE_10_HZ: Serial.println("10 Hz"); break;
    case LIS3DH_DATARATE_25_HZ: Serial.println("25 Hz"); break;
    case LIS3DH_DATARATE_50_HZ: Serial.println("50 Hz"); break;
    case LIS3DH_DATARATE_100_HZ: Serial.println("100 Hz"); break;
    case LIS3DH_DATARATE_200_HZ: Serial.println("200 Hz"); break;
    case LIS3DH_DATARATE_400_HZ: Serial.println("400 Hz"); break;

    case LIS3DH_DATARATE_POWERDOWN: Serial.println("Powered Down"); break;
    case LIS3DH_DATARATE_LOWPOWER_5KHZ: Serial.println("5 Khz Low Power"); break;
    case LIS3DH_DATARATE_LOWPOWER_1K6HZ: Serial.println("16 Khz Low Power"); break;
  }
}
//}


void loop() {
  do
  {

   myservo.detach();
  //reading = lis_A.y;
  reading2 = lis_B.y;

/*if (reading < -800 ){
  reading=0;
}

 if(reading > -800){
  Serial.println(reading);
  lcd.println(reading);
 }
*/
if (reading2 < -800 ){
  reading2 =0;
}

 if(reading2 > -800){
  Serial.println(reading2);
  lcd.println(reading2);
 }

 
 
   
 /* lis_A.read();      // get X Y and Z data at once
  // Then print out the raw data
  //Serial.print("X:  "); Serial.print(lis.x);
Serial.print("  \tY:  ");Serial.print(lis_A.y);
  //Serial.print("  \tZ:  "); Serial.print(lis.z);
*/

 lis_B.read();      // get X Y and Z data at once
  // Then print out the raw data
  //Serial.print("X:  "); Serial.print(lis_B.x);
Serial.print("  \tY:  ");Serial.print(lis_B.y);
  //Serial.print("  \tZ:  "); Serial.print(lis_B.z);

  /* Or....get a new sensor event, normalized */
  sensors_event_t event;
  //lis_A.getEvent(&event);
  lis_B.getEvent(&event);

  /* Display the results (acceleration is measured in m/s^2) */
  //Serial.print("\t\tX: "); Serial.print(event.acceleration.x);
  //Serial.print(" \tY: "); Serial.print(event.acceleration.y);
  //Serial.print(" \tZ: "); Serial.print(event.acceleration.z);
  //Serial.println(" m/s^2 ");
//float totalAcceleration = sqrt((event.acceleration.x * event.acceleration.x) + (event.acceleration.y * event.acceleration.y) + (event.acceleration.z * event.acceleration.z));
  //Serial.println();
    //reading = analogRead(A4 & A5);
   
    Serial.print("Sensor Value=");
    //reading - 100;
    //health=health-reading;
    health=health-reading2;
    Serial.println(health);
    lcd.println(health);



     
   // if ( health< 10000){
  //delay(600);
//}

  delay(600);


} while(health>1);
myservo.attach(9);
//myservo2.attach(11);
  // attaches the servo on pin 9 to the servo object
  delay(15);
  myservo.write(1);
 // myservo2.write(1);
  // sets the servo position according to the scaled value
  delay(1000);
  // waits for it to get to the position
  myservo.detach();
 // myservo2.detach();
  delay(6000);//how long it pauses
  myservo.attach(9);
  //myservo2.attach(11);
  // attaches the servo on pin 9 to the servo object
  delay(15);
  myservo.write(179);
  //myservo2.write(179);
  // sets the servo position according to the scaled value
  delay(1000); // waits for it to get to the position
  myservo.detach();
  //myservo2.detach();
  delay(1000);
  health=5000;

}

animefruit
 
Posts: 169
Joined: Tue Feb 25, 2020 1:04 pm

Re: Velosats

by adafruit_support_bill on Wed Jul 29, 2020 3:58 pm

Try this:

Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LIS3DH.h>
#include <Adafruit_Sensor.h>
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3,POSITIVE);

// Used for software SPI
#define LIS3DH_CLK 13
#define LIS3DH_MISO 12
#define LIS3DH_MOSI 11
// Used for hardware & software SPI
#define LIS3DH_CS 10

// software SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS, LIS3DH_MOSI, LIS3DH_MISO, LIS3DH_CLK);
// hardware SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS);
// I2C
//Adafruit_LIS3DH lis_A = Adafruit_LIS3DH();
Adafruit_LIS3DH lis_B = Adafruit_LIS3DH();
Servo myservo;
int health=5000;
//int reading;
int reading2;
int pos;


void setup(void) {

  lcd.begin (16 ,2);
  lcd.clear();
 
  Serial.begin(9600);
 
   myservo.attach(9); //servo at digital pin 9
 myservo.write(0); //initial point for servo
 
  while (!Serial) delay(10);     // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("LIS3DH test!");

 //if (! lis_A.begin(0x18)) {   // change this to 0x19 for alternative i2c address
    //Serial.println("Couldnt start A");
   //while (1) yield();
 // }

  if (! lis_B.begin(0x19)) {   // change this to 0x19 for alternative i2c address
    Serial.println("Couldnt start B");
    while (1) yield();
  }
  Serial.println("LIS3DH found!");

   //lis_A.setRange(LIS3DH_RANGE_4_G);   // 2, 4, 8 or 16 G!
   lis_B.setRange(LIS3DH_RANGE_4_G);
  //Serial.print("Range = "); Serial.print(2 << lis_A.getRange());
  Serial.print("Range = "); Serial.print(2 << lis_B.getRange());
  Serial.println("G");

  // lis.setDataRate(LIS3DH_DATARATE_50_HZ);
 /* Serial.print("Data rate set to: ");
  switch (lis_A.getDataRate()) {
    case LIS3DH_DATARATE_1_HZ: Serial.println("1 Hz"); break;
    case LIS3DH_DATARATE_10_HZ: Serial.println("10 Hz"); break;
    case LIS3DH_DATARATE_25_HZ: Serial.println("25 Hz"); break;
    case LIS3DH_DATARATE_50_HZ: Serial.println("50 Hz"); break;
    case LIS3DH_DATARATE_100_HZ: Serial.println("100 Hz"); break;
    case LIS3DH_DATARATE_200_HZ: Serial.println("200 Hz"); break;
    case LIS3DH_DATARATE_400_HZ: Serial.println("400 Hz"); break;

    case LIS3DH_DATARATE_POWERDOWN: Serial.println("Powered Down"); break;
    case LIS3DH_DATARATE_LOWPOWER_5KHZ: Serial.println("5 Khz Low Power"); break;
    case LIS3DH_DATARATE_LOWPOWER_1K6HZ: Serial.println("16 Khz Low Power"); break;
*/

    switch (lis_B.getDataRate()) {
    case LIS3DH_DATARATE_1_HZ: Serial.println("1 Hz"); break;
    case LIS3DH_DATARATE_10_HZ: Serial.println("10 Hz"); break;
    case LIS3DH_DATARATE_25_HZ: Serial.println("25 Hz"); break;
    case LIS3DH_DATARATE_50_HZ: Serial.println("50 Hz"); break;
    case LIS3DH_DATARATE_100_HZ: Serial.println("100 Hz"); break;
    case LIS3DH_DATARATE_200_HZ: Serial.println("200 Hz"); break;
    case LIS3DH_DATARATE_400_HZ: Serial.println("400 Hz"); break;

    case LIS3DH_DATARATE_POWERDOWN: Serial.println("Powered Down"); break;
    case LIS3DH_DATARATE_LOWPOWER_5KHZ: Serial.println("5 Khz Low Power"); break;
    case LIS3DH_DATARATE_LOWPOWER_1K6HZ: Serial.println("16 Khz Low Power"); break;
  }
}
//}


void loop() {
  do
  {

   myservo.detach();
  //reading = lis_A.y;
  reading2 = lis_B.y;

/*if (reading < -800 ){
  reading=0;
}

 if(reading > -800){
  Serial.println(reading);
  lcd.println(reading);
 }
*/
if (reading2 < -800 ){
  reading2 =0;
}

 if(reading2 > -800){
  Serial.println(reading2);
  lcd.println(reading2);
 }

 
 
   
 /* lis_A.read();      // get X Y and Z data at once
  // Then print out the raw data
  //Serial.print("X:  "); Serial.print(lis.x);
Serial.print("  \tY:  ");Serial.print(lis_A.y);
  //Serial.print("  \tZ:  "); Serial.print(lis.z);
*/

 lis_B.read();      // get X Y and Z data at once
  // Then print out the raw data
  //Serial.print("X:  "); Serial.print(lis_B.x);
Serial.print("  \tY:  ");Serial.print(lis_B.y);
  //Serial.print("  \tZ:  "); Serial.print(lis_B.z);

  /* Or....get a new sensor event, normalized */
  sensors_event_t event;
  //lis_A.getEvent(&event);
  lis_B.getEvent(&event);

  /* Display the results (acceleration is measured in m/s^2) */
  //Serial.print("\t\tX: "); Serial.print(event.acceleration.x);
  //Serial.print(" \tY: "); Serial.print(event.acceleration.y);
  //Serial.print(" \tZ: "); Serial.print(event.acceleration.z);
  //Serial.println(" m/s^2 ");
//float totalAcceleration = sqrt((event.acceleration.x * event.acceleration.x) + (event.acceleration.y * event.acceleration.y) + (event.acceleration.z * event.acceleration.z));
  //Serial.println();
    //reading = analogRead(A4 & A5);
   
    Serial.print("Sensor Value=");
    //reading - 100;
    //health=health-reading;
    health=health-reading2;
    Serial.println(health);
    lcd.println(health);



     
   // if ( health< 10000){
  //delay(600);
//}

  delay(600);


} while(health>1);
myservo.attach(9);
//myservo2.attach(11);
  // attaches the servo on pin 9 to the servo object
  delay(15);
  myservo.write(1);
 // myservo2.write(1);
  // sets the servo position according to the scaled value
  delay(1000);
  // waits for it to get to the position
  myservo.detach();
 // myservo2.detach();
  delay(6000);//how long it pauses
  myservo.attach(9);
  //myservo2.attach(11);
  // attaches the servo on pin 9 to the servo object
  delay(15);
  myservo.write(179);
  //myservo2.write(179);
  // sets the servo position according to the scaled value
  delay(1000); // waits for it to get to the position
  myservo.detach();
  //myservo2.detach();
  delay(1000);
  health=5000;

}

adafruit_support_bill
 
Posts: 78979
Joined: Sat Feb 07, 2009 10:11 am

Re: Velosats

by animefruit on Sat Aug 01, 2020 2:15 pm

It works! Thank you. Now my next question is how can I solder a 360 degree servo motor. Is there any solderable 360 degree servo motors that you would recommend for me to use? Is there anything similar that I can solder? What would you recommend for me to do this?

animefruit
 
Posts: 169
Joined: Tue Feb 25, 2020 1:04 pm

Please be positive and constructive with your questions and comments.