Programming Flashcards

1
Q

map()

A

map(value, fromLow, fromHigh, toLow, toHigh)
Re-maps a number from one range to another. A value of “fromLow” gets mapped to “toLow” and a value of “fromHigh” gets mapped to “toHigh”. Ex) an analog value to 8 bits (go from range 0 to 255 to range 0 to 1023)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

analogReadResolution()
analogWriteResolution()

A

analogReadResolution(bits)
In some arduino boards (like MKR) the default read resolution is 10 bits but has capabilities of up to 12 bits. (write default is 8 bits but can go up to 12) You can set the resolution you want by choosing the argument (bits). (you might be able to do it in uno, havent tried)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

noTone()

A

noTone(pin)
Stops the generation of a square wave triggered by tone(). Has no effect if the tone hasnt been generated.
(if you want to have different tones on multiple pins, you might have to call noTone() on one pin before calling tone() on the next)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

pulseIn()

A

pulseIn(pin, value, timeout)
timeout is optional, default is one second.
Reads a pulse (either HIGH or LOW) on a pin. If value is HIGH, the method waits for the pin to go from low to high, starts timing, then wait for the pin to go to low and stops timing. Returns the length of the pulse in microseconds or returns 0 if no complete pulse was received within the timeout

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

shiftIn()
shiftOut()

A

idk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

tone()

A

tone(pin, frequency, duration)
duration is optional, otherwise until noTone() is called.
Generates a square wave of the specifies freq. (and 50% duty cycle)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

different delays (pauses in the program)

A

delay(ms)
delayMicroseconds(us)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

micros()
millis()

A

time passed since the arduino board began running the current program.
micros() resolution of a few microseconds. Goes back to 0 after 70 minutes
millis() resolution of milliseconds. Goes back to 0 after 50 days

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

constrain()

A

constrain(x, a, b)
constrains a number to be within a range.
x is the number to constrain. If x is between a and b, then x is returned. If its below a, a is returned. If its above b, b is returned.
Dont have operations inside (), it can yield incorrect results. Only values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

max()
min()

A

max(x, y)
min(x, y)
returns the larger or the lower of the two numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

sq()

A

the number to the power of 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

isAlpha()

A

isAlpha(thisChar)
Checks if the char is a letter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

isAlphaNumeric()

A

isAlphaNumeric(thisChar)
Checks if the char is a letter or a number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

isAscii()

A

isAscii(thisChar)
Checks if the char is an ASCII character

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

isControl()

A

isControl(thisChar)
Checks if the char is a control letter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

isDigit()

A

isDigit(thisChar)
Checks if the char is a number

17
Q

isGraph()
isPrintable()

A

isGraph(thisChar)
Checks if the char is printable with some content. Dont know the difference between the 2 methods

18
Q

isHexadecimalDigit()

A

isHexadecimalDigit(thisChar)
Checks if the char is an hexadecimal digit (A-F, 0-9)

19
Q

isLowerCase()
isUpperCase()

A

isLowerCase(thisChar)

20
Q

isPunct()

A

isPunct(thisChar)
Checks if the char is a punctuation (so comma, semicolon, exclamation mark etc)

21
Q

isSpace()
isWhitespace()

A

isSpace(thisChar)
Checks if the char is a space, newline, vertical tab etc
isWhitespace(thisChar)
Checks if the char is a space character

22
Q

random()

A

random(max)
random(min, max)
returns a number between min and max-1

23
Q

randomSeed()

A

randomSeed(seed)
seed is a non-zero value (coz 0 is default)
initializes the random number generator. Its always the same. Use seed = analogRead() on an unconnected pin for a random number seed. Use this method in the setup method.

24
Q

bit()

A

bit(n)
computes the value of the specified bit???

25
Q

bitClear()

A

?? sets a 0 to a value

26
Q

bitRead()

A

bitRead(x, n)
Reads a bit of a number. x is the number from which to read, n is which bit to read, starting at 0 for the least-significant (rightmost) bit.

27
Q

bitSet()

A

?? sets a 1 to a value

28
Q

bitWrite()

A

?? writes a bit to a value

29
Q

highByte()

A

kjdf

30
Q

lowByte()

A

kjsd

31
Q

How do you program PWM

A

If connected to the PWM pins, you can write analogWrite(pin, value). The value is responsible for the PWM. It represents the duty cycle. Value = 255 x (Desired Voltage / 5 [V])

32
Q

What library do you always need to include when using I2C?

A

Wire

33
Q

How do you program using I2C?

A

You initialize the protocol with Wire.begin() in the setup method.

34
Q

How do libraries work? And where can you find them?

A

They include a header file .h and a source file .cpp and these files contain the library code. The list of the methods and how to use the library is in the README.md. There might be a file with examples as well. When including the library in the sketch, write #include <library_name.h> You can find them in the arduino program or at github</library_name.h>