top of page
Blog: Blog2

WEEK 2- FRIDAY

  • Aug 4, 2019
  • 2 min read

Important for designers to speak the same language as programmers and developers.

Important points:

-5v red lead and blue lead connected to two positive and negative bases on bread board

-always comment your code

- {} () [] are all different



Pulse Width Modulation

~ = PWM - sending pulses to a light in waves


Coding

# define LEDPIN 9 (unchangeable) is a shortcut for 'int = LEDPin 9;'(changeable), it doesn't need a semi colon either

- capitals = means its defined (LEDPIN)


Difference between Digital and Analogue

Digital= high, low

Analogue= a 'wave form', 0 value and every value in between 5v, changing and multiple values


analogWrite = 8 bit,

digitalWrite= 10 bit,


Binary 101 (01101)

map(sensorValue, 0, 1023,0, 255) mapping the sensor value makes it dim more smoothly since the pre determined numbers are plugged in


Designing code: its all about choices

Basic sequence:

setup Input/Output -> start state -> wait for button (read button state, repeat) -> blink LEDs (switch on LED, switch off LED, repeat)


If, then, else:

If (value > testvalue) {

// code in here...

}


== means you're testing whether something is correct


Instead of a pulldown resistor for a button,you can use:

pinMode (pin, INPUT_PULLUP);


Button is HIGH until pressed when it becomes low

! = inverts the read


Boolean logic vs the tables of truth

AND && if variable 1 AND variable 2 are true

OR || if variable 1 OR variable 2 is true

NOT ! if variable is NOT true


Truth tables are useful: Mapping all the possible outcomes


Building complex statements: (4 Loops) 'Algebra'

eg. if (value >= 50 && (value<=100 || buttonX))

i.e. if value is bigger and doesn't equal 50, AND (value 2 is smaller than and doesn't equal 100 OR button x is pressed) something will happen...

The potentiometer was turned which relays values which are written on the screen.

The potentiometer was turned which turns the LED on gradually.

Both buttons were required to be pressed so that the LED could receive power.

A loop was created so that the LED would add a value through every loop and turn on and off repeatedly.

Comments


©2019 by Tayissa Walters. Proudly created with Wix.com

bottom of page