AsTeRICS Arduino Microcontroller Demo

This is a tutorial including four different demos, showing you how to use the popular arduino microcontroller platform together with AsTerICS.

Objective

Digital Input/Output, PWM and ADC with the microcontroller Arduino Uno.(current)


Description

The Arduino Uno microcontroller platform supports digital input and output and analog input. This tutorial shows those functions in four demonstrations:

  • Demo 1: Digital Input
  • Demo 2: Digital Output
  • Demo 3: PWM
  • Demo 4: ADC
  • Demo 5: Servo PWM


Requirements

For this demo you need

Additionally required for demos:

  • Demo 1: Digital Input: Switch, Resistor
  • Demo 2: Digital Output: LEDs, Resistor
  • Demo 3: PWM: LEDs, Resistor
  • Demo 4: ADC: Capacitor, Resistor
  • Demo 5: Servo PWM: Servo motor

Install CIM on Arduino Uno

Windows 7, 8, 10

Flash Arduino Uno

 C:\absolute\path\to\AsTeRICS\CIMs\Arduino\build> flash COM1

Linux

Install avrdude

$ sudo apt-get install avrdude

Flash Arduino Uno

 $ avrdude -pm328p         \ 
-P /dev/ttyACM1 \
-c stk500v1 \
-b 115200 \
-U flash:w:/absolute/path/to/AsTeRICS/CIMs/Arduino/build/Arduino.hex \
-F

MAC OS X

Install avrdude

 $ brew install avrdude --with-usb

Flash Arduino Uno

 $ avrdude -pm328p         \ 
-P /dev/ttyACM1 \
-c stk500v1 \
-b 115200 \
-U flash:w:/absolute/path/to/AsTeRICS/CIMs/Arduino/build/Arduino.hex \
-F

Demos

Demo 1: Digital Input

The first demo introduces you to the digital input capabilities of the Arduino Uno platform. Setup the circuit and press Start to capture switch operation at the connected button.

Circuit

For this demo you have to setup the electric circuitry as depcited below.

Demo 1: Digital Input Arduino Circuit for Demo 1: Digital Input

First, connect a 220 Ω resistor R1 to the 5V pin on the left side. Then connect the resistor to the switch S1 and to the digital input pin with the number 2 on the right side of the connectors of the Arduino Uno, as shown in the left picture above. Finally, connect the other pin of the switch to one of the GND pins of the left side of the connectors of the Arduino Uno.

Demo Application

Use the left button to start and deploy the model to a (locally) running ARE instance, and start to capture push button (S1) activity.

Edit Model ArduinoDigitalInput

Open in WebACS

You can edit the used model directly in WebACS and adapt to fit your own needs.


Demo 2: Digital Output

The second demo introduces you to the digital output capabilities that are included with the Arduino Uno platform. Setup the circuit and press the buttons in the application section.

Circuit

For this demo you have to setup the electric circuitry as depicted below.

Demo 2: Digital Output Arduino Circuit for Demo 2: Digital Output

First, connect a 220 Ω resistor R1 to the digital output pin with the number 2 on the right side of the connectors of the Arduino Uno, as shown in the left picture above. Then connect the anode of the LED D1 (positive) with that resistor. Finally, connect the cathode of the LED (negative) to one of the GND pins on the left side of the connectors of the Arduino Uno.

Demo Application

Use the left button to start and deploy the model to a (locally) running ARE instance. Afterwards, press the buttons LED On and LED Off to turn the LED on and off, respectively. The AsTeRICS model (.acs) is started and commands are passed through to it, in order to toggle the LED.

Edit Model ArduinoDigitalOutput

Open in WebACS

You can edit the used model directly in WebACS and adapt to fit your own needs.


Demo 3: PWM

The third demo shows you how to use the PWM capabilities of the digital outputs of Arduino Uno to dim a LED light. Setup the circuit, and in the application section below, choose the desired Duty Cycle and press the buttons in the application section.

Circuit

For this demo you have to setup the electric circuitry as depcited below.

Demo 3: PWM Arduino Circuit for Demo 3: PWM

First, connect a 220 Ω resistor R1 to the PWM pin with the number ~3 on the right side of the connectors of the Arduino Uno platform, as shown in the left picture above. Then connect the anode of the LED D1 (positive) with that resistor. Finally, connect the cathode of the LED (negative) to one of the GND pins on the left side.

Demo Application

Use the left button to start and deploy the model to a (locally) running ARE instance. Afterwards, press the buttons LED On and LED Off to turn the LED on and off, respectively. You may change the value of the slider Duty Cycle as you wish. The AsTeRICS model (.acs) is started and commands are passed through to it, in order to toggle and dim the LED.



Edit Model ArduinoPWM

Open in WebACS

You can edit the used model directly in WebACS and adapt to fit your own needs.


Demo 4: ADC

The fourth demo shows how to measure an analog value and use its digital representation in an ACS model.

Circuit

For this demo you have to setup the electric circuitry as depcited below.

Demo 4: ADC Arduino Circuit for Demo 4: ADC

First, connect a 100 kΩ resistor R2 to the digital output pin with the number 2, on the right side of the connectors of the Arduino Uno platform, as shown in the left picture above. Then connect the resistor with a 10 µF (electrolytic) capacitor C1 with that resistor. Additonally, connect the positive side of C1 with the analog pin with the number A0, on the left side of the connectors of the Aruindo Uno. Finally, connect the negative side of the (electrolytic) capacitor to one of the GND pins on the left side.

Demo Application

Use the left button to start and deploy the model to a (locally) running ARE instance. Afterwards, press the buttons Set Pin 2 and Reset Pin 2 to turn pin with the number 2 on and off, respectively. The AsTeRICS model (.acs) is started and commands are passed through to it.


Edit Model ArduinoADC

Open in WebACS

You can edit the used model directly in WebACS and adapt to fit your own needs.


Demo 5: Servo PWM

Circuit

For this demo you have to setup the electric circuitry as depcited below.

Demo 5: Servo PWM Arduino Circuit for Demo 5: Servo PWM

Servo motors, used for the construction of models, usually have connectors with three pins (power - control - ground). Connect the power pin (red) of the servo motor with the 5V pin on the left side. Then connect the control pin (yellow, orange, white) of the servo motor with the PWM pin with the number ~3 on the right side of the connectors of the Arduino Uno platform, as shown in the left picture above. Finally, connect the ground pin (brown, black) of the servo motor with the GND pin on the left side.

Demo Application

Use the left button to start and deploy the model to a (locally) running ARE instance. Afterwards, press the buttons Servo On and Servo Off to turn the servo motor on and off, respectively. You may change the value of the slider Angle as you wish. The AsTeRICS model (.acs) is started and commands are passed through to it.



Edit Model ArduinoServoPWM

Open in WebACS

You can edit the used model directly in WebACS and adapt to fit your own needs.


Additional Material

This section contains additional support material related to this demo tutorial.

Source Repository

Fork and modify this repository.