Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to use the Mbed compiler and Mbed.h library with a FRDM-KL46Z microp

ID: 3817697 • Letter: I

Question

I am trying to use the Mbed compiler and Mbed.h library with a FRDM-KL46Z microprocessor

(PLEASE USE C LANGUAGE PREFERRABLY, OR C++)

1. In one competition, the robot was required to use an infrared phototransistor to find an infrared beacon flashing at 10 kHz and ignore beacons flashing at other frequencies. Assume that a circuit exists using the phototransistor which provides your KL46Z microprocessor with a square wave signal at the frequency of the infrared beacon if it is correctly pointing at a beacon. This signal is available on pin PTA 13. You are to write a program, including any necessary subroutines or interrupts, that will update a global variable called "beacon ok" at least 10 times per second. If the signal frequency is 10 kHz +/-10%. then beacon ok should have the value of 1. If the signal frequency is less than 100 Hz, assume that a beacon has not been found and beacon ok should have the value of 0. If there is any frequency found greater than 100 Hz but not 10 kHz 10%, the value of beacon ok should be -1.

Explanation / Answer

package com.cheggtest;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;


public class ReadCSVFile {
   public static void main(String[] args) {
      
       BufferedReader studentInfo = null;
      
       try {
           String data;
           studentInfo = new BufferedReader(new FileReader("c://Users//student.txt"));
          
           while ((data = studentInfo.readLine()) != null) {
               System.out.println("Raw CSV data: " + data);
               System.out.println("Converted ArrayList data: " + crunchifyCSVtoArrayList(data) + " ");
           }
          
       } catch (IOException e) {
           e.printStackTrace();
       } finally {
           try {
               if (studentInfo != null) studentInfo.close();
           } catch (IOException crunchifyException) {
               crunchifyException.printStackTrace();
           }
       }
   }
  
   // Utility which converts CSV to ArrayList using Split Operation
   public static ArrayList<String> crunchifyCSVtoArrayList(String studentList) {
       ArrayList<String> resultList = new ArrayList<String>();
      
       if (studentList != null) {
           String[] splitData = studentList.split("\s*,\s*");
           for (int i = 0; i < splitData.length; i++) {
               if (!(splitData[i] == null) || !(splitData[i].length() == 0)) {
                   resultList.add(splitData[i].trim());
               }
           }
       }
      
       return resultList;
   }
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote