G11A_G_T1_W1_W2_24_25.pdf
Document Details
Uploaded by SkillfulParabola
Emirates Schools Establishment
Tags
Full Transcript
Chapter 1 Microcontroller Boards Prepared by: Eng. Sara Awadalla Section 1 Example of Microcontroller Boards Lesson Outcome Illustrate the functions and parts of the microcontroller-based board. Develop basic codes using a programming interface. Demonstrate the use...
Chapter 1 Microcontroller Boards Prepared by: Eng. Sara Awadalla Section 1 Example of Microcontroller Boards Lesson Outcome Illustrate the functions and parts of the microcontroller-based board. Develop basic codes using a programming interface. Demonstrate the use of the serial monitor. Categorise the different types of variables and operators Keywords Keywords What is Arduino? Arduino Hardware Software Board (Physical) Arduino (IDE) program What is Arduino? Arduino Hardware Software Board (Physical) Arduino (IDE) program Activity Open Student Book Page:10 Solve the worksheet https://www.liveworksheets.com/fx125220us Explore the Arduino Board Activity Explore the Arduino Board Explore the Arduino Board Process Read signals Write order Activity Am I input device or output? Button Activity Am I input device or output? Input Activity Am I input device or output? Light Activity Am I input device or output? Output Activity Am I input device or output? Motor (Wheel) Activity Am I input device or output? Output Activity Am I input device or output? Monitor Activity Am I input device or output? Output Explore the Arduino Board Explore the Arduino Board What is the type of the our microcontroller? Arduino Board? Explore the Arduino Board What Arduino is the Leonardo type of our is Arduino used at school Board? Explore the Arduino Board What Arduino about UNOtheisArduino used in usedTinkerCAD in TinkerCAD? What is Arduino? Arduino Hardware Software Board (Physical) Arduino (IDE) program Arduino Code Structure Arduino use C/C++ Language Sketches: Programs written using Arduino programming language Note: Your code will NOT run without both functions Arduino Code Structure Seeds water once repeatdly Explore the Arduino IDE software ▪ Arduino IDE stands for Integrated Development Environment (IDE) or (Arduino software). 1 2 3 Explore the Arduino IDE software Activity LTZTLE137 Serial Monitor Definition is a window that displays any serial information the Arduino board is transmitting or receiving Serial Monitor ▪ To open the serial monitor: 1. Run the Arduino software. 2. Upload the code to the Arduino board. 3. Then, double-click on the serial monitor button. Serial Monitor ▪ The serial monitor consists of three sections: Serial Monitor Function syntax Description To begin a serial communication with Arduino board with baud rate of 9600. Serial.begin (9600); Baud rate: Number of bits to be transmitted per second. Ask the Arduino to be in hold until the serial communications is fully while (!Serial); established as it takes time to be ready Print out the required on screen Serial.print(….); Print out the required on screen and Serial.println(…..); start a new line for the next message Serial Monitor Start with Serial.begin Write your code inside the void setup(): Don’t forget ( ; ) at the end of each statement. What is the result? Example Code Serial Monitor Serial.print( ….); Serial.println(…..); Serial.print( “5+1”); Serial.print(“5+1“); Serial.println( “5+1”); Serial.println(“5+1“); Serial.print(“5+1”); Serial.print(5+1); Serial.println(“5+1”) Serial.println(5+1); Output on monitor Output on monitor Output on monitor Output on monitor 5+1 5+1 5+1 5+1 5+1 6 5+1 6 Arduino syntax is a set of Arduino Code Syntax rules that defined how the code should be written and structured. Activity 1.1.3 (Student book-p.21) 2 1 1 2 semicolon Activity 1.1.3 (Student book-p.21) 4 2 3 1 block 3 comments 4 line comments Activity 1.1.3 (Student book-p.21) 4 2 3 6 5 1 5 variables variable 6 declaration Data Type Data result from any operation need to be stored so variable is used. What is variable? A memory storage unit in the program to put the result in Why we need it? Store the result and avoid any repetition. Variable types integer float bool char Data Type Variable types integer float bool char Data Type What is my type? Data Type What is my type? 950? Data Type What is my type? 950? int true? Data Type 0.5? What is my type? 950? int true? bool 0.5? Data Type What is my type? float 950? int 10.0? true? bool 0.5? Data Type What is my type? float 950? int 10.0? true? float bool G? 0.5? Data Type What is my type? float 950? ?? int 10.0? true? float G? bool char 0.5? Data Type What is my type? float 950? ?? int char 10.0? true? float G? bool char *This is not a must Data Type Your choice * Must match with the type Variable Assigning Defining type name value a variable Activity Write the right answer of the given task. Declare integer variable called num and assign 5 to it. Activity Write the right answer of the given task. Declare integer variable called num and assign 5 to it. Answer int num=5; Declare bool variable called result and assign true to it. Activity Write the right answer of the given task. Declare integer variable called num and assign 5 to it. Answer int num=5; Declare bool variable called result and assign true to it. Answer: bool result=true; Activity Write the right answer of the given task. Declare integer variable called num and assign 5 to Declare char variable called it. letter and assign ‘a’ to it. Answer int num=5; Declare bool variable called result and assign true to it. Answer: bool result=true; Activity Write the right answer of the given task. Declare integer variable Declare char variable called called num and assign 5 to letter and assign ‘a’ to it. it. Answer: Answer char letter=‘a’; int num=5; Declare bool variable called result and assign true to it. Answer: bool result=true; Activity Write the right answer of the given task. Declare integer variable Declare char variable called called num and assign 5 to letter and assign a to it. it. Answer: Answer char letter=‘a’; int num=5; Declare bool variable called Declare float variable called result and assign true to it. grade_11 and its values is Answer: 90.5. bool result=true; Activity Write the right answer of the given task. Declare integer variable Declare char variable called called num and assign 5 to letter and assign a to it. it. Answer: Answer char letter=‘a’; int num=5; Declare float variable called Declare bool variable called grade_11 and its values is result and assign true to it. 90.5. Answer: Answer: bool result=true; float grade_11= 90.5; Operators Operators Type Arithmetic Rational Boolean Compound Operators Operators Type Arithmetic Rational Boolean Compound Arithmetic Operators Activity Operators Operators Type Arithmetic Rational Boolean Compound Rational Operators Activity Activity Activity Num1 = 11 Num2=3 Num1 (11) !=(Not equal) Num2(3) → True as 11 not equal to 3 Result = True (1) Output : Num1 is not equal to Num2: 1 Activity https://create.kahoot.it/share/arduino-revision-grage-11/750631bf-45e5-43f8- a238-f4ffd1e2d69f Operators Operators Type Arithmetic Rational Boolean Compound Boolean Operators Activity Operators Operators Type Arithmetic Rational Boolean Compound Compound operators Compound Operators Write the compound form of the following operators in the chat section Compound Operators Write the compound form of the following operators in the chat section A=A+1 Compound Operators Write the compound form of the following operators in the chat section A=A+1 Answer: A++ or A+=1 A=A*B Compound Operators Write the compound form of the following operators in the chat section A=A+1 Answer: A++ or A+=1 A=A*B Answer: A*=B B=B+C-1 Compound Operators Write the compound form of the following operators in the chat section A=A+1 Answer: A++ or A+=1 A=A*B Answer: A*=B B=B+C-1 Answer: B+=(C-1) Compound Operators Write the compound form of the following operators in the chat section A=A+1 Answer: A++ or A+=1 A=A/4 A=A*B Answer: A*=B B=B+C-1 Answer: B+=(C-1) Compound Operators Write the compound form of the following operators in the chat section A=A+1 Answer: A++ or A+=1 A=A/4 Answer: A/=4 A=A*B Answer: A*=B A=A-1 B=B+C-1 Answer: B+=(C-1) Compound Operators Write the compound form of the following operators in the chat section A=A+1 Answer: A++ or A+=1 A=A/4 Answer: A/=A A=A*B Answer: A*=B A=A-1 Answer: A-- or A-=1 B=B+C-1 Answer: B+=(C-1) A=A*(B+1) Compound Operators Write the compound form of the following operators in the chat section A=A+1 Answer: A++ or A+=1 A=A/4 Answer: A/=A A=A*B Answer: A*=B A=A-1 Answer: A– or A-=1 B=B+C-1 Answer: B+=(C-1) A=A*(B+1) Answer: A*=(B+1) Activity - Homework