Книга: Arduino: Master The Arduino Basics
Назад: Chapter 7: Can Arduino Work Wirelessly?
Дальше: Conclusion

We have spent some time talking about the technical things that you can do with the help of the Arduino board. By this time, you should be familiar with some of the coding that comes with this board and how to do a few little projects to store information that you want and even to change how the LED lights work. But most people do not pick to work with an Arduino board because of all the technical stuff. They choose to work on it because they want to learn how to do some neat projects. Now that you have the basics and the technical stuff down, it is time to learn a few projects that can add some fun to working with this technology.

Heating Blanket

The first project we are going to take a look at is a heating blanket. These can feel nice and warm when you are dealing with a cold winters’ day, but they are expensive to purchase on your own. The good news is that if you purchase a few parts for the Arduino board and the material that you want to use, you can get this blanket up and running in no time. This one will also need a code to help it get started so make sure that you have a good USB cord to help you get it all done. Some of the materials that you need to make your very own heating blanket include:


Once you have had a chance to collect all the materials that you need, it is time to get started. So the first step is to sew up the hand warmer blankets that you picked out. You can design this to look any way that you would like so get creative and have some fun. Once that creativity is done, you will need to use your conducting thread to sew onto your board before connecting this to the positive side, which will be where the blue LED lights will be located. You will also need to take some time to sew together the negative parts if you want this to work.

Now you can grab your hook up wire, which will be the red wire that you have, and make sure to connect it to the positive contact of the board, making sure that it is on the side that has the positive side of your switch. It is good to use a parallel connection so that it will hook up to the positive part of your pad and also save you some hassle.

When you are done getting the positive side all hooked up, the next step is to get the negative part ready. You can bring out the black hook up wire to help connect up these negative parts of the board, so they are hooked up to the power source as well. Continue on so that these parts are all connected to the negative part of the switch.

From here, you can work on a parallel connection that will go all the way to the S leg of your MOSFET. When that is done, create another one that will go to the 10k resistor, going parallel as well. Now you need to take your 11th pin from your Arduino board and hook it up, so it connects with the G leg of your MOSFET. There should be a branch when you are done that ends up going parallel to the other end of the resistor. And finally, you will connect the D leg of the MOSFET to the negative parts that are on the heating blanket.

At this point, you will need to turn to your computer and work for a bit inside of the IDE. This will allow you to create the code that is needed for this project. The code that will make the board work and create a great heating blanket for you will include:




Hardware Connections:

-led1 = D9;

-led2 = D10;

-led3 = D11;

-button = D2;

-Mofset = D3;


int btnPin = 2;

boolean btnPressed = false;

int fetPin = 3;

int led1 = 9;

int led2 = 10;

int led3 = 11;

int mode;

void setup(){

// initialize the digital pin as an output.

pinMode(btnPin, INPUT);

pinMode(fetPin, OUTPUT);

pnMode(led1, OUTPUT);

pinMode(led2, OUTPUT);

pinMode(led3, OUTPUT);


// the loop routine runs over and over again forever:

void loop(){

// increment mode on depress, unless mode = 3, then reset to 0

if (btnPressed && digitalRead(btnPin) == LOW)

mode = mode == 3 ? 0 : mode + 1:

// Assign button state

btnPressed = digitalRead(btnPin):

switch (mode)


case 0:

analogWrite(fetPin, 0); // off

digitalWrite(led1, LOW)

digitalWrite(led2, LOW)

digitalWrite(led3, LOW)


case 1:

analogWrite(fetPin, 85); // 33% duty cycle

digitalWrite(led1, HIGH);

digitalWrite(led2, LOW);

digitalWrite(led3, LOW);


case 2:

analogWrite(fetPin, 170); // 66% duty cycle

digitalWrite(led1, HIGH);

digitalWrite(led2, HIGH);

digitalWrite(led3, LOW);


case 3:

analogWrite(fetPin, 255); // 100% duty cycle

digitalWrite(led1, HIGH);

digitalWrite(led2, HIGH):

digitalWrite(led3, HIGH);





Yes, this code may look a little long when getting started, but it does give all of the directions that are needed to get that heating blanket up and started. It will tell your blanket how hot it can get, with a few different settings placed in. The code will also instruct the blanket on how it should turn on and off, so you are able to get it to work for you. This provides you with a lot of different options for the blanket when you are done, and you are sure to stay nice and comfy during winter.

LED Light up Strip

The next project that we are going to work on is creating our own light up the strip. This will require the help of something known as an e-textile which can actually make it a bit easier to work on the project. To get this one done, we are going to create an LED light up with the help of LilyPad. The supplies that you can use to get this project done include:


Once you have had a chance to collect these supplies, it is time to get started. Take the needle and get it all set up with the conductive thread that we are using. You may find that placing the fabric in the embroidery hoop can help because this keeps it all in place while you are doing the work.

At this point, we need to work on making a positive trace. What this means is that we have to make a mark that goes from our source of power over to the positive part of our LED strip. You can start on this right beside the battery pack. You will be creating a place for the battery pack (but don't put it in there yet) near where the LED lights should be and make sure both of these are near each other. These will be helpful because you will be able to use them as the negative and the positive pins in your battery pack. 

Now, we need to ensure that we place the battery pack in the correct space before starting with the sewing process. You can first start with trapping the edge of your board into the fabric. You can do this by wrapping it up in the thread, about four times will be fine on each of your positive pins (there will be the first one that we talked about as well as a second one near the top of the Arduino board). When these pins are being sewn into place, you need to make sure that you keep the stitches pretty small rather than just doing one long stitch. This helps to ensure that the pack is going to stay in its place and you won't have things moving around and shorting out the circuits. 

Take some time to finish the stitching all the way through the positive side of your LED strip. You will have to check a few times to make sure that you are on the right pole. If you end up sewing on the wrong pole at any time, you will experience some issues because not all the LED lights will show up.

After you are done getting the positive side all sewn up, it is time to start working on the other side. To do this, you need to return from the current side of the LED to the negative part of your pack. You will basically be doing the same steps that we talked about before, but they will be done on the negative side instead to help get the whole package ready to work with the LED lights. 

Once you reach the end of this, you should take a few seconds to look at the project to see if there is any thread dangling anywhere on the project. If there is, you need to snip it off to avoid problems. You can also double check to see if your negative and positive traces are touching any other parts. If they are, you need to redo some of the stitches because it could lead to several issues when it is time to get the light working again. 

If you have checked over the whole project and you notice that it all looks good and your sides are placed together properly, it is time to take your cell battery and place it in the pack. Once the battery is inside the pack, the LED lights should start showing up right away. And at this point, you are done with your project!

Назад: Chapter 7: Can Arduino Work Wirelessly?
Дальше: Conclusion