PROject Python: Making a function

Quote of AWESOMENESS: “The function of leadership is to produce more leaders, not more followers” ~ Ralph Leader

Hiii!

Functions are so useful and cool at the same time and right now I’m going to teach just how to make one!

But, before we go there, what exactly is a function? It’s somewhat like a pre-made command that you get to customize yourself. For example, you wanted to make five circles, imagine you would have to make each circle repeating how big you wanted it to be, the color, locations, and others. But, if you had a function, you would make it so much simpler in just adding the code and copy-pasting the function.

Here’s the code for a function:

[rememberWHITESPACE is very important in Python]

# This hastag is a comment and won't affect the code
# We start making function by defining it with the word def
# The thing written inside the parenthesis is called the argument
# Remember to put the colon then the indentation will be proper, too

def list(alist):
    # Here, I'm setting the variable a to number 0
    a = 0

    # This is a for-loop and the i just stands for index 
    for i in alist:
        if i > 0:
            a += 1
        else:
            pass
    print(a)


# Here is the actual function in action!
# Test section
mylist = [2,-4,5,-16,-20]
mylist2 = [2,6,8,-4]
mylist3 = [-5,-6,-7,-8,10]


list(mylist)
list(mylist2)
list(mylist3)

This is just a simple example of what you can make of a function. Try it out! 

 

Don’t forget to be awesome!

Yours truly, 

L.O.A.S.H

 


 © Elizabeth Anne Villoria 

 

L.O.A.S.H’s Guide to (nearly) Everything: How to Make an Arduino Robot Arm

Level of hardness: Intermediate

I’m so excited!

This project is just extremely awesome and awe-spiring that I can’t wait for you guys to try it out!

We. Are. Going. To. Make. An. Arduino. Robot. Arm!!!!!! I know, I know super cool. Now, without further ado, let’s jump right into this project.

The following are what you will need to gather:

  • 1x Arduino UNO Board
  • 1x Breadboard
  • 1x USB Cable Type A/B
  • 2x Button
  • 2x 10k-Ohm Resistor
  • 3x Potentiometer
  • 5x LED (A.K.A light-emitting diode, A.K.A miniature looking light bulb-ish)
  • 5x 220 Ohm Resistor
  • 20x Jumper Wires

Step 1:

First, let’s start by putting the potentiometers, the buttons, and the LED’s on our breadboard.

Step 1.jpg

We will be placing 3 potentiometers, 2 buttons, and 5 LED’s. For your reference, the photo above can help. Yes, I did say 5 LED’s but I forgot to place the fifth LED in this photo, but you should put 5.

Here are some important basics to understand about an LED:

Cathode (-, shorter side)

Anode (+, longer side)

0-02-01-011b6222b4e99533565c045f5f76d88f8eee9d81ad4743fa7754a214abc03bab_full.jpg

Step 2:

RESISTORS. Resistors. resistors.

Step 2.jpg
Here, in this photo, I’ve put 5 LED’s

Place five of your 220 Ohm Resistors on each of the Anodes (+) sides of each of your LED’s and the other end of the resistor to the negative side lane on your breadboard which we will later connect to the GND on your Arduino board. I’ve placed another photo above showing where I’ve placed my 220 Ohm Resistors.

ARDUINO1.jpg
Here, I circled each of the legs (Anode side) which I connected my 220 Ohm Resistors to

Now, take both of your 10k-Ohm Resistors. You will have to place one side of your resistor to only one of the button’s leg. Do this for both buttons. Here is another picture but of the buttons and resistor placing.

0-02-01-a4dc3cdadbe48e9699da5c60eaaf009fd209b963a449b08300cb864f4790b9c9_full.jpg

We have finished placing all the resistors we will be needing in this project. You guys are doing an awesome job, btw!

Step 3:

This step will be really quick.

All we need to is get two jumper wires, first. Then, connect the Negative lane on your breadboard to your GND on your Arduino, and, the positive lane of on your breadboard to the 5V on your Arduino (you can find this right beside the GND, usually).

