Champaign-Urbana Community Fab Lab
Champaign-Urbana Community Fab Lab

Posts Tagged ‘Assignment 6: Arduino Introduction’

Arduino Introduction – Grant Johnson

Build Process

The storyboard for my Arduino invention!

For this week, we began working with Arduino’s and attachments, to make cool stuff and little robots. For my invention, I decided to create a fan that turns on when a certain temperature threshold is met, and turns off when that temperature goes back down. You may be thinking, “Wow, this sounds a lot like an A/C unit”. I would agree, but in some buildings and situations, I think it would be convenient to have a more personalizable, small-scale fan to keep the

The hand that would turn on or turn off switches on the extension cord.

area around you cool. I

also think this is something that could help out people that aren’t entirely mobile or have difficulty being mobile by allowing them to cool themselves off without the extra strain of having to get up.

Having some familiarity with Arduino’s definitely made this week’s lessons much easier to follow and understand and allowed me to be aware of the limitations and accessories that come with them. I started out by drawing a storyboard showing how my product would function and the problems it would solve — allowing people to stay cool without having to get up. To make this possible I essentially decided to attach some servos to some ‘hands’ (in my prototype, popsicle sticks), these hands are then connected to the Arduino, which is reading the local temperature on a digital thermometer. When the

temperature threshold is met then the hands move to turn on the extension cord that the fan would be plugged into. When the temperature gets low enough again then it will turn the fan off. The only real challenge I experienced with this project was getting three different accessories to run off the Arduino at the same time. To solve this I simply took the wires and ran them through a breadboard to act as a type of ‘splitter’ for the wires

An excerpt of my code!

running into the power and grounding inputs on the Arduino. I then took the code for sweep and changed it some to work with two different servos running when different actions happen. I also created some simple loops for LEDs connected to Arduino’s during this week, which you can see in the attached video:

 

Reflection

This project was a lot of fun and really gave me a lot of room to make a huge variety of

different prototypes that could do any number of things. A lot of what we learned in class really helped me know how to proceed, but it also helped that I had previous knowledge of how to work with Arduino’s (I’ve made a locomating little car). I feel like this assignment definitely helped me think of how to take my previous knowledge and expand it in a really creative way. I also really enjoyed seeing all the examples from Sara on different ways that Arduino’s could be integrated into things such as art experiences.

I really was excited to see the arms of my prototype move when different temperatures

The set-up for my thermometer and Arduino board.

were read from the thermometer, that was a really fun and cool part of the project. It was also interesting seeing all the different things that could be connected to Arduino’s that could be used in future projects! I can see myself coming back to Arduino/buying a kit for myself soon so I can make some more awesome stuff.

 

Continue Reading

Arduino I Assignment

This week, we were introduced to the open-source platform Arduino and also learned more about building circuits with breadboards, LEDs, and resistors. I was particularly looking forward to this particular assignment, because as a CS major, I already felt comfortable with the coding aspect of the project, but have never worked with Arduinos before so it still got to be a novel learning experience nonetheless.

In lab we created a simple program to get an LED light blinking at various rates with the Arduino. I was able to get mine to blink “S.O.S.” in Morse code using some simple for-loops and varying the delay times between turning the LED on/off.

Then, we were asked to create a storyboard and Arduino device on our own time using different input/output sensors besides the touch sensor and LED output used in lab. For this, I conceptualized an idea of utilizing a distance sensor that would keep track of my cat’s location and make sure she isn’t hiding in places she shouldn’t be. As a cat owner, I always find myself worried I’m going to accidentally lock my cat in a closet or room and be unable to find her later. So I thought maybe one way of combatting that would be to install an ultrasonic sensor in the back of a closet or in other areas where I think she might hide in, which would read her distance and if she’s within the range where she could potentially be inside the closet, it would alert me. One output device that could be used for the alerting is an LCD screen which could also display information about where she is exactly.

The storyboard I came up with

To set up the Arduino device in lab, I found this tutorial to be helpful: https://www.instructables.com/id/Connecting-an-LCD-Screen-and-an-Ultrasonic-Distanc/ 

LCD screen and Arduino setup

Ultrasonic sensor and Arduino setup

