Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
johna69
Product and Topic Expert
Product and Topic Expert

This year at SAP Inside Track Washington DC we are trying a first for us. We are taking the learning and material we created for a Girls Exploring Tech event at Rutgers Prep (blog to come) event and reusing them for a hands on session to close out the day.

A big thank you to tammy.powlas gerardo.moreno and candice.schumann for their help in putting this together.

Attendees will have the chance to play with an M3D 3D printer after first creating their own objects with sketchup, create one or more of three Arduino projects with a challenge as a twist.

The three Arduino projects are all included in this blog and includes schematics, materials list and code so can be reused by anyone.

Night Light

Parts List

Schematic

Programming Instructions

1.Open the Arduino program.
2.Make sure the Arduino is connected to the computer.
3.Make sure the correct board is selected by clicking Tools > Board > Arduino Uno.
4.Select the Serial port by clicking Tools > Serial Port >  (The correct port). On a MAC the port should look something like /dev/tty.usbmodem1411. On a Windows machine the port should look something like COM5.
5.Create a new sketch by clicking File > New.
6.We first need to initialize some variables.  Write the following code:

//Which pins are we using
const int sensorPin = 0;
const int ledPin = 9;
// We'll also set up some variables for the light level:
int lightLevel, high = 0, low = 1023;




7.We then need to set up the Arduino. Add the following code:

void setup()
{
  // We'll set up the LED pin to be an output.
  pinMode(ledPin, OUTPUT);
}




8.Now we need to tell the Arduino what to do while it is running. Write the following code after the setup code:

void loop()
{
  // We’lluse the analogRead() function to measure the
  // voltage coming from the photoresistor.
  lightLevel = analogRead(sensorPin);
  // manually change the range from light to dark
  manualTune();
  // Turn on the LED just according to the light level
  analogWrite(ledPin, lightLevel);
 
}
void manualTune()
{
  // We need the light level to be between 0 and 255
  // Right now it is between 0 and 1023
  lightLevel = map(lightLevel, 0, 1023, 0, 255);
  lightLevel = constrain(lightLevel, 0, 255);
}
void autoTune()
{
  //Challenge
}




9.Click the Verify button  . This compiles your code. The IDE changes it from text into instructions the computer can understand
10.Click the Upload button  . This sends the instructions via the USB cable to the computer chip on the Arduino board. The Arduino will then begin running your code automatically.
11.Try adjusting the light falling on the photocell to see how the light from the LED changes.

Blink

Parts List

Schematic

Programming Instructions

1.Open the Arduino program.
2.Make sure the Arduino is connected to the computer.
3.Make sure the correct board is selected by clicking Tools > Board > Arduino Uno.
4.Select the Serial port by clicking Tools > Serial Port >  (The correct port). On a MAC the port should look something like /dev/tty.usbmodem1411. On a Windows machine the port should look something like COM5.
5.Create a new sketch by clicking File > New.
6.First we need to set up the board to output to the LED. Write the following code:

void setup() {
  // initialize digital pin 12 as an output.
  pinMode(12, OUTPUT);
}

7.We then need to tell the Arduino what to do while it is running. Write the following code after the setup code:

// the loop function runs over and over again forever
void loop() {
  // turn the LED on (HIGH is the voltage level)
  digitalWrite(12, HIGH);  
  // wait for a second
  delay(1000);         
  // turn the LED off by making the voltage LOW
  digitalWrite(12, LOW);
  // wait for a second
  delay(1000);             
}

8.Click the Verify button  . This compiles your code. The IDE changes it from text into instructions the computer can understand
9.Click the Upload button  . This sends the instructions via the USB cable to the computer chip on the Arduino board. The Arduino will then begin running your code automatically.
10.You should see the LED light blink on and off.

Temperature Reader

Parts List

Schematic

Programming Instructions

1.Open the Arduino program.
2.Make sure the Arduino is connected to the computer.
3.Make sure the correct board is selected by clicking Tools > Board > Arduino Uno.
4.Select the Serial port by clicking Tools > Serial Port >  (The correct port). On a MAC the port should look something like /dev/tty.usbmodem1411. On a Windows machine the port should look something like COM5.
5.Create a new sketch by clicking File > New.
6.We are using the One Wire and Dallas Temperature libraries. Import the One Wire library by clicking Sketch > Import Library > OneWire. Do the same with the Dalla Temperature library by clicking Sketch > Import Library > dallas_temperature_control.
7.We need to set up One Wire and Dallas Temperature. Add the following code under the import code:

// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with our device
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
8.Next we need to set up the Arduino. Add the following code:

void setup()
{
  // start serial port (where we will write to)
  Serial.begin(9600);
  Serial.println("Temperature Demo");
 
  // Start up the library
  sensors.begin();
}
9.We then need to tell the Arduino what to do while it is running. Write the following code after the setup code:

void loop()


{
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  // Send the command to get temperatures
  sensors.requestTemperatures();
  Serial.println("DONE");
  Serial.print("Temperature for Device 1 is: ");
  float temperature = sensors.getTempCByIndex(0);
  //Convert to Fahrenheit
  temperature = (temperature * 1.8 ) +32;
  Serial.println(temperature);
  delay(1000);
}
10.Click the Verify button  . This compiles your code. The IDE changes it from text into instructions the computer can understand
11.Click the Upload button  . This sends the instructions via the USB cable to the computer chip on the Arduino board. The Arduino will then begin running your code automatically.
12.Click the Serial Monitor button  . This will open the Serial Monitor and the temperature will be printed to the screen every second.
13.Try changing the temperature by blowing or breathing in the temperature sensor.