Category Archives: Teaching

Computer Engineering Day Camp

Next week, the ECE department hosts Computer Engineering Day Camp for high school students. The program has two different sections: 1) Mobile robot, 2) Smart phone programming. But in the last day, two sections will be integrated into one to control Lego Mindstorm Robots with Smart devices through the Bluetooth technology.

I am responsible for the second section, smart phone programming. To be precise, smart device programming is better term since I am going to introduce some additional tablet devices powered by Android.

App Inventor for Android will be used for programming The block based graphical programming tool, similar to Scratch, was originally from Google Labs. Now it is maintained by MIT.

For more details such as lecture materials, you can visit here.

Wireless Remote Sensor

Sensor data from the ultrasonic sensor can be sent to remote machines. Many choices can be made. Here in this example, in order to send data a Bluetooth module will be used. A Bluetooth module cannot be connected to the Arduino without using an extra parts. The IO Expansion Shield from is one of options.

The DF-BluetoothV3 Bluetooth module (SKU:TEL0026) is compatible with the IO Expansion. This combination makes me easier when it comes to adding a Bluetooth module. Using this we can simply add wireless capability into the Arduino. The next step is to attach the ultrasonic sensor to the IO expansion board.

On the expansion board, there are digital and analog pins that are connected to corresponding pins to the Arduino board. Make sure that pins for TRIGGER and ECHO from the ultrasonic sensor are connected to the IO expansion board according to the pin usage in the source code that is used in the previous posting. The picture below shows the assembled module.

Note that the Bluetooth module should be disconnected when a binary is being uploaded. Anyway, the exact same code from the previous posting can be used so that you do not need to upload a new binary.

The next step is that making pairs between the computer and the Bluetooth module. By doing this, from the computer  communicating with a Bluetooth module is now just simple serial communications.

Detail steps depend on the operating system. Followings are from Mac OS X. Choose the Set Up Bluetooth Devices menu item. Select the Bluetooth_V3 item.

The default passcode of the Bluetooth module is ‘1234.’ When you are prompted use the passcode.

When the pairing is completed successfully the window below will be shown.

Practically we are done. Open any terminal software for serial communication. I recommend CoolTerm that can be downloaded from here.