Then, using the code from the tutorial with some minor adjustments to adapt to the devices I was using and writing my own custom messages (i.e. “[insert pet’s name] is [insert distance] away!”) to the display, I uploaded the code to the Arduino. However, while it seemed like the ultrasonic sensor was working (the green LED on the Arduino was programmed so that it would blink faster if something moved closer to the sensor), and the LCD display was definitely connected as it was lit, text was not appearing on the screen. I did some online searching and it seemed like lots of people were saying it was either a hardware or jumper cable connection issue. Even after changing the jumper cables and LCD display, nothing was showing up. Another reason might be because the LCD screen was too bright. Unfortunately due to lack of time at the lab I could not troubleshoot further.

The final setup

To make this prototype more functional for the real world (granted I had gotten the original to work), I think having longer wires or even some sort of wireless system (if at all possible) would help make it easier for someone to be able to carry or view the LCD display without having to be close to the sensor. I also think that if someone wanted to check for their pet’s location in multiple areas of the house, being able to install and assign several sensors would be cool. 

Continue Reading

Arduino Part 1

 

This week, we learned how to use Arduino. It is a very simple circuit that can carry out simple commands using the command prompt in the IDE. We learned how to code using the IDE to make the LED in the circuit blink using natural body resistance.

For this week, we need to make a storyboard to explain what Arduino sensor we are going to use and make. I chose to use the temperature sensor. Below is the attached storyboard. 

This is the storyboard for my Arduino thermostat

I decided to use the TM63 temperature sensor to as the input, then I also used the LED as an output to the Arduino circuit. In the IDE, I set that if the temperature goes beyond 35 degrees Celcius, the LED light will turn on as an indicator. I got the code for the thermostat from the MakerLab website which was really helpful. Then, I added the code snippet to turn on the light once the temperature hits more than 35 using the IF function and the code snippet we learned earlier in the week. Below is the code and a picture of the Arduino circuit.

 

 

Below is the link to the video if the above player does not work:

Arduino Thermostat

This week’s activity was very interesting to me as I have never worked with hardware before. Although it was hard at first, I managed to do it and it was satisfying.

If I were to do an iteration of this activity, I would:

  1. Add more LED bulbs to assess the level of temperatures
  2. Create more If clauses to give a more broad spectrum assessment
Continue Reading

Arduino I: Intro

For the first week of Arduino project, we were introduced into the essentials of the microcontroller, LED controls, and some of its sensors. With the circuit design experience in the Copper Tape project, most of the materials were not that difficult. Although still relied on Google for figuring out the right resistor. I’ve had some Arduino experience years ago, maybe. The lab session was very handy and helped to bring back those almost lost memories.

Triggering one LED within the loop() was easy. But when asked to add multiple reactions, things got a bit different. Because of the simplicity of Arduino, the program is supposed to be a neverending serial process. At a time, I was trying to have two LEDs blink different patterns. But soon I realized that it might need to have some walkaround. Parallel processing might be possible for Arduino, but that’s still out of my capacity. Might be a good point of discussion in class.

 

For the ideation project, I was thinking about the future of drone deliveries. It would be sweet to know the direction from where they would approach. Maybe not very useful for everyone, but it won’t harm either. And then the notion of a radar system came to my mind–a disk (or other shapes) rotating over and over on a base. Therefore, for the lab’s accessibility, I decided to do a shrunk version based on the availability of materials. Ultrasonic distance sensors on a servo could simulate the most essential form of radar. By periodically rotates the servo, the setup could sense approaching objects with a much wider angle. So in the following week, I’d try this design.

The design has been implemented with UNO x1, servo x1, ultrasonic sensor x2, LED x1, and a resistor. 

The setup was as shown above. The trigger and echo pins from both of the ultrasonic sensors were connected to PWM-capable pins on the board. The code was shown as below. I wrote several functions for this build. The base() function was designed to drive the servo run periodically back and forth. The range was limited to 90-degree because the pin connectors will fight against the servo due to the short arm. This is another shrink from the original sketch. Out of the 360, this ‘radar’ can only scan half of them. So I sliced the two 90-degree sectors into halves–each 45-degree sector represents a geological direction ( North, South, East, and West). This is what the angleToDirection() function was designed for. Then the alarm function was set to be called after each scan, so that if an object is detected within a threshold range,  the alarm (LED) will be triggered. I used both the onboard LED, and another one on the breadboard. Together with single and double blinks, the two LEDs could represent the direction of an approaching object in a very abstract way. Adding to that, I placed a serial output for the alarm message as well. 

