Fri 26, 14.00pm Project Zone: Advanced Arduino Workshop

This time we made two circuits for Multiplexing of LEDs and PWM for an engine control. The Arduino language made the programming part very easy though. Especially the functions analogRead(pin) and analogWrite(pin, value) made the PWM very easy opposed to the effort you have to do in C. The Arduino Language Reference page shows the available functions that make your life easier.

I.e. the to get a (analog) value from a pin and write it to another is done in two lines of Arduino:

sensorValue = analogRead(sensorPin) / 4; // analogRead gives 0 to 1023, want 0 to 255
analogWrite(motorPin, sensorValue); // analogWrite uses 0 to 255

I try to find the code, I had written in C for PWM, that you can see the difference. I would like to have more programming next time for people in the advanced workshop, we spent lot of time with the hardware and not Arduino in particular.

Advertisement
Explore posts in the same categories: Dev8D London (UK)

Tags: ,

You can comment below, or link to this permanent URL from your own site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.