ComSci Final Second Test
Know how to make an array
A group of variables All with the same NAME But identified by unique numeric indexes (indexs) Always start at 0 The last element in the collection has the index that is one less than the number of elements in the array. For example an array with 5 elements: arr[0], arr[1], arr[2], arr[3], and arr[4] arr[5] does NOT exist
Example of an array
for( int i=0; i<8; i++ ) { // This design pattern makes more sense now digitalWrite(ledPins[i],HIGH); delay(100); } Replaces 16 lines: digitalWrite(ledPins[0],HIGH); delay(100); digitalWrite(ledPins[1],HIGH); delay(100); digitalWrite(ledPins[2],HIGH); delay(100); digitalWrite(ledPins[3],HIGH); delay(100); digitalWrite(ledPins[4],HIGH); delay(100); digitalWrite(ledPins[5],HIGH); delay(100); digitalWrite(ledPins[6],HIGH); delay(100); digitalWrite(ledPins[7],HIGH); delay(100);
Know what a for loop is
Goes in the loop OR setup function Loop function: Fill in the values below to use PWM to make the LED connected to pin 10 slowly get brighter from OFF to FULLY ON: for( int i=0; i < 256 ; i++ ) { analogWrite( 10 , i ); } Setup Function: Fill in the blanks with the appropriate code to put each of these pins in OUTPUT mode: for( int i=0; i < 14; i++ ) { pinMode( i, OUTPUT ); }
Know what input pullup is
Input pullup involves using a button to complete a circuit. Unpushed (default state) Up Circuit Opened When wired in INPUT_PULLUP: HIGH
Know the range for analog read
0-1023
Know about signals and messages
All signals are ANALOG Due to the REAL LIFE nature of signal transmission... digital messages are transmitted over: light (fluctuations in color/brightness) sound touch electrical pulses radio waves Messages are EXACT and can be digital or analog. Digital - numbers 0 and 1 Analog (exists on a continuoum) - temperature, distance, light level, color, sound / tone, volume
Know the difference between analog and digital
Analog - 0 - 1023, 60%, etc Digital - yes or no, on or off, 0V or 5V
Know how the map function works
It uses ratios to compare
Know what PWM is
Pulse Width Modulation Allows the system to SIMULATE analog output. PULSE - beat WIDTH - DURATION because signal waves exist over time, not distance MODULATION - change
Know about motors
Rotational motion. Electric motors use electromagnetism to make motion DC Electric Can Motor -Spins in one direction forever at a variety of speeds. -Fast -Can alter speed -Infinite rotation -Two wires, just needs power -Can not start and stop "on a dime" -Rotates in one direction -Good for making objects move and longer spins such as for gears, pulleys, propellers Servo Motor -Can rotate to a specific degree position, but usually at one speed and cannot go around in one direction forever. -You can set the motor to move to a specific degree position. -Uses specially coded digital instructions through at least 3 wires to enable directional motion. Gear Motor -gear motor is a basic DC can motor you find in toy, RC cars, etc with a gearbox attached to it to increase torque -Works as an electrical current is passed through a coil creating an electromagnet -The repelling force causes rotation. -When the motor is energized, rotational motion occurs. -With PWM, you can vary the speed of the motor's rotation. -Use digitalWrite() or analogWrite() to activate motion.
Know what kind of signals the arduino can sense
The Arduino can only sense digital inputs, however analog inputs can be emulated
Know about digital read command
The command you would need to code if there is a digital signal on pin #8 you wanted to read the state of
Know about analog write
Which of the following commands would make a DC motor connected to pin 9 spin at about 50% speed
Know what a potentiometer is
Think of it as a volume knob It changes resistance It works by "divides" the constant electrical signal As you turn the knob on the potentiometer, we detect a different amount of input voltage on the analog input sensor pin on the Arduino
Know what analog read is
analogRead() //***Function reads input voltage*** variable=analogRead(pin);
Know about analog input
analogRead() Function reads input voltage variable=analogRead(pin); example: sensorValue=analogRead(A0); After this line, the variable sensorValue contains the value that was read at that moment.