As a reflection on this build. The ultrasonic sensors were tricky to deal with. Because it needs to listen for its echo at each step, it is easy to pollute the receiving end with triggers of previous steps. Also, during the test, a delay was necessary each time the servo reverse its rotation direction. Or it tended to generate some irregular signal, could be a false close response, or a far distance. There were a lot of trial and errors in deciding the parameters of the rotation and scanning. But it all worth it.

Continue Reading

Arduino 1: LED and Sensors

This week in lab, we began to use Arduino.  As someone who has never used an Arduino device or the software, it was an interesting project.  I do have a slight background in coding, but I only know a few basic things from languages such as Python.  Due to this background, I did slightly understand what Duncan was teaching us, but it was difficult adjusting to the language.  For the first example that we worked on in lab, we made an LED blink.  I followed Duncan’s instructions exactly, but initially, the LED would not even turn on.  I asked my neighbor for assistance, but he didn’t know what to do either.  We began to ask Duncan for help, but my neighbor bent the LED in a specific way, and it suddenly began to work.  After that, we were told to manipulate the program to have the LED blink “SOS” in Morse Code instead of 1 second intervals.  After changing some variables’ values and adding a few more lines of code, I successfully created the SOS message.  I then decided to have the LED spell my name.  It was quite fun figuring out what times to set for the delays and blink durations.  For the next activity, we were told to use alligator clips and aluminum foil to function as a touch sensor. 

We then ran a new program to light the LED when the aluminum foil was touched.  It fortunately worked.  We were then told to manipulate the program to cause different outcomes to occur.  I decided to make the LED light up when a force within a certain range was used on the foil.  If too much force was used, the LED would turn back off.

For the last activity for this lab, we were asked to make a storyboard for a potential Arduino device incorporating a sensor of some sort.  I decided to make a storyboard about a device that would help tone-deaf people see where their notes actually are on the scale in order to work toward improving their singing.

Overall, this was a fun activity using devices that I have no experience with.  I look forward to this week’s activity.

Continue Reading

Drew Zelac – Arduino Intro

I already had a couple Arduino Unos and sensors lying around my apartment from an IoT class my apartment-mates and I are taking this semester and from a demo I participated in a couple years ago. I first decided to just go simple and use an ultrasound distance sensor with a multi-colored LED, but then I decided I wanted to do something more interesting.

I went with a ultrasound sensor and a Piezo speaker/buzzer to create a backup alarm for a car. The point of this device is to mimic the backup sensors in most cars in the last decade or so, but with just an Arduino and a couple cheap devices attached instead of the multi hundred dollar sensor array that is installed in the cars.

I found a tutorial online for the Piezo speaker and got that working first. I used a 120ohm resistor and plugged the Piezo speaker into GND and Pin 8. With the code from the tutorial, it worked immediately.

I then added in the ultrasound sensor. I found another tutorial online about how to wire this and some code to get it to work. For this, I attached VCC to 5V, Trig to Pin 11, Echo to Pin 12, and GND to GND. This also went together without any problems. I just combined the code for the Piezo speaker and the ultrasound sensor and it worked.

I added in some conditional statements in the code to play a different frequency sound at different intervals, depending on the distance from the ultrasound sensor to the object it is sensing. After playing around with the frequencies and delay intervals, I thought it was doing a good job or sensing objects and alerting the user of the approximate distance to the object. All that was left was to clean up the code a bit, add in some more comments like how to wire the Arduino and devices, and credit my sources.

For this week’s project, everything seemed to go well. For the setup I did with the Piezo speaker and ultrasound sensor, I don’t think there was anything to be improved with the wiring. Code can almost always be improved, so I could probably clean it up a little bit more. Since I had done this kind of work before, it was fairly simple for this week. I’m looking forward to next week where the requirements will be more challenging and I can learn more!