0-02-01-6fd074bc2363a5d4f7eeac736e13aa2c95fdaaf5a41a127461e58cbd6de4e417_full.jpg
Here is the overview of everything so far

0-02-01-9f5ae76933b271ca278f51d0408598871b44bec7e1f6ffe72d9769cfe432e262_full.jpg

Done with this step. Great job!

Step 4:

For this step, you will be needing 5 of your jumper wires.

We will be connecting each of the LED’s on the breadboard onto the Arduino UNO board with your jumper wires.

0-02-01-e005f0f6751aba57f242a36978d87a1d43181bbb475954d45b82c2a3813de93d_full.jpg

Here is the first LED I connected. We will be connected the other leg (cathode, shorter side) of the LEDs to these numbers on the Arduino in order:

  • 2
  • 3
  • 4
  • 7
  • 8

I will also be numbering the LEDs on the next photo so that it will be easier to know which we will be connecting to which.

0-02-01-9ef28dac8b7d5bc5fd62e992e07553b3203f81f692aeb6eb5360a8dcfbb8f082_full.jpg
This shows where I connected my jumper wires to the LEDs

We will connect:

  • LED 1 to 2 on the Arduino board
  • LED 2 to 3 on the Arduino board
  • LED 3 to 4 on the Arduino board
  • LED 4 to 7 on the Arduino board
  • LED 5 to 8 on the Arduino board

0-02-01-b902992761fc2b9afa0ea746f62a966d45e98e808df225a0e38bfd5f7da3f940_full.jpg

Step 5:

I know that wiring could be a tedious job but it’s okay because I know you can do it.

Wiring is very important because it connects. It works as that bridge that can help cars go back and forth and connect with other cities. If you have a bulb and a power source you can’t just put it beside each other or clink it together to light the bulb up (even that would be super cool if that’s how easy it was), you need to connect it through wires. So, let’s continue? Yes.

In this step, we will be wiring the buttons and the potentiometers.

0-02-01-6fb24a73cf9e51511a1fe448099e10ea294b31eaaa6066c8dc9c5388a2a931f4_full.jpg

Here in this photo I got two jumper wires and connected one end to the remaining unconnected leg of the buttons and connected the other side of the jumper wire to the positive (+) lane on the breadboard

That was easy, wasn’t it?

We are nearly done!

Let’s start wiring the potentiometers now.

For the potentiometer, it’s going to be slightly harder.

0-02-01-f9a7e31d477692dcf148d5c2c74ab36ebda7f2d66e706d430d5ad2f6ea9eece8_full.jpg

In this photo, I’ve connected 3 jumper wires to the right side of the potentiometer then connected the other end of the wire to the Negative lane of the breadboard (A.K.A GND).

0-02-01-e83476876ad48bd0734014f0ae9b085c86dde636d44ad971e0b87cc2bfd5f27b_full.jpg

And, then, I got 3 more wires and connected it to the left side of my potentiometer then connected the other end to the Positive Lane on the breadboard.

0-02-01-e2341ee51a513ec1ceb48087e988986118cc7da8657b372b0e0892d09b7838a7_full.jpg

I’ve added the numbers on top of each potentiometer so that it’s easier to understand how to connect it to the Arduino.

As you may see on the picture to your left, I’ve added 3 white jumper wires to each of the middles of the potentiometers because we will connect this to the Arduino Board. Connect potentiometer 1 to the A0 on the Arduino UNO Board | Connect potentiometer 2 to the A1 on the Arduino UNO Board | Connect Potentiometer 3 to the A3 on the Arduino UNO Board.

0-02-01-b7140f69d3dca97af218c8d6d50cfdd2c516e1bd2f1a17e821fbfef945116f1a_full.jpg

Step 6:

0-02-01-c6963f33b5cc690153f696b05333e7086d58d45d3856e00540cec17fff73b77f_full.jpg

In this step, grab two more jumper wires and connect both ends of the lanes on each side of the breadboard to each other. I used the black and red wire here.

You will need to connect the Negative lanes on each side to each other and the Positive lane on each side to each other.

Tada! Next step.

Step 7:

Seeeeervoooo Moooootooooors.

