Python 2

8) Some more things to know about strings are the multiple ways of escaping double quotes in a string such as the /n character.

/n = put’s text after it on a new line

/t = tab’s in the following text on the same line

\\ = add’s in \ into the string

“”” = multiple lines of a string

* = creates a list

 

wireless pump

So we bought a pump and a 12v power supply with 1 amp output and connected the pump up to my relay circuit and pin 8 of the Arduino.

Note* solder header pins onto the wires of the pump for easier connections.

Using my wireless board and code from pervious tests I created a wireless pump that turns on when you press the button on the website and turns off when you press the off button on the site.

Python

http://learnpythonthehardway.org/book/ex1.html

A great guide to help start up with python.

1) print (“this is a string”)

It will print to the Python Shell or if you want to run in in the terminal you can by typing in: python followed by the file name. (Make sure your in the right directory).

Any errors in your code will be brought to your attention by the terminal when you run your script and it will also print the line the error is on.

 

2) Commenting out on python is just like any other programming language and uses a # to comment out single lines.

3)

  • + plus
  • - minus
  • / slash
  • * asterisk
  • % percent
  • < less-than
  • > greater-than
  • <= less-than-equal
  • >= greater-than-equal

To do maths or equations with python, you can write in the numbers and use the expressions above.

4) Variables in python are the same as any other programming language and are set above the code for global use.  Multiple word variables can be written with _.

Also an = is an assigning expression assigns the value on the right to the variable on the left, eg, car = 5.

5) Format strings, these are like normal strings but have variables embedded into them. To use a format string you have to use “string” rather then the ‘string’ , and to write one in the program you”

“string here” % variable name

The % is a module key which add’s in variables to the line.

6) Strings and text, this section describes how we can use combine strings””, variables, numbers and operations all together for example:

hilarious = False
joke_evaluation = "Isn't that joke so funny?! %r"

print joke_evaluation % hilarious

This would print “Isnt that joke so funny False”

7) “text\ntext\n”

This will output text into a new line /n stands for newline character

Another extra to strings is the :

"""
There's something going on here.
With the three double-quotes.
We'll be able to type as much as we like.
Even 4 lines if we want, or 5, or 6.
"""

LED parallel

Setting up LED ‘s in parallel is extremely simple and the best way to power on multiple Led’s. It means you only need 1 connection to the negative and one to the positive.

It also means each LED gets the full 3v to it rather then a section of the 3 volts.

Python 3

Something I should have started learning a long time ago is python, and now this project is starting to enter python territory it seems like the best time to learn it.

There is a massive difference between Python 2 and Python 3 in terms of the syntax used:

http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python/python2python3.pdf

AC vs DC

In this post I shall be noting down the differences AC voltage and DC voltage.

AC: Stands for alternating current  and travels in whats called an sinusoid or wave like pattern.  This allows the current to flow in an alternating repetition, with the up curve being positive and the down curve being negative.

Ac is what powers your mains or anything that gets powered from far away as the wave pattern can travel further then DC’s straight line current flow.

DC: Stands for direct current given it’s flow of current which can be visualised by a straight line which moves in one direction. This current travels at a constant speed which makes it perfect to control the voltage output which is why batteries are DC voltage and that’s why a lot of  components/toys take DC voltage.

 

http://engineering.mit.edu/ask/what%E2%80%99s-difference-between-ac-and-dc

Multimeter

How to use a multimeter. In this post I am going to quickly inform you how to correctly use a multimeter.

  1. There are multiple settings you can set depending on what you are testing, such as: Voltage dc, Ohms, Voltage Ac, Diode and amps.
  2. Voltage DC is there to measure battery operated devices or anything that gets it’s power source not from the mains.
  3. Voltage AC will be for mains electricity or anything powered from a great distance.
  4. Ohms is to measure the resistance of components such as resistors.
  5. Diode setting is to read the gate on the diode as it only allows voltage to travel in one direction.
  6. Amps measures the amps of a component.

The relay circuit

So I went to maplin and bought a 6 pin relay which works like :

To set up a circuit with this type of relay you need:

  1. 5v relay
  2. transistor
  3. diode
  4. resistors
  5. wires
  6. led
  7. push button
  8. 9v battery

To set this up you:

  •  Put the relay in the middle of the breadboard
  • Have the push button at the bottom middle of the breadboard powered with a 220 ohm resistor and linked to one of the power pins on the relay.
  • A diode goes from one coil to the other one with the bar end on the side of the power.
  • A transistor goes connecting pin (left)  goes onto the coil (non-power side), base (centre) goes to power and the last emitter pin goes to ground, with the other power pin.
  • On the n/o pin put and led and ground it with a resistor.

Now when you press the switch the LED comes on