I then created a storyboard for my invention.

My code is below:

//The ultrasound sensor code is by the Rui Santos
/*
* created by Rui Santos, https://randomnerdtutorials.com
*
* Complete Guide for Ultrasonic Sensor HC-SR04
*
Ultrasonic sensor Pins:
VCC: +5VDC
Trig : Trigger (INPUT) – Pin11
Echo: Echo (OUTPUT) – Pin 12
GND: GND
*/

// ULRASOUND SENSOR

/*
* https://programmingelectronics.com/an-easy-way-to-make-noise-with-arduino-using-tone/
Piezo Speaker Pins:
Positive – Pin8
GND: GND
*/

int trigPin = 11; // Trigger
int echoPin = 12; // Echo
long duration, cm, inches;


// PIEZO SPEAKER

// A sketch to demonstrate the tone() function
// Specify digital pin on the Arduino that the positive lead of piezo buzzer is attached.
int piezoPin = 8;

void setup() {
// ULTRASOUND SENSOR

// Serial Port begin
Serial.begin (9600);
//Define inputs and outputs
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);

}

void loop() {
// ULTRASOUND SENSOR CODE BELOW

// The sensor is triggered by a HIGH pulse of 10 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

// Read the signal from the sensor: a HIGH pulse whose
// duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
duration = pulseIn(echoPin, HIGH);

// Convert the time into a distance
inches = (duration/2) / 74; // Divide by 74 or multiply by 0.0135

Serial.print(inches);
Serial.println(“in”);

// PIEZO SPEAKER CODE BELOW

/* Tone needs 2 arguments, but can take three
1) Pin#
2) Frequency – this is in hertz (cycles per second) which determines the pitch of the noise made
3) Duration – how long teh tone plays
*/
if(inches < 2){
tone(piezoPin, 4500, 100);
delay(100);
}
else if(inches < 4){
tone(piezoPin, 4000, 100);
delay(300);
}
else if(inches < 8){
tone(piezoPin, 3000, 100);
delay(600);
}
else if(inches < 12){
tone(piezoPin, 2500, 100);
delay(1000);
}
else{
tone(piezoPin, 1500, 100);
delay(2000);
}

}

Continue Reading

Arduino Intro

When I started thinking of ideas for this project, I thought about making a light that would automatically turn on when someone walked into a room. My original thought ended when I thought about the problems surrounding the room’s door – it would be too complicated to maneuver around the closing and opening of the door. So instead I though about creating a nightlight of sorts. I have problems sleeping sometimes so I thought that I could use Arduino to my advantage. The code and example I came up with is basically just fade with multiple LEDs in it. When the lights go off, the lights would fade in and out slowly to create a calming effect. 

Here’s my storyboard (excuse my horrible drawing abilities):

 

The Arduino professionals online said there was an easier way to create this code, but I just went the long way to understand it better. I didn’t get farther than the code for this project, unfortunately, but I would like to later on.

I do have a problem involving an end parenthesis that I can’t find out the problem to, but I hope that someone else will be able to look at it later and find out where I went wrong. Arduino is relatively easy for a beginner to use, but it still has some difficulties for people like me who are not experts at coding. Once the software becomes more familiar, I think I can get better without entirely relying on the Internet. 

Continue Reading

Jacob Pruiett Arduino Intro Post

When I initially had started this project, I had initially decided to go for a simple concept: a “get out of the way” horn, using an active buzzer, and an obstacle detector.

I assembled my parts, and then began implementing them in my first set of code.

After some basic testing, I found that my initial iteration was wrong. The obstacle detector went low when it detected something, so I had to change that to correct it.

With that change, my initial project was working. But I thought that it would be boring with how easy it was to make and how little effort I needed for it, especially given my background, so I decided to change my project, whilst still incorporating what I already had. When going over the list of sensors we had, I discovered we had a laser and a button switch, and I hatched a new idea: a safer laser pointer that automatically shuts off and buzzes when pointed at someone!

After I added these sensors to my arduino board, I was ready to implement them into code. My code had gotten larger, so I couldn’t take a screenshot natively on the arduino coding interface, so I started to copy and paste my code into notepad and take screenshots after I hit what I believe to be important changes in my project.

On my first try, I had decided to have the button use an analog feature to turn on the system, by implementing the enable signal on the obstacle detector using an output signal from the arduino. However, I came to realize that this feature could be implemented more effectively in code by simply using that same input signal in an if else statement that locked the rest of the system’s logic behind that button press.

However, even after implementing it this way, I was still having issues getting the system to work. After some experimentation, I realized the same issue as with the obstacle detector also applied to the push button. So I had to switch the turn on case from high to low.

After that final change, the system worked well! Here’s a video demonstration:

A little difficult from a usability perspective, but for a bare-bones prototype it did a good job in my opinion. I was pretty at home throughout the making process this time, so I didn’t really find any part to be too difficult, the only problems I had were the same as in any other coding project with minor niggling issues that needed to be debugged. I found the process to be fun, especially since I hadn’t used most of these sensors before. In addition, the resources provided for this assignment were very helpful and informative, so learning these new sensors was a breeze.

Continue Reading

Arduino Intro Assignment – Mohammed Faiz Patangia

For this assignment, we had to work with an Arduino. I was very excited for this assignment because it was my first time working with Arduinos. This assignment was very interesting, and I had a good time creating circuits, with Arduino in it. In the class, we worked on two to three different examples. In all the examples, understanding and changing the code was not at all challenging for me. Sometimes, I faced bit of a challenge in creating circuits and understanding the entire resistor logic in the circuit. However, the entire process went smoothly.

Example from Class

From the exercises that we did in class, the one exercise that made LED fade, based on the touch pressure, was very cool. It was very fun to change lines of code and see how the entire behavior of the LED changes.

For the second part of assignment, I created a circuit, whose input was a photo-resistor and output was an LED. The central idea of this project was that the brightness of LED will increase as the darkness in the room increases. If there is more darkness, the LED will be more bright. To create this circuit, I used a photoresistor, a LED, an Arduino, one 320 ohm resistor, one 10k ohm resistor, a breadboard, and few wires.

The entire circuit

With more darkness, the LED was more bright

 

The entire process was pretty straightforward. Since, there were may options available for input and output, I was a bit confused on what to chose. In the beginning, I chose photoresistor, and constructed the activity based on that.

For the storyboard, I designed it to give an idea on how it will help people, who may not be able to walk, turn on the light.

StoryBoard

Overall, the entire assignment was very interesting and a good learning activity. I enjoyed the process.

Continue Reading

Arduino Introduction Assignment

At the beginning of the assignment I wanted to make some kind of arduino using a motor as the output. My first idea that I wanted to try was using a touch sensor to control the speed of the motor. This theoretically would allow you to change the speed of the motor based on how hard you press the sensor. This gave me the idea of having a touch controlled handheld fan. To do this I looked at the touch sensor lab example we looked at in lab and tried to translate it into the motion of the motor. The initial code I tried is below.   

Unfortunately, this code didn’t work out as I expected it to, being that the motor would rotate fully after touching the sensor. Instead what had happened was the motor would move slightly and move back to it’s original position, as if the motor was just twitching. As a result of this I tested out the base code for running my motor to see if the code just didn’t work, which ended up being the case. After this I decided to look up how the control a motor with an arduino again, to see if I could find a different resource that could help me. After searching through youtube, I found some code that could help me, the modified code can be seen below.

  

Instead of spinning the motor like I wanted initially this code made the motor spin back and forth, the video below displays this movement.

IMG_0359

While not inline with me initial idea, it did give me a new idea. The movement reminded me of the scrubbing and cleaning. With that in mind my finished idea was to use a button to control a motor that would be attached to an arm with some kind of sponge or cleaning rag that would allow for the cleaning of surfaces without much human effort; as the storyboard below illustrates.

Unfortunately I didn’t have enough time to create an Arduino with both the button and the motor working together. Because of this if I did this project again I would like to give myself more time so I can actually test out a finished project so I can see how and if it works the way I want it to. Another thing I learned is that you need to be very specific when it comes to Arduino, as I stated before I had some trouble getting the motor to work, this was partially do to the code not being perfectly suited for the motor I had. If I had looked up the specific motor from the very beginning I likely would have saved myself a lot of time.

