Programme Development

To program our CanSat we use the development environment called Arduino.

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. (source: http://arduino.cc/)
 The programming language of it is based on C++, but it is much more simple. If you are familiar with any programming language you should not have any problem, while learning Arduino.(Unfortunately, in the school we learn Turbo Pascal, not C and C++, so it took quite a time for me to get used to Arduino. - Gellért Kovács)

 Here is a simple programme code, written by me (Gellért). It reads the temperature sensors value every second, and if there is a change to the last measuruement it prints to the Serial Monitor the amount of the change and it flashes the inbuilt LED.

NOTE: This is just an example to let you know how an Arduino code looks like. It is not meant to teach or explain anything , that is why there are no explanations included. If you need further information please visit the official Arduino webpage, where you can find a lot of tutorials and examples.

#define LED 8
#define off HIGH
#define on LOW

int sensorValue = 0;
int previous_sensorValue = 0;
int kulonbseg = 0;

void setup()
{
  Serial.begin(38400);
  pinMode(LED, OUTPUT);
}

void loop()
{
  previous_sensorValue = sensorValue;
  sensorValue = analogRead(A2); //read the sensors value
  Serial.print(sensorValue);

  if (previous_sensorValue == sensorValue)
    {
      Serial.println(" nem valtozott."); //English: did not cahnge
      digitalWrite(LED, off);
    }
   else
     {
       digitalWrite(LED, on);
       if (previous_sensorValue < sensorValue)
         {
           kulonbseg = sensorValue - previous_sensorValue;
           Serial.print(" nott "); //English: it increased
           Serial.print(kulonbseg);
           Serial.println(" egyseggel."); //English: by "kulonbseg" units
         }
        else
          {
            kulonbseg = previous_sensorValue - sensorValue;
            Serial.print(" csokkent "); //English: it decreased
            Serial.print(kulonbseg);
            Serial.println(" egyseggel."); //English: by "kulonbseg" units
          }
     }
     delay(1000);
}

Comments

Popular Posts