We are nearing the last of our steps. KEEP GOING!

0-02-01-46631c0308f650ba97afc343709fdbb27f10dbd4643fe021bee9c020e70b9ffa_full.jpg

We will add the servo motors to our breadboard and I put mine side by side to each other.

I connected three jumper wires each for three of my servos, meaning 9 jumper wires in total.

About servo motors in Arduino:

  • They usually have 3 plug pins (this is where I connected my jumper wires to)

0-02-01-edf9b558c6d4432ad44cb70ca0e47ac313c1cd48d4732033f7e41d77cfc0058d_full.jpg

Take a look at your servo motor. You will probably notice there are three colored wires. Each color represents 3 different things. The colors could actually be different sometimes but, as you see here, my colors are brown, red, and yellow.

  • The brown is the Ground/Negative (-)
  • The red is Positive (+) [This wire is usually located at the center of all the three wires]
  • The yellow is the Signal

Your wires on your servo motors might be different and you might be thinking “WHAT!?!?” but it’s okay (that’s what I thought too) here is how you can compare it to mine to find the similarities:

  • The Ground/Negative is usually | Black or Brown (in my case, it’s brown)
  • The Positive is always Red
  • The Signal can be either | Orange, Yellow, or White (in my case, it’s Yellow)

Better?

Awesome, let’s proceed.

0-02-01-46631c0308f650ba97afc343709fdbb27f10dbd4643fe021bee9c020e70b9ffa_full.jpg

These are what you need to connect with your Servos:

  • Connect each of the GND/Negative (Black or brown wire) on each of your servo motors to the positive lane on your breadboard (I used a white jumper wire, check the photo above for reference)
  • Connect each of the Positive (Red wire) on each of your servo motors to the negative lane on your breadboard (I used an orange jumper wire)
  • Lastly, connect each of the signals (Orange, Yellow, or white wire) of your servo motors to: 5, 6, and, 9 on your Arduino
0-02-01-6dec16957b4bf711bfaab5ca160c05ce4352e7d5c718d7ccc6d0f65f2e468470_full.jpg
I know it’s a bit of a mess. But, there are three wires that you can find colored: 1x black & 2x green. These are the wires that connect to the Arduino

0-02-01-9a06e49e7a630816019854857d1f2d4f1a89238088779dac7ad18023d117a46f_full.jpg

Step 8:

This is our last time! Congratulations!!!

Connect your Arduino to your computer, fire up the Arduino app on your computer, copy paste the code below and press Upload.

Screen Shot 2018-01-20 at 15.01.04

Screen Shot 2018-01-20 at 15.01.15

Screen Shot 2018-01-20 at 15.01.23

Screen Shot 2018-01-20 at 15.01.32

Screen Shot 2018-01-20 at 15.01.42

Screen Shot 2018-01-20 at 15.01.49

Screen Shot 2018-01-20 at 15.02.07

Now, the challenge whether you choose to accept it or not is to build your own robot arm out of cardboard or you can check this —-> here which was made by Ryan Chan. Shoutout to him, btw. I hope you enjoyed this! I certainly had an awesome time and I hope you did, too!

You can teach others and share your awesome knowledge on building an arduino robot arm, I give some bragging rights.

Thanks so much for reading!

Yours truly,

L.O.A.S.H

Ibajay Journey: Second Day, Mangrove Exploration

Circa: JUNE 7, 2016

Second day

We went back to the park to check out our traps and the mangroves. This time, we came at 8:00 am. The sun was shining through the trees and the birds were chirping beautifully. We arrived at our trap site.

Did we catch any?

From afar we could see the trap was touched by something. The trap was deactivated, but by what? We walked down the muddy stairs and to the traps. One was under a bridge and the other was near the oldest tree. We got both the traps and checked them. We were able to peek through a small hole which was created for inserting the paddle. We saw a claw and an antenna. It was possible that it was just a crab, but I guess we’ll find out soon.

Frightened Creature