Outside of the issues I had, this project did let me see how an Arduino can be used to make different kinds of contraptions, theoretically. In my case it was an automated window cleaner and I’m interested to see what ideas my classmates had with their own Arduinos.    

 

 

Continue Reading

Left Means Yes, Right Means No

Assignment 6: Arduino Introduction

During this assignment, we are introduced to Arduino. Arduino is a small computer that a user can upload code to, to execute a task. For example, if one wanted to make a light switch, one could make it so that once a switch was hit, an LED would turn on. What one would have to do to an Arduino to make this happen is tell the Arduino (in C++) to allow power through a certain channel when the switch is turned on. Arduino can be as complex or as simple as you want it to be. For this reason, Arduino has a low barrier to entry, anyone can use it. 

Arduino Lab

I actually messed up and did not take any pictures of what I was doing during the lab so I will try and explain it all. Once we were given free reign to explore our options for Arduino, I examined a bunch of sensors. The fire sensor seemed the most comical but I did not have a flame source for it to detect. This lead me to discover the joystick and button sensors. Given my background of game design, I settled with these sensors. For the output of the game, I chose the 16×2 LCD screen. 

For the next hour in lab, I got nothing done. Not because I did not feel like doing work, but I couldn’t find any help online. I only wanted to power/control the LCD screen. Every tutorial for the LCD screen never showed how they plugged the jumper cables in. The text tutorials didn’t help either, they never specified what board they used (it matters!). I managed to find a proper tutorial once I explicitly searched “16×2 LCD screen Arduino Uno.” Overall, learning how to search for the information I needed was the only piece of knowledge I took out of that lab time (not bad!).

Arduino Freetime

Moving on, I messed around with the arduino a bunch in my free time. Most of the time I was just trying to get inspiration. At this point I had a slew of ideas, but didn’t know what was possible for me. A couple of the ideas were: a virtual keyboard, choose your own adventure, and a simple platformer. Once I found out how to upload text properly to the LCD I had an epiphany about a simple yet dynamic way to make a choose your own adventure game. 

Choose Your Own Adventure “The True Dichotomy” – Storyboard

“The True Dichotomy” is a chose your own adventure game that only used two buttons as the form of input. In the panels, when the LCD is telling the player “Right is ____, Left is _____”, the LCD is explaining to the player what the buttons mean now. When navigating, they mean no and yes. When in combat, they mean fight and defend. This could me modified in a myriad of ways, perhaps for an iterative assignment

Here’s a bunch of photos. 

 

Input being printed to LCD. 1 = button not pressed, 0 = button is pressed.

The moment when I had that epiphany. 

Picture 1. When no is pressed once. Picture 2. When no is pressed again. 

If I didn’t have to pay money for Arduino drafting software (TinkerCad didn’t have enough moduals), I would have made an image showing how I did my wiring. It’s nothing complex, I had a line for ground and line for power. The inputs were inserting directly into the pin holes. The importance of the two photos was to show that there is actual progression in the text when one of the buttons is pressed. WordPress wouldn’t let me past my code for security reasons so just click here. This setup would not work long term. I’m looking into a way to jump to points in the code using global variables as a point of reference. 

Reflection

Jeez, I haven’t touched C++ since high school. Coming back to C++ was just a frustrating as I thought it would be. Knowledge of other languages defiantly makes some of the process easier but makes other aspects even more frustrating. On the other hand, working with Arduino itself was a relatively new frontier. We have worked with circuits before but I still have trouble visualizing circuits in my head. It’s just something I need to tinker with to understand. Basically what I did for this assignment, tinker.

This assignment will be the one i choose to do an iteration on! I have this whole idea for an arcade cabinet that has the two buttons but three LCD screens. I plan on making a legit choose your own adventure game completely contained within the Arduino. I am thinking about buying a bigger LCD screen for more text while having two smaller LCD screens displaying what the two buttons currently do. This is going to be so cool if I pull it off! Once I find a good framework for my code, everything will fall into place. 

Continue Reading