One extra optional step is visualizing the sensor data. Processing ( is used to visualize sensor data from the Bluetooth module. I made the visualization code as simple as possible.

import processing.serial.*;
// screen width
int maxWidth = 800;
int maxHeight = 100;
int lf = 10;

// The serial port
Serial myPort; 
float gCurDist;
Graph gGraph;

void setup() {
  // List all the available serial ports

  // Open the port you are using at the rate you want:
  // You may change the index number accordingly.
  myPort = new Serial(this, Serial.list()[0], 9600);

  // myPort = new Serial(this, "/dev/tty.Bluetooth_V3-DevB", 9600); 
  size(maxWidth, maxHeight);

  gGraph = new Graph(700, 80, 10, 10);
void serialEvent(Serial p)
  String incomingString = p.readString();
  String[] incomingValues = split(incomingString, ',');
  if(incomingValues.length > 2) {
    float value = Float.parseFloat(incomingValues[1].trim());
    gCurDist = value;
void draw() {
  gGraph.distance = gCurDist;
class Graph {
  int sizeX, sizeY, posX, posY;
  int minDist = 0;
  int maxDist = 500;
  float distance;

  Graph(int _sizeX, int _sizeY, int _posX, int _posY) {
    sizeX = _sizeX;
    sizeY = _sizeY;
    posX = _posX;
    posY = _posY;

  void render() {
    int stemSize = 30;

    float dispDist = round(distance);
    if(distance > maxDist)
      dispDist = maxDist+1;
    if((int)distance < minDist)
      dispDist = minDist;

    float distSize = (1 - ((dispDist - minDist)/(maxDist-minDist)));
    rect(posX, posY, sizeX-(sizeX*distSize), sizeY);

Ultrasonic Sensor

Ultrasonic sensor test. It works. Nice.

Ultrasonic sensor module is HC-SR04. I purchased this from The company provides a Ultrasonic library.

  • Go to and find the Ultrasonic section.
  • Download the library.
  • Unzip it and copy the unzipped folder to your Arduino libraries folder.
  • You may restart Arduino to let it recognize the new library.
  • Use an example code for your starting step.

Here is the example.

#include <Ultrasonic.h>
#define TRIGGER_PIN 12
#define ECHO_PIN 13
Ultrasonic ultrasonic(TRIGGER_PIN, ECHO_PIN);
void setup()
void loop()
  float cmMsec, inMsec;
  long microsec = ultrasonic.timing();
  cmMsec = ultrasonic.convert(microsec, Ultrasonic::CM);
  inMsec = ultrasonic.convert(microsec, Ultrasonic::IN);
  //Serial.print("MS: ");
  Serial.print(", ");
  //Serial.print(", CM: ");
  Serial.print(", ");
  //Serial.print(", IN: ");

Just wire pins as the source code says. Then open the Serial Monitor from Arduino. You will see he raw milliseconds and distance in centimeter and inch.

That’s it.

Arduino books

Get my feet wet with Arduino. I like the tiny book, Programming Arduino, Getting Started with Sketches. This book is well organized and pretty much informative. Arduino Cookbook is a good reference book that covers a lot of specific topics. Two project driven books also worth to read and obviously to do.

App Inventor for Android

I started learning how to use App Inventor. A few things that I should have known.

  1. App Inventor doesn’t require Android SDK.
  2. App Inventor is a web-based app but App Inventor for Android Blocks Editor is a Java-based app requiring JDK 1.6.
  3. Must install App Inventor Setup that is a supplementary tool set.
  4. Blocks Editor cannot find an emulator when TeamViewer is running.

How Learning Works

This is a brief introduction to seven research-based principles for smart teaching in the book: How Learning Works. I summarize an email news letter from Tomorrow’s Teaching and Learning.

What is learning?

  • Learning is A process not a product
  • Learning involves change in knowledge, beliefs, behaviors, or attitudes.
  • Learning is not something done to students but rather something students themselves do.

Seven principles of learning?

  1. Student’s prior knowledge can help or hinder learning.
  2. How students organize knowledge influences how they learn and apply what they know.
  3. Students’ motivation determines, directs, and sustains what they do to learn.
  4. To develop mastery, students must acquire component skills, practice integrating them, and know when to apply what they have learned.
  5. Goal-directed practice coupled with targeted feedback enhances the quality of students’ learning.
  6. Students’ current level of development interacts with the social, emotional, and intellectual climate of the course to impact learning.
  7. To become self-directed learners, students must learn to monitor and adjust their approaches to learning.

Good teaching

Tools for teaching by Davis, B.G., Jossey-Bass

Here is the table of contents.

Getting Underway

Responding to a Diverse Student Body
Discussion Strategies
Lecture Strategies
Collaborative and Experiential Strategies
Enhancing Students’ Learning and Motivation
  • 21.   Helping Students Learn
  • 22.   Learning Styles and Preferences
  • 23.   Motivating Students
Writing Skills and Homework Assignments
Testing and Grading
Instructional Media and Technology
  • 35.   Chalkboards
  • 36.   Flipcharts
  • 37.   Transparencies and Overhead Projectors
  • 38.   Slides
  • 39.   Films and Videotapes
  • 40.   Computers and Multimedia
Evaluation to Improve Teaching
Teaching Outside the Classroom
  • 44.   Holding Office Hours
  • 45.   Academic Advising and Mentoring Undergraduates
  • 46.   Guiding, Training, and Supervising Graduate Student Instructors
Finishing Up
  • 47.   The Last Days of Class
  • 48.   Student Rating Forms
  • 49.   Writing Letters of Recommendation