We slowly lifted the opening for the creature to get out. On the other end of the trap, we put a container to catch it. We didn’t know exactly how the attitude of this animal was. We prepared to catch it as a mix of excitement and curiosity took over. We surrounded our trap and waited patiently. Silence filled the air. You could probably hear a leaf fall from a mile away.

But, fortunately for us, slowly it came out. It meaning the mud – lobster. We closed the lid of the cylindrical container. The mud – lobster pushed the cover and was trying to claw its way up. Very intelligent animals, indeed. It stopped moving when I ventured toward the container it was in. I put a small stick in front of its face to see what it would do. It didn’t move but after a few seconds, it loudly tried to clamp it with both its claws.

Plot 2

After capturing the mud – lobsters we went back to our second plot. We measured the starting of the plot and went further inland. We noticed there were a lot of Nypas on one of the mounds. We studied how the other mounds were surrounded by other kinds of plants. We were trying to measure the other mounds on the other side but it was covered with Acanthuses and Nypa Fruticans. After measuring all the mounds visible, we went back to the old tree.

New Plot

Since we found some interesting things happening on this small piece of an island with the tree, we decided to make a plot there. The circumference of the whole island was 18 M 77. We wanted to look at the mud – lobster better so we decided to let it go for awhile. Scared it would run, we tied a small piece of string to its body creating a leash. It looked pretty funny, leashing a lobster. After realizing they are actually very, very slow we just unleashed them. We barricaded their surroundings with small logs and pieces of stick we found lying around, even an old boot. The biggest mud – lobster kept escaping and trying to get into one of the holes. They both stopped moving so we put them back into their containers.

Traps

We decided the best idea was to set up the traps in the same mound to check if more than one lobster lived in it. After setting up the traps, and nearly catching some mudskippers, we rested on top of one of the open bridges. This bridge wasn’t completely finished so the sides had no railings yet. We spotted a medium-sized jellyfish that got itself tangled up in the vines. It was beautiful and after few minutes untangled. The cool breeze was passing as I stared through the binoculars. I could barely make out the sweet songs of the birds anymore. The sun started to fall and the night was filled with partying crickets.

Night Sky

It’s been two hours since we left the trap and made a decision to check them out. We steadily made out our way with some flashlights. The ants started to appear everywhere, we could barely touch the railings for support. There was this one time when we found five ants all tearing up one ant. It was crazy. We did our nocturnal prospection for maybe 45 minutes. We went back and forth quietly trying to spot some mud – lobsters burrowing away. On our way out we closed all our lights and stared into the sky. All the stars were out, and the moon was like a shimmering diamond. We told each other stories and left back to go home.

THUNDER!!

We’ve finished freshening up and we were just laying around studying. We could see the flashes of lightning through our window. There was no after sound with the lightning in a long time. The silence in the air was occupied by the sound of the aircon. All of a sudden a loud boom came screaming through my ears. I jumped, accidentally pulling off my earphones with it. We all looked at each other, surprised. The ground shook for me, it felt so close by. It was past 9:00 pm so we decided to sleep already.

~ Juvenile L.O.A.S.H

In Danjugan, Day 1: Exploration of the Island (part 2)

Day 1 (again):

Where was I? Oh, yeah…

We reached our destination! Yay. We were assigned to drop our bags over at one of the tables before anything. I remember one of the first things that we were all told was about the eco toilet (which the place where you do the number 2). Btw, it was already lunch. Time to eatttt. The other kids went into the dining area already while I took a quick glimpse of the place. When I decided to join the rest I went up the small bamboo steps up to the dining area which was hovering over (with the aid of some concrete) the Moray Lagoon. The water was so clear and blue. Also, the reason to why the Lagoon had a Moray in it was because if you looked at the water you could see Moray Eels. They can look scary sometimes but also they made the water look lively if that makes sense.

As I stared at the dining area, I had no idea where to sit. Most of the tables were taken and I didn’t know where to sit. Also, I didn’t plan on sitting alone. And as I’ve mentioned before, most who came were with a relative or friend so they had a person to eat with.

I gathered my strength and decided to take a seat with a table that had 3 occupied seats. I said “hi” and we started to have a good conversation. In just a few minutes we all became friends.

