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 animefruit on Sun Aug 16, 2020 2:38 pm

What do you mean by solder spatters?

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

Re: Velosats

by animefruit on Sun Aug 16, 2020 2:43 pm

So you say I should remove the solder spatters. How do I do that? Do you mean I need to desolder all my joints on the front and have to resolder them?

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

Re: Velosats

by adafruit_support_bill on Sun Aug 16, 2020 2:52 pm

Remove these blobs of solder:
spatters.png
spatters.png (897.2 KiB) Viewed 41 times


And fix these so the solder flows onto the solder pads:
reflow.png
reflow.png (289.55 KiB) Viewed 41 times

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

Re: Velosats

by animefruit on Sun Aug 16, 2020 2:56 pm

Ok. Thankyou. I will do that.

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

Re: Velosats

by animefruit on Tue Aug 18, 2020 6:04 pm

So I tried to put those solder joints on to the pad and I still do not see characters on the lcd. Does this photo of my solder joints look good now? The adafruit site for assembling an lcd that you gave me says that if you can’t see any characters on the lcd than you should adjust the potentiometer. Is there some way I could adjust the contrast without a potentiometer?
Attachments
F75337FB-11F0-4A90-B435-DD09B1997F0C.jpeg
F75337FB-11F0-4A90-B435-DD09B1997F0C.jpeg (161.71 KiB) Viewed 35 times

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

Re: Velosats

by adafruit_support_bill on Wed Aug 19, 2020 6:56 am

There is a potentiometer on the backpack board. It is the little metal part next to where it says "Contrast".

You can use a small screwdriver to turn it. Be very gentle when turning and do not force it. Turning past the stops will damage the potentiometer.

Image

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

Re: Velosats

by animefruit on Thu Aug 27, 2020 10:17 pm

Ok. I did that and it worked when I used the HelloWorld 12c sketch. But it seems to not work with my other code. Can you tell me what I am doing wrong with my other code? Here is my other 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();
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() {

  lcd.setCursor(0, 1);
  do
  {

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

 

if (reading < -4000 ){
  reading=0;
}

 if(reading > -4000){
  Serial.println(reading);
  lcd.println(reading);
 }

if (reading2 < -4000 ){
  reading2 =0;
}

 if(reading2 > -4000){
  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 +reading2;
    //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 Fri Aug 28, 2020 6:04 am

You are declaring your display to use standard wiring via pins.
Code: Select all | TOGGLE FULL SIZE
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3,POSITIVE);


You need to declare it to use address #0 on i2c as it is done in HelloWorld_i2c:
Code: Select all | TOGGLE FULL SIZE
LiquidCrystal_I2C lcd(0);

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

Re: Velosats

by animefruit on Fri Aug 28, 2020 9:54 pm

I did that, but it still doesn't work on my lcd. Is there anything else in my code I need to change. Here is my changed 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);
LiquidCrystal_I2C lcd(0);

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

  //lcd.setCursor(0, 1);
  do
  {

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

 

if (reading < -4000 ){
  reading=0;
}

 if(reading > -4000){
  Serial.println(reading);
  lcd.println(reading);
 }

if (reading2 < -4000 ){
  reading2 =0;
}

 if(reading2 > -4000){
  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 +reading2;
    //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 Sat Aug 29, 2020 6:08 am

What output do you see on your serial monitor?

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

Re: Velosats

by animefruit on Sun Aug 30, 2020 10:38 pm

Its printing off the accelrometer values like it should.

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

Re: Velosats

by adafruit_support_bill on Mon Aug 31, 2020 7:12 am

Is the backlight on? You may need to add a command to turn it on in your setup()

Code: Select all | TOGGLE FULL SIZE
lcd.setBacklight(HIGH);

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

Re: Velosats

by animefruit on Fri Sep 04, 2020 9:11 pm

Where in my code do I put this? I put it somewhere in my code and it still doesn't work. Here is my code with that code you sent me :
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);
LiquidCrystal_I2C lcd(0);

// 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.setBacklight(HIGH);// ada
  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() {

  //lcd.setCursor(0, 1);
  do
  {

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

 

if (reading < -4000 ){
  reading=0;
}

 if(reading > -4000){
  Serial.println(reading);
  lcd.println(reading);
 }

if (reading2 < -4000 ){
  reading2 =0;
}

 if(reading2 > -4000){
  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 +reading2;
    //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 Sat Sep 05, 2020 6:05 am

Code: Select all | TOGGLE FULL SIZE
lcd.setBacklight(HIGH);// ada
  lcd.begin (16 ,2);
  lcd.clear();


You are calling lcd.setBacklight before you call lcd.begin. You can't send other commands to the board until after you call begin().

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

Re: Velosats

by animefruit on Sat Sep 05, 2020 2:19 pm

It is still not working, and I put the code after the "lcd.begin". Is there anything else I am missing to make this lcd not work for this code? Here is my code where I put the code you told me to use after begin:
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);
LiquidCrystal_I2C lcd(0);

// 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);
 lcd.setBacklight(HIGH);// ada
   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() {

  //lcd.setCursor(0, 1);
  do
  {

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

 

if (reading < -4000 ){
  reading=0;
}

 if(reading > -4000){
  Serial.println(reading);
  lcd.println(reading);
 }

if (reading2 < -4000 ){
  reading2 =0;
}

 if(reading2 > -4000){
  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 +reading2;
    //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

Please be positive and constructive with your questions and comments.