Microcontrollers for everyone Quiz 1
Our Toy
- Arduino Microcontroller, made in Italy - Uses Atmel "Atmega 328" Micro controller unit - Comes in various models: Uno, Leonardo, Duo, Mega, Nano, etc.
8 ways to destroy your Arduino
- Connect > 12v power - Connect power backwards - Connect 5v supply to the 5v pin while powered by USB - Change collections while powered (risky) - Short I/O pins to ground - Short I/O pins to each other - Apply overvoltage to I/O pins - Short Vin to ground
Garden-Variety Computers
- Have processor (e.g., Intel), Memory (RAM and disk) - IOS devises -- keyboard -- Mouse -- Display -- USB port -- Network connection
Microcontrollers have...
- Low power - Limited memory resources - Digital out - Digital In - Analog in - Analog out - Serial port (USB) - 12C and SPI - Ethernet or wireless options - "Shields"
Floating point numbers
- These can represent scientific values, 6.02 * 10**23 (Avogadro). - They allow math computations - If they convert from a float to an integer, we chop off the fractional portion. - e.g., float abc; int j; - abc = 27.65 - J= (int) abc; // The value of J will be 27
Void
- This is special data type meaning "nothing". - Functions are declared as returning a data type, and if it returns nothing, it is declared as "void" - For example, void setpinmode() { pinmode(13, OUTPUT); }
Int a;
- integers are 32-bits - Can be plus or minus, ranging from -2 million to +2 million - Commonly used as counters or indexes on lists (arrays).
Data types
- viod - int - char - unsigned int - unsigned char - float - boolean
Microcontroller
A computer
Hardware vs. Software
Hardware (wiring): Connection to the bread boards, wiring to Arduino ports, Set-up Software (programming): Programming in Arduino language (C)
Microcontrollers do...
Sensing - Temperature, humidity, pressure, light level, rainfall, wind direction, wind speed, light color, ionizing radiation (nuclear), etc. Control - Turn things on and off, varying speeds and direction of motors Communications - sensed data and control feedback
Character
char a; - Stores a single character, a byte of information (8 bits). The binary value ranges from -128 to + 127. Also can store one text character, whose character code is its binary value. For example, 01000001 represents the letter 'A' - Also, can be an unsigned value: - unsigned char b; // ranges from 0 to 255
Unsigned int
unsigned int b; - Holds an unsigned 32-bit integer, which can range from 0 to +4 billion.