You might like to modify the code on the previous page so that the browser command has three data points, red, green and blue, which are submitted to the agent and then relayed to the device to set the LED to whatever color you set in your browser. The imp006’s user LED’s primary colors are set by writing the value of these pins:
You’ll need to configure each pin as an PWM (Pulse Width Modulation) output, for example:
red_pin.configure(PWM_OUT, 1.0, 0.5); red_pin.write(0.5);
Now you can cycle through the values between
1.0 for each color.
We have more code samples for you to run on your imp006 Breakout Kit to help you understand how to create apps for the Electric Imp Platform.
Getting stuck? Need a component recommendation? You can reach out for advice and assistance at our Developer Forum.
A task for more advanced developers: since the agent is a micro web server, use web technologies like JQuery to build an interactive web UI served by the agent that allows the user to click on LED on/off buttons, and to enter color values into text fields. This example code will help you.
With suitable code, your agent can interpret much more complex HTTP requests combining multiple commands relevant to the device, which may include displays, sensors, control motors and more. You can write complex APIs served by the agent through which mobile apps can interact with your device.
We also have a Hardware Abstraction Layer (HAL) for the board which is a Squirrel table compiled to present key board pins and buses through explicit identifiers. Include the table,
BreakoutBoard_006, in your code to access these identifiers, such as
BreakoutBoard_006.BLUETOOTH for the Bluetooth sub-system,
BreakoutBoard_006.LED_RED for the RED user LED and
BreakoutBoard_006.SENSOR_I2C for the I2C bus over which the board’s sensors are accessed. Just paste the code in from the link above.
To find out more about the Electric Imp architecture and how it impacts application development, take a look at the Platform Overview.
Review the imp network state diagram to learn what states the imp006 passes through as it boots and runs your application.
You can find out all about the imp006 Breakout Board and its capabilities at its reference design page. This is a key reference as you explore all of the board’s capabilities.
You should also check out the imp006 pin mux page — this will tell you which of the imp006’s pins can be accessed by your code and the features that can be enabled for each of those pins.
ImpCentral is great for getting started and building basic projects, but you may prefer tools that operate offline or can integrate with an existing workflow. Check out our impWorks™ command line tools: impt, for managing imp projects and code, and Builder, which is a powerful code pre-processor. The impWorks suite also includes a plug-in for the popular VSCode text editor.
We can’t wait to see what you build!