This part is an extension to lab05-Part02 in using Arduino grove board. In this part we are going to use the buzzer and

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

This part is an extension to lab05-Part02 in using Arduino grove board. In this part we are going to use the buzzer and

Post by answerhappygod »

This Part Is An Extension To Lab05 Part02 In Using Arduino Grove Board In This Part We Are Going To Use The Buzzer And 1
This Part Is An Extension To Lab05 Part02 In Using Arduino Grove Board In This Part We Are Going To Use The Buzzer And 1 (56.78 KiB) Viewed 46 times
should look like this when code run
This Part Is An Extension To Lab05 Part02 In Using Arduino Grove Board In This Part We Are Going To Use The Buzzer And 2
This Part Is An Extension To Lab05 Part02 In Using Arduino Grove Board In This Part We Are Going To Use The Buzzer And 2 (55.99 KiB) Viewed 46 times
please help!!!
This part is an extension to lab05-Part02 in using Arduino grove board. In this part we are going to use the buzzer and the button on the board to make an alarm clock. Basically, you should use the knowledge developed in Lab05-Part2 for connecting the board to java using Firmata libraries and modify the provided code below. A portion of the main method, and a method (getAlarmDate) for taking the keyboard entries are provided along with the necessary/useful classes/methods. 11 Grove Beginner Kit For Acting Har 642 GROVE seeed
import org.firmata4j.firmata. *; import org.firmata4j.IODevice; import org.firmata4j. Pin; import java.io.IOException; import import java.util.Date; import java.util.Scanner; import java.text.SimpleDateFormat; java.text.ParseException; public class lab07P2 { public static void main(String[] args) } String myPort = "/dev/cu.usbserial-0001"; IODevice myGroveBoard = new FirmataDevice (myPort); try { throws IOException, ParseException { } } catch (Exception ex) { System.out.println("couldn't connect to board."); myGroveBoard.start(); System.out.println("Board started."); myGroveBoard. ensure InitializationIsDone (); finally /* you should develop this block */ } public static Date getAlarmDate () throws ParseException { Scanner input = new Scanner (System.in); System.out.println("This program uses Arduino board to act as an alarm clock."); System.out.println("Below, you can enter your desire date and time to set an alarm."); String dateStr; Date DT; while (true) { // modify for your own computer & setup. System.out.print("Enter four digits the year (e.g. 2022): "); int year = input.nextInt (); System.out.print("Enter two digits the month (e.g. 06): "); int mm = input.nextInt (); System.out.print("Enter two digits the day (e.g. 28): "); int dd = input.nextInt (); System.out.print("Enter two digits the hour (e.g. 07): "); int un 2012 P int HH = input.nextInt (); Pr System.out.print("Enter two digits the minutes (e.g. 12): "); PASS int MM input.nextInt (); System.out.print("Enter two digits the second (e.g. 52): "); 11 MM > 59 || SS < 0 || SS > 59)) { int SS input.nextInt (); if (! (year < 2022 || mm > 59 || mm < 0 || dd < 0 || dd > 31 || HH < 0 || HH > 24 || MM < 0 } dateStr == "" +dd+ "/" +mm+ "/" + year + " " + HH+ ":" + MM + ":" + SS; SimpleDateFormat frmt-new SimpleDateFormat ("dd/MM/yyyy HH:mm:ss"); DT=frmt.parse (dateStr); Date NOW-new Date(); if (NOW.before (DT)) { System.out.println ("The entered alarm time is " + DT); } break; return DT; System.out.println("The entered date is not correct. Please reenter your desire date");
You should develop the rest of the main method (as mentioned in the program above) such that your program runs as below: 1- The program asks user to enter the desire alarm date and time. You should use the getAlarmDate method for this.
2- Your code should check continually whether the current time has passed the entered date or not. (Hint: search whether date1.after(date2) or date1.before(date2) from java.util.Data is useful) 3- Right after the current time passes the alarm time, Arduino buzzer should start beeping for 30 times. The buzzer beep should be set up as 100 milliseconds on and 100 milliseconds off. Hint: see the LED-specific statements in Lab05-Part2, see if those statement can be modified for the buzzer as: var myBuzzer =myGrove Board.getPin(5); myBuzzer.setMode(Pin.Mode.PWM); myBuzzer.setValue(X); (for example, see if myBuzzer.setValue(20) can turn it on and myBuzzer.setValue(-1) can turn it off.) 4- Note that you should be able to stop the buzzer by pressing the button for less than half a second. Hint: see the LED-specific statements in Lab05-Part2, see if those statement can be modified for the button as: var myButton =myGroveBoard.getPin(6); myButton.setMode(Pin.Mode.INPUT); myButton.getValue() can gives the signal from button. If you do not press the button and run myButton.getValue(), your program receives O. and if you press the button and running myButton.getValue(), your program receives 1.
Lab07Part2 src labo lab07P2.java x Run: 个 ↓ 顺道 lab07P2 x lab07P2 a /Users/babak/Library/Java/JavaVirtual Machines/openjdk-18.0.1.1/Content Enter two digits the minutes (e.g. 12): 23 Enter two digits the second (e.g. 52): 300 The entered alarm time is Tue Jun 28 19:23:30 EDT 2022 ... Board started. Jun. 28, 2022 7:22:50 P.M. org.slf4j.impl.JCLLogger Adapter warn WARNING: Current version of firmata protocol on device (2.5) differs f This program uses Arduino board to act as an alarm clock. Below, you can enter your desire date and time to set an aram. Enter four digits the year (e.g. 2022): 2022 Enter two digits the month (e.g. 06): 06 Enter two digits the day (e.g. 28): 28 Enter two digits the hour (e.g. 07): 19 Arduino alarms at Tue Jun 28 19:23:30 EDT 2022 You have not woken up yet! You have not woken up yet! You have not woken up yet! You have not woken up yet! You have not woken up yet! You have not woken up yet! You have not woken up yet! You have not woken up yet! You have not woken up yet! You have not woken up yet! You have not woken up yet! You have not woken up yet! Notifications
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply