A remote Sun SPOT will transmit data to a Sun SPOT mounted on a car, which will control an integrated circuit (IC) according to the digital input/output pins D0 to D3. The IC will subsequently drive the motors that propel the car. The application utilizes various libraries from the Sun SPOT platform, including those for radiogram communication, peripheral management, and sensor integration. The remote Sun SPOT sends tilt values detected by its accelerometer to the car Sun SPOT, which interprets these values to control the car's movement.
The application begins by initializing the EDemoBoard instance and setting up a connection to the car Sun SPOT using its IEEE address. A continuous loop is established to read tilt data from the accelerometer. Based on the tilt values, specific control commands are generated and sent via radiogram to the car Sun SPOT. The control commands are determined by evaluating the tilt angles along the X and Y axes, with predefined thresholds to ascertain movement direction. The application also includes mechanisms for error handling and resource management, ensuring that connections are appropriately closed and LEDs are turned off when the application is terminated.
The control logic is encapsulated within the `getControl()` method, which returns specific numeric values representing the tilt conditions. These values correspond to different movement commands for the car, allowing for responsive control based on the remote Sun SPOT's orientation.
The overall architecture of the system relies on effective communication between the two Sun SPOT devices, leveraging wireless radiogram connections to facilitate real-time data exchange. This setup enables the remote control of the car based on physical tilt inputs, showcasing the integration of sensor data with motor control in an embedded system environment.Here remote Sun SPOT will send data to Sun SPOT on car which will drive the IC according to DC IO pins D0 - D3. The IC will drive the Motors which will run the car. package org. sunspotworld. demo; import com. sun. spot. io. j2me. radiogram. Radiogram; import com. sun. spot. io. j2me. radiogram. RadiogramConnection; import com. sun. spot. peripheral. NoRouteExcepti on; import com. sun. spot. peripheral. Spot; import com. sun. spot. peripheral. radio. IRadioPolicyManager; import com. sun. spot. sensorboard. EDemoBoard; import com. sun. spot. sensorboard. peripheral. ITriColorLED; import com. sun. spot. sensorboard. peripheral. IAccelerometer3D; import java. io. IOException; import javax. microedition. midlet. MIDletStateChangeException; import com. sun. spot. util. IEEEAddress; import com. sun. spot. util. Utils; import javax. microedition. io. Connector; /** * Remote Spot will send Tilt values to the Car Spot. * * @author Jay Mahadeokar */ public class StartApp extends javax. microedition. midlet. MIDlet { EDemoBoard demoboard = EDemoBoard. getInstance(); protected void startApp() throws MIDletStateChangeException { IRadioPolicyManager rpm = Spot. getInstance(). getRadioPolicyManager(); IEEEAddress myAddr = new IEEEAddress(rpm. getIEEEAddress(); System. out. println("Hi! my address = " + myAddr. asDottedHex(); //This is my Car Sun SPOT address IEEEAddress bsAddress = new IEEEAddress(new String("0014.
4F01. 0000. 1231"); IAccelerometer3D acc = demoboard. getAccelerometer(); while(true) { try{ RadiogramConnection conn = (RadiogramConnection)Connector. open("radiogram://0014. 4F01. 0000. 1A29:10"); Radiogram rdg = (Radiogram)conn. newDatagram(conn. getMaximumLength(); try { //Get control called and value sent to car spot! rdg. writeUTF(""+getControl(); conn. send(rdg); Utils. sleep(200); // Sleep for sometime! } catch (NoRouteException e) { System. out. println ("No route to 0014. 4F01. 0000. 1A29"); } finally { conn. close(); } } catch(IOException e){ System. out. println("There is a problem opening the connection"); } } } //Returns the numeric value corresponding to the current Tilt Positions of //Sun SPOT //Return values only if Tilt > 0. 5 or Tilt < -0. 5 public int getControl() { int ret = 0; try { double xTilt = demoboard. getAccelerometer(). getTiltX(); double yTilt = demoboard. getAccelerometer(). getTiltY(); if (xTilt > 0. 5 && yTilt < 0. 5 && yTilt > -0. 5) { ret = 110; } if (xTilt < -0. 5 && yTilt < 0. 5 && yTilt > -0. 5) { ret = 101; } if (yTilt > 0. 5 && xTilt < 0. 5 && xTilt > -0. 5) { ret = 100; } if (yTilt < -0. 5 && xTilt < 0. 5 && xTilt > -0. 5) { ret = 1000; } } catch (IOException ex) { ex. printStackTrace(); } return ret; } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { ITriColorLED [] leds = EDemoBoard.
getInstance(). getLEDs(); for (int i = 0; i < 8; i+) { // turn off the LEDs when we exit leds[i]. setOff(); } } protected void pauseApp() { } } import com. sun. spot. io. j2me. radiogram. Radiogram; import com. sun. spot. io. j2me. radiogram. RadiogramConnection; import com. sun. spot. peripheral. NoRouteException; import com. sun. spot. peripheral. Spot; import com. sun. spot. peripheral. radio. IRadioPolicyManager; import com. sun. spot. sensorboard. EDemoBoard; import com. sun. spot. sensorboard. peripheral. ITriColorLED; import com. sun. spot. sensorboard. peripheral. IAccelerometer3D; import java. io. IOException; import javax. microedition. midlet. MIDletStateChangeException; import com. sun. spot. util. IEEEAddress; import com. sun. spot. util. Utils; import javax. microedition. io. Connector; /** * Remote Spot will send Tilt values to the Car Spot. * * @author Jay Mahadeokar */ public class StartApp extends javax. microedition. midlet. MIDlet { EDemoBoard demoboard = EDemoBoard. getInstance(); protected void startApp() throws MIDletStateChangeException { //This is my Car Sun SPOT address IEE 🔗 External reference
The circuit operation principle of the device illustrated in Figure 11 addresses the frequent occurrence of power outages, particularly in critical situations where continuous power supply is essential, such as during surgeries. The circuit employs a simple design that...
This dual power supply utilizes the L165 power operational amplifier from SGS-Thomson Microelectronics. The L165 IC can deliver up to 3.5A of current, with internal current limiting. It is available in a Pentawatt package, making it well-suited for power...
Non-sinusoidal waveform generators are also referred to as relaxation oscillators. The op-amp relaxation oscillator depicted in the figure functions as a square wave generator. Generally, square waves are relatively simple to generate. Similar to the UJT relaxation oscillator, the...
The following circuit illustrates a schematic diagram for a remote control toy car. Features: it does not interfere with the performance of the original design.
The remote control toy car circuit typically consists of several key components that enable wireless...
The 1N4001 is a 1 Amp silicon rectifier with a voltage range of 50 to 1000 volts. It features guaranteed high-temperature soldering, high current capability, a diffused junction, low reverse leakage, and utilizes a void-free molded plastic technique for...
The circuit presented is a simple stereo FM transmitter capable of transmitting high-quality signals over a range of 70 feet. It utilizes the BH1417 PLL Stereo Transmitter IC from Rhom, which features distinct sections for audio processing of the...
We use cookies to enhance your experience, analyze traffic, and serve personalized ads.
By clicking "Accept", you agree to our use of cookies.
Learn more