Wednesday, November 15, 2017

17 October '17- Day 15- Higher dimensional arrays and pointers

Beginning of class we were introduced to higher dimensional arrays and pointers.  most engineering problems can be solved using 1 or 2 dimensional arrays but on occasion a 3 dimensional array can be useful.  We also began discussion on addresses and pointer in C.  An address is a specific integer value to specify the memory location.   in order to properly utilize this feature we must move away from using repl.it and use a compiler that we can use offline.  Virtual-C IDE is one example of a downloadable compiler from the many out there.
Once an offline compiler has been installed, using pointer to reference memory locations is much more reliable.  The overall advantage to using pointers in a program is to optimize the speed at which the program runs and use less memory.
(example showing the Virtual-C IDE program and a sample code using pointers.)
In Lab we began discussion on how to wire up and control a c motor using a potentiometer.  The POT value in the middle would stop the motor and turning the POT to the left or right would speed up the motor in that direction.  Certain precautions must be made to protect the Arduino board since the pins are not designed to run a dc motor so having protection diodes and a secondary power source to run the motor are necessary.  

(Lab using a potentiometer to control the direction of the spinning dc motor)
(mounted dc motor on the robocar chassis)









No comments:

Post a Comment