Freigeben über


Small Basic - Arduino Sample Programs

This March LitDev introduced about Arduino on this blog.  Today, I'd like to introduce my Small Basic programs using Arduino.

The first one is the IR Turtle controller (HLT038).

Screen shot of a program Turtle Controller

The circuit is like (GZN399):

Screen shot of a program OSOYOO UNO R3 0.1

The Arduino program irdemo.ino is from osoyoo.com.  More details about this program are described here.

The second one is a thermometer (KKK886).

Screen shot of a program Thermometer

The circuit is like (GZN399-0):

Screen shot of a program OSOYOO UNO R3 0.2

The Arduino program is as follows.

 //TMP36 Pin Variables
int sensorPin = 5; // the analog pin the TMP36's Vout (sense) pin is connected to
                   // the resolution is 10 mV / degree centigrade with a
                   // 500 mV offset to allow for negative temperatures
float lastTemp;    // last temperature
 
/*
 * setup() - this function runs once when you turn your Arduino on
 * We initialize the serial connection with the computer
 */
void setup()
{
  Serial.begin(9600);  // Start the serial connection with the computer
                        // to view the result open the serial monitor 
}
 
void loop()                     // run over and over again
{
  //getting the voltage reading from the temperature sensor
  int reading = analogRead(sensorPin);  
 
  // converting that reading to voltage, for 3.3v arduino use 3300
  int mV = map(reading, 0, 1023, 0, 5000);
 
  // now print out the temperature
  float temperatureC = (mV - 500) / 10.0 ;  //converting from 10 mV per degree with 500 mV offset
                                            //to degrees ((voltage - 500mV) times 100)
  if (temperatureC != lastTemp) {
    Serial.println(temperatureC);
    lastTemp = temperatureC;
  }
  delay(1000);                                     //waiting a second
}

Arduino can be connected with many types of sensors or actuators.  So, with this device, we can explore Small Basic world more and more interesting!

Comments

  • Anonymous
    October 19, 2016
    nice work nonki))updated ur arduino project in order to simulate 3 leds flashing in rgb: NCH457
  • Anonymous
    October 20, 2016
    Thanks Tryhest. I started a thread about Arduino and Small Basic.https://social.msdn.microsoft.com/Forums/en-US/6fd2f515-ac9b-4499-a7a5-87418bc2419c/tinkering-arduino-and-small-basic?forum=smallbasic
  • Anonymous
    October 23, 2016
    Very interesting !SB is much powerful than i thought :)
  • Anonymous
    October 29, 2016
    Fantastic Arduino samples!
  • Anonymous
    November 23, 2016
    Your connection graph is very clear and nice. Which graph tool do you use?
    • Anonymous
      December 01, 2016
      elane, this tool is just a Small Basic program. Thank you for your comment.
  • Anonymous
    November 23, 2016
    thank you !