2012 SJ One Hello World Sample Project

From Embedded Systems Learning Academy
Revision as of 16:48, 27 August 2012 by Preet (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


This article will teach you:

  • Write a simple program for the SJ One Board
  • Output data from the Board Sensors

Please note that you need to read the Development Package article before following along this article.

The MAIN Function

The main() function is the entry point of a program. A lot of things may happen before main(), but it would be usually abstracted away from the user.

Locate main.cpp in your project

Hello World

Your "Hello World" project consists of printf message, compiling, loading the program onto the board, and confirming that your message comes out as you intended it. Follow these steps:

  1. Open up Eclipse
  2. Open Hello World Sample Project
  3. Open up main.cpp (You could search for it using shortcut key Ctrl+Shift+R)
  4. Write your own printf outputting your favorite message: printf("My own hello world!");
  5. Compile & Load the program onto the Board
  6. Open COM Port in Hercules and press RESET on the board to view your printf message.

Board Sensors

After you get a basic "Hello World" program working, you can now output various different sensor values.

Here are the sensors or devices of SJOne Board you can access:

  • Acceleration Sensor (AS)
  • Temperature Sensor (TS)
  • Light Sensor (LS)
  • IR Sensor (IS)
  • 2-Digit 7-Segment Display(LD)
  • 8 Board LEDs(LE)
  • 8 Board Switches (SW)

Output Sensor Data

To output sensor data, simply access the sensor device using the device name given between the parenthesis in the bullets above. In your main() function, you could type a device name followed by a . (period) to see the list of things you could do with a device. For example, you could type: "TS." and the Eclipse drop-down menu would show function calls you can make. We will use the Ts.getValueAsString() function call in the example below:

int main()
    printf("Hello World!");
    while(1) {
        printf("Temperature Sensor Reading: %s\n", TS.getValueAsString());