Author Topic: New to visualino  (Read 1057 times)

aishen

  • Newbie
  • *
  • Posts: 30
    • View Profile
New to visualino
« on: 2016-December-12 11:50:34 am »
Hi,
I recently discovered visualino, thank you for this excellent tool. I am french and I would like to know if it's translated or not, eventually I might try to do it after a longer experience. To begin I am doing an Elego Robot car vers 0.2 conversion. I started a LCD telemeter and I found one variable I don't know how to set it, here is the arduino program :

(variable I don't know how to set ? unsigned int distance = duree*(VITESSE/1000.0); //on multiplie par la vitesse, d=t*v and #define VITESSE at the moment)

#include <LiquidCrystal.h>
#define VITESSE 340
const int USTrig = 2; // Déclencheur sur la broche 8
const int USEcho = 3; // Réception sur la broche 9
LiquidCrystal lcd(7,8,9,10,11,12);
void setup() {
    lcd.begin(2, 16);
    pinMode(USTrig, OUTPUT);
    pinMode(USEcho, INPUT);
    lcd.print("Telemetre");
   
}
void loop()
{
   digitalWrite(USTrig, HIGH);
   delayMicroseconds(10);
   digitalWrite(USTrig, LOW);
   unsigned long duree = pulseIn(USEcho, HIGH);
  if(duree > 30000)
   {
      //si la durée est supérieure à 30ms, l'onde est perdue
      lcd.clear();
      lcd.home(); // Replace le curseur en haut à gauche
      lcd.print("Onde perdue :(");
      lcd.setCursor(0,1);
      lcd.print("Mesure echouee !");
   }
   else
   {
      // 4. On divise cette durée par deux pour n'avoir qu'un trajet
      duree = duree/2;

      // 5. On calcul la distance avec la formule d=v*t
      unsigned int distance = duree*(VITESSE/1000.0); //on multiplie par la vitesse, d=t*v

      // 6. On affiche !
      lcd.clear();
      lcd.home(); // Replace le curseur en haut à gauche
      char message[16] = "";
      sprintf(message, " Dist : %4d mm", distance);
      lcd.print(message);
      sprintf(message, "Temps : %4d us", duree);
      lcd.setCursor(0,1);
      lcd.print(message);
   }
   delay(250); // Petite pause
}

Any help,
Thank you
(I can read spanish as I used to know it , I use ubuntu.)

Víctor R. Ruiz

  • Administrator
  • Jr. Member
  • *****
  • Posts: 91
    • View Profile
Re: New to visualino
« Reply #1 on: 2016-December-14 03:44:31 pm »
I guess you can use the long int variable.

aishen

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: New to visualino
« Reply #2 on: 2016-December-14 03:50:04 pm »
Thanks you. I found a spanish tempo maybe easier.

aishen

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: New to visualino/lcdtermo final
« Reply #3 on: 2016-December-14 06:21:29 pm »
I just finished my LCD termo, completly done with visualino and very compacte !
By the way, I saw few things to correct in the translation : égal à should be = that's why it's very useful to be able to practice it.
I can send the visualino bly, just ask me. I will do an 123d.circuits.io of it and maybe a github repo for tutorial.
Anyway thanks for your help.

#include <Wire.h>
#include <LiquidCrystal.h>
/***   Global variables   ***/
int pinSensor=0;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
/***   Function declaration   ***/
void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.clear();
}
void loop()
{
    pinMode(pinSensor,INPUT);
    int leerSensor=analogRead(pinSensor);
    int termo=leerSensor - 552 / 20;
    lcd.print(termo);
    lcd.print(" degres");
    delay(5000);
    lcd.clear();
}
/***   Function definition   ***/