application development
play

APPLICATION DEVELOPMENT LECTURE 5: ARDUINO PART 2, DESIGNING CLASSES - PowerPoint PPT Presentation

APPLICATION DEVELOPMENT LECTURE 5: ARDUINO PART 2, DESIGNING CLASSES REVISITED class AppDev { Part of SmartProducts } INTRODUCTION Fjodor van Slooten APPLICATION DEVELOPMENT W241 (Horst-wing West) f.vanslooten@utwente.nl Design a class


  1. APPLICATION DEVELOPMENT LECTURE 5: ARDUINO PART 2, DESIGNING CLASSES REVISITED class AppDev { Part of SmartProducts }

  2. INTRODUCTION Fjodor van Slooten APPLICATION DEVELOPMENT W241 (Horst-wing West) f.vanslooten@utwente.nl ▪ Design a class ▪ Project planning ▪ Arduino programming part 2 ▪ Assignment Keep laptop or phone ready for slides @ vanslooten.com/appdev use 2 AppDev 5/17/2019

  3. ASSIGNMENT 4 ▪ Translate pseudo-code to code Stop. // Stop. Turn the Ultrasonic Sensor 90 degrees // Turn the Ultrasonic Sensor 90 degrees Read the value of the Ultrasonic Sensor (look left) // Read the value of the Ultrasonic Sensor (look left) Turn the Ultrasonic Sensor -180 degrees // Turn the Ultrasonic Sensor -180 degrees Read the value of the Ultrasonic Sensor (look right) // Read the value of the Ultrasonic Sensor (look right) Turn the Ultrasonic Sensor 90 degrees (faces in original direction) // Turn the Ultrasonic Sensor 90 degrees (faces in original direction) Compare the two read values of the Ultrasonic Sensor: // Compare the two read values of the Ultrasonic Sensor: if the first value is smaller than last? // if the first value is smaller than last? Turn right // Turn right else: // else: Turn left // Turn left Drive. (Continue moving) // Drive. (Continue moving) 3 AppDev 5/17/2019

  4. ASSIGNMENT 4 ▪ Translate pseudo-code to code Stop. // Stop. Turn the Ultrasonic Sensor 90 degrees stop(); Read the value of the Ultrasonic Sensor (look left) // Turn the Ultrasonic Sensor 90 degrees Turn the Ultrasonic Sensor -180 degrees evshield->bank_b.motorRunDegrees(sensorMotor, SH_Direction_Forward, 30, 90, Read the value of the Ultrasonic Sensor (look right) SH_Completion_Wait_For, SH_Next_Action_BrakeHold ); Turn the Ultrasonic Sensor 90 degrees (faces in original direction) // Read the value of the Ultrasonic Sensor (look left) Compare the two read values of the Ultrasonic Sensor: unsigned int left = sonar->ping_cm(); if the first value is smaller than last? // Turn the Ultrasonic Sensor -180 degrees Turn right // Read the value of the Ultrasonic Sensor (look right) else: // Turn the Ultrasonic Sensor 90 degrees (faces in original direction) Turn left // Compare the two read values of the Ultrasonic Sensor: Drive. (Continue moving) // if the first value is smaller than last? if (left<right) { // Turn right Serial.println(F("go right")); Same, but with steer(-20); } SH_Direction_Reverse // else: // Turn left drive(-40); // Drive. (Continue moving) drive(); 4 AppDev 5/17/2019

  5. DESIGN A CLASS ‘PRODUCT’ IN C++ (ARDUINO) ▪ Read assignment: we are going to make a simplified version of a vending machine… ▪ … which sells ‘Products’, which only needs (displays) the name, and does calculations with the price class Product { class Product { class Product { class Product { String name; name; private: private: price; int price; // in cents String name; String name; Step 1 : analyze object } } int price; // in cents int price; // in cents in real world…: public: public: // constructor (fills in name and price) // constructor (fills in name and price) It is : a product Step 1b : Product(String n, int p); // methods Identify Map to properties : color, // methods (getters) } String getName(); methods contents, type, name, int getPrice(); dimensions, price… … } 5 AppDev 5/17/2019

  6. DESIGN A CLASS ‘PRODUCT’ Add an include line for // constructor: #include "Product.h" Product::Product(String n, int p) { "Product.h" // constructor: assign values to class-variables name and price } Product::Product(String n, int p) { // assign values to class-variables name and price // methods: name = n; String Product::getName() { price = p; } return the name } // methods: int Product::getPrice() { String Product::getName() { return the price // return the name } return name; Step 2 : add pseudo code } which describes what int Product::getPrice() { methods should do // return the price Step 3: add code to return price; } methods (change pseudo code into real code) 6 AppDev 5/17/2019

  7. PROTOTYPE FOR PROJECT HOW DO YOU DO? ▪ About to enter second half of project ▪ Usually, developing software (coding + testing) takes 55% of time (design + requirements = 40%) ▪ So to have enough time left, you should now start developing prototype Estimation of time needed for phases 7 AppDev 5/17/2019 in development of a prototype

  8. Prepare to vote In Internet 1 2 This presentation has been loaded without the Shakespeak add-in. Want to download the add-in for free? Go to http://shakespeak.com/en/free-download/. TXT 1 2 Voting is anonymous 5/17/2019 AppDev

  9. Regarding REQUIREMENTS specification we are A. Just started B. Busy, unknown how much time this will take C. Almost ready D. Done The question will open when you start your session and slideshow. Votes: 51 Closed This presentation has been loaded without the Shakespeak add-in. In Internet This text box will be used to describe the different message sending methods. Want to download the add-in for free? Go to http://shakespeak.com/en/free- TXT The applicable explanations will be inserted after you have started a session. download/.

  10. Regarding REQUIREMENTS specification we are A. 2.0% Just started B. 5.9% Busy, unknown how much time this will take C. 37.3% Almost ready D. 54.9% Done Closed

  11. Regarding DESIGN (for prototype) we are A. Just started B. Busy, unknown how much time this will take C. Almost ready D. Done The question will open when you start your session and slideshow. Votes: 50 Closed This presentation has been loaded without the Shakespeak add-in. In Internet This text box will be used to describe the different message sending methods. Want to download the add-in for free? Go to http://shakespeak.com/en/free- TXT The applicable explanations will be inserted after you have started a session. download/.

  12. Regarding DESIGN (for prototype) we are A. 26.0% Just started B. 60.0% Busy, unknown how much time this will take C. 14.0% Almost ready D. 0.0% Done Closed

  13. = programming Regarding CODING (for prototype) we are A. Not started yet B. Just started C. Busy, unknown how much time this will take D. Almost ready The question will open when you E. Done start your session and slideshow. Votes: 50 Closed This presentation has been loaded without the Shakespeak add-in. Internet In This text box will be used to describe the different message sending methods. Want to download the add-in for free? Go to http://shakespeak.com/en/free- TXT The applicable explanations will be inserted after you have started a session. download/.

  14. Regarding CODING (for prototype) we are A. 22.0% Not started yet B. 48.0% Just started C. 28.0% Busy, unknown how much time this will take D. 2.0% Almost ready E. 0.0% Done Closed This presentation has been loaded without the Shakespeak add-in. Internet In This text box will be used to describe the different message sending methods. Want to download the add-in for free? Go to http://shakespeak.com/en/free- TXT The applicable explanations will be inserted after you have started a session. download/.

  15. Regarding TESTING (for) the prototype we are A. Not started yet B. Just started C. Busy, unknown how much time this will take D. Almost ready The question will open when you E. Done start your session and slideshow. Votes: 47 Closed This presentation has been loaded without the Shakespeak add-in. In Internet This text box will be used to describe the different message sending methods. Want to download the add-in for free? Go to http://shakespeak.com/en/free- TXT The applicable explanations will be inserted after you have started a session. download/.

  16. Regarding TESTING (for) the prototype we are A. 40.4% Not started yet B. 40.4% Just started C. 17.0% Busy, unknown how much time this will take D. 2.1% Almost ready E. 0.0% Done Closed This presentation has been loaded without the Shakespeak add-in. Internet In This text box will be used to describe the different message sending methods. Want to download the add-in for free? Go to http://shakespeak.com/en/free- TXT The applicable explanations will be inserted after you have started a session. download/.

  17. Did you discuss a planning with your tutor? A. Yes, and the phases just mentioned were also discussed B. Yes, but different phases were discussed C. Yes, but we did not have a clear planning D. We still have to do this E. No The question will open when you start your session and slideshow. Votes: 47 Closed This presentation has been loaded without the Shakespeak add-in. In Internet This text box will be used to describe the different message sending methods. Want to download the add-in for free? Go to http://shakespeak.com/en/free- TXT The applicable explanations will be inserted after you have started a session. download/.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend