Computer Tech Post #5 – Learn to Code: Conditional Code and Logical Operators

After completing the topics of Conditional Code and Logical Operators under Learn to Code 1, I didn’t find any puzzles especially hard. Some were a bit more challenging than others, but after about 3 tries or so, I was able to figure them out.

Conditional code and logical operators make code easier and also specify what you want Blu, Byte, or another character to do.

Conditional code is making your character follow a set of commands if a situation, or boolean, is true. (A situation and a boolean are the same). For example, if you want your character to collect a gem if they are on one, you’d use an ”if” block and code, “if isOnGem ( collectGem() )” If this situation is possibly false, you’d either add an “else if” statement or just an “else” statement. For example, ”if isOnGem ( collectGem ) else if isOnSwitch ( toggleSwitch() ) You’d add an “else if” statement when there are multiple possible situations, but if there is only one other possible situation, you’d just add an ”else” statement with a set of commands and no boolean. When using ”else if”, if the boolean you proposed is true, than your character would follow your set of commands. On the other hand, for just an ”else” statement, there is no boolean because there is no other possible outcome if the first boolean was false. For example, if you want your character to move forward if there is an open switch on their left, but the boolean is false and the only other possible situation is that your character would be behind a closed switch, then you’d put an ”else” statement and add the commands: ”moveForward() toggleSwitch()”

Logical Operators are a feature you can add to your boolean to make the code more specific for your character. There are 3 logical operators I learned. One was the ”NOT” operator, which in code reads as ”!” Another was the AND operator, which in code reads as ”&&” Lastly, the third operator was the OR, which in code reads as ”II” These operators are supposed to change the boolean in a specific way. the NOT operator you’d use right in front of a boolean if you want your character to follow your set of commands if the boolean you proposed is the opposite. For example, “if !isBlocked ( moveForward() ) This would read as, if not is blocked ahead, move forward. The 2 other operators are the AND and the OR. The AND operator is used if you want your character to follow your set of commands when both situations are true. For example, if you want your character to collect a gem and toggle a switch when they’re on a gem and a switch, you’d use it that way. the OR operator is used when you want your character to follow your set of commands if at least one boolean is true.

6th Grade Tech – Post #5

Mr. Calvert has assigned a new project. We’re supposed to make three different light switches, mostly made out of cardboard and tin foil. After we finish making these switches, we are going to play a game with them.

The game is called the “Self-Driving Car.” The only other thing that you need to play the game is a deck of playing cards. This is how to set it up: first, you have to divide the deck into two, the cards face-down. Then, you arrange the three switches in a horizontal line facing you. After that, you are all set to play.

This is how you play: first, you flip the first card of each half of the deck over. If the card on the left is red, and if the card on the right is black, then you turn on the switch on the left. If the card on the right is red, and the one on the left is black, then you turn on the switch on the right. Lastly, if both of the cards are red, then you turn on the switch in the middle. The goal is to test how fast you can operate it, without making any mistakes.

Tin foil is conductive, so the switch works by having one piece of it connected to a wire with positive charges and another piece connected to a wire with negative charges. Those wires are connected to the LED light, so when the two pieces of tin foil touch, it’ll make the light turn on. Our switches are due this Friday. I already finished all of them, luckily. Here are some pictures of my switches and me working on them…


Rube Goldberg – Post #5

This is my 5th Rube Goldberg post. Nick and I have started building our machine this week. We tested some parts and found that it’s very challenging to get things to work. We have been working very hard and have had a lot of failures. Sometimes when we were setting up the dominoes, one domino would accidentally fall and knock down ALL the rest which was REALLY frustrating! Other times, the dominoes would be too close to each other, so when we started the machine they wouldn’t fall the way we want them to and that attempt would fail. We realized the dominoes have to be placed about 3/4 of an inch apart from each other to fall the right way. We also think we might need to replace the cardboard tubes that go taped to the wall with something more stable, or replace that step for something else.

Next time we meet, on Saturday, we will continue working on the step with the computer calling the phone and try to finish the design and start filming the entire machine at work. Last time we tried the phone step, the ramp was either too steep or not steep enough. The phone either would get stuck and not move down when called or slide down right away when we put it on the ramp. I hope we get a successful run this weekend. We really want to finish it!

Here are a few videos…

Video #1

Video #2

Video #3

Video #4