While everyone finished their remaining lunch, one of the camp directors started introducing all the other camp members which we call ALs. Apparently, we were gonna be split up into four teams. Each team would be lead by one adult leader (or AL). All the AL’s each took turns in introducing themselves and their background about where they came from and why they’re in the camp. There was one scientist who came from Germany and who was going to teach us about fish and corals.

Also, we were told that for the answers that we got correct or for the behavior or actions that we did right we would get points for our teams. And of course, with being late or others our points could go down. Once we finished acquainting with our teams and AL’s, we all went out of the dining cabana and made a circle. Apparently, we were going to say our name and a dance. It went one way around the circle. When it reached my turn like everyone else, I shouted “LIBI!” and did this awkward dance move which everyone then shouted “LIBI!” and the same move. This was just a fun way to acquaint ourselves with everyone.

There are actually four cabanas for all the campers. Two are for the girls and two are for the boys. One of the main rules is that no boys allowed in the girl’s cabana and vise versa. There were about 5 girls in my cabana while there was about 7 in the other girl’s cabana.

When we finished preparing ourselves for swimming and trekking, we heard our call (KUUUUUWEEEEE (which is a bird call which came from one of the ALs)).

Most of the things you would hear (from the Camp Director) when all the campers gathered are “look at me if you could hear me” or “clap twice if you could hear me“. These were some of the ways to gather the attention when everyone was being loud.

Anyways, back to the learning center. We were briefed about the island and the different beaches and lagoons. At this point, there were a few questions in which you could earn a few points from. We were also briefed about first aid and other things to be aware of while we do our trek. We were ready. We were instructed to bring our snorkel, other gear (if you have any), waterproof bag (if you need for things you want to bring which you don’t want to get wet), water bottle, sunscreen and insect repellent. If you forgot to bring your snorkel gear (just like me ;D) don’t worry! You could rent a snorkel or any other gear at one of the gear stall area on the island. All you have to do is sign your name and Tadaaa!

Because each team had its separate color (in my case, color white), we had to wrap a different color per team on the snorkel. We then headed out team by team. While passing one of the bridges, we saw big sea urchins at the bottom. Wanna know why they were hanging out there? Well, above the bridge is a bat cave. And, the bat cave goes all the way down. The urchins liked the bat poop. Mmmm.

We passed by turtle beach and typhoon beach. And, after waiting for the other teams at some sort of bar (rehydrating ourselves with some water), we swam to the beach reaching one of the far rafts with the ALs and our teams.

Good thing for the tapes wrapped our snorkels when the others were still snorkeling you could still identify which ones were part of your team. We were shown the different corals and fishes. It seemed to explode with colors! It was beautiful.

We made our way back with a sunset trek. The sky was orange and the light slowly made its way down. Our night ended with some dinner and finally a bath! Even though it’s only one bucket per person, I agree that it’s a good amount to use. Here’s the tip, use the tabo twice to wash away the sand and wet your hair, then shampoo and soap, then another wash. Done! You’ll probably have some leftovers.

Just before sleeping, we all sat around in a circle at the dining area after pushing away the chairs and tables to the side. One of the ALs told us that this was our community building and that it will be one of the only times we’ll be doing it. As we sat down in a circle, we shared what we enjoyed throughout the day and something we liked to build in our community. On a sheet of Manila Paper, a circle was drawn. Inside the circle, we would throw out ideas we would like to have in our community, an example, trust or respect for others.

Screen Shot 2017-06-24 at 08.27.58

The picture above is the paper that we all made. In our community, we had the power of choice, the power of two feet, and the power of experts. Inside our community, we wrote down words we wanted for our Danjugan community. As you may see above, we wanted positivity, trust, support, friendship respect, understanding for each other in our Danjugan family.

After this, we went to our cabanas and slept. Well, the truth is I talked to my roommates (cabana mates) before sleeping. We were having a small debate whether or not we should leave the chips in the cabana. Laziness kinda went around and we decided to leave the food in the room.

We put our mosquito nets properly around our mattresses and finally slept. 😉

(to be continued)

~ L.O.A.S.H