FMUSER Wirless Transmit Video And Audio More Easier !

[email protected] WhatsApp +8618078869184
Language

    DIY distance sensing alarm

     

    "The project is thrust by the alarm, prompting the distance between the driver and his car behind the car. The alarm, H08R6 module (infrared sensor) is constituted by H07R3 module (audio speakers), H08R6 module (infrared sensor), the read distance between him and the car, and then sends the message to H07R3 module (audio speakers) play a song, the volume levels will decrease as the distance between the two vehicles increases. Be Design steps: First, the IR sensor module connected together (H08R6) and an audio speaker module (H07R3). Second, write code: 1, the two modules (H08R6, H07R3) are defined in the fixed topology, we describe the connection between the module thereof. (Note: P08R6 H08R6 module with the same module, but different forms) 2, defines a specific ID for each module. This ID is to function in another module definition module. like: Three modules (module1, module2, Module3), Module 1 Module 2 will send a message, it will know where the message module2 by ID, which transmits the message over to module1. ID module 1 (H08R6) 1 ID module 2 (H07R3) 2 In this section, module2 (H07R3) will receive a message on port 3, thus being inverted. 3, in the main.c file: The sensor unit is set to units of cm, and the DMA is enabled, in order to transfer data from the sensor memory Inside a for loop: AbsDistanceToColor calling function the function (Sensor) function returns a value dependent on sensor values, and variable assignment returns the value assigned state_sensor Adding a delay time, which is the time between a message with another message In the switch () inside, we will check the value of state_sensor Additional information: messageParams [0 -> 3] = frequency; // frequency messageParams [4] = number of samples for sine wave; // number of samples of a sine wave messageParams [5] = play sine wave for specified time; // specified playback time sine SendMessageToModule (2, CODE_H07R3_PLAY_SINE, 6); 2 is the ID module 2 (H07R3) CODE_H07R3_PLAY_SINE is the code message (through it, module2 (H07R3) will know what to execution), said here sine wave module2 (H07R3) 6 messageparams Note: they are not (audio speaker module H07R3) code, external code as performed by an infrared sensor module (H08R6). An infrared sensor attached :( H08R6 code) / ** ************************************************** ************************************************************ **** * File name: main.c * Note: The main program body ************************************************** ************************************************************ **** * * Copyright (c) 2015 STMicroelectronics * * In source and binary forms Redistribution and use, regardless of whether modifications, * The following conditions is allowed: * 1. Redistributions of source code must retain the above copyright notice, * This list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * This list of conditions and the following disclaimer in the documentation * And / or other materials accompanying the release. * 3. STMicroelectronics the names of its contributors name * Can be used to endorse or promote products derived from this software * Especially without the prior written permission. * * This software is provided "as is" provided by the copyright holders and contributors * And all warranties, express or implied, including, but not limited to, * Merchantability and fitness for a particular purpose implied warranties * Disclaimer. Copyright holders or contributors shall be liable under any circumstances * For any direct, indirect, incidental, special, or consequential exemplary results * Damages (including, but not limited to, procurement of substitute goods or * Service; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * Whether it is based on contractual liability, strict liability, or based on any theory of liability, * Or tort (including negligence or otherwise) terminate your use in any way * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE, you can use this software *. * ************************************************** ************************************************************ **** * / / * Hexabitz amended as BitzOS (BOS) V0.2.4- Copyright (C) 2017-2021 Hexabitz all rights reserved* / / *include----------------------------------------------- ------------------- * / #include "BOS.h" / * Private variables ---------------------------------------------- ----------- * / float sensor = 0.0f; uint8_t state_sensor; uint8_t old_state_sensor; uint8_t mode = 1; uint8_t sample = 200; / * Private function prototypes --------------------------------------------- - * / uint8_t AbsDistanceToColor (float distance); uint8_t counter = 0; /* The main function---------------------------------------------- -------------- * / int main (void) { / * MCU configuration ---------------------------------------------- ------------ * / / * Reset all peripheral devices, initialization of the Flash interface and Systick. * / HAL_Init (); / * The system clock * / SystemClock_Config (); / * Initialize peripherals all users * / / * Initialize BitzOS * / BOS_Init (); / * Call the init function freertos objects (in freertos.c in) * / MX_FREERTOS_Init (); / * Start the scheduler * / osKernelStart (); /* Infinite loop */ while (1) { } } / * ------------------------------------------------ ----------- * / / * User tasks * / void UserTask (void * argument) { // Set the units to mm SetRangeUnit (UNIT_MEASUREMENT_CM); // flow memory Stream_ToF_Memory (50, portMAX_DELAY, & sensor); for (;;) { state_sensor = AbsDistanceToColor (sensor); Delay_ms (250); switch (state_sensor) { case 1: // Frequency messageParams [0] = (uint8_t) (150 >> 24); messageParams [1] = (uint8_t) (150 >> 16); messageParams [2] = (uint8_t) (150 >> 8); messageParams [3] = (uint8_t) (150); // number of samples Music Notes messageParams [4] = sample; // duration seconds 2 seconds // Note: Division 16 seconds // Time = duration / 16 seconds messageParams [5] = 2; SendMessageToModule (2, CODE_H07R3_PLAY_SINE, 6); break; case 2: // Frequency messageParams [0] = (uint8_t) (300 >> 24); messageParams [1] = (uint8_t) (300 >> 16); messageParams [2] = (uint8_t) (300 >> 8); messageParams [3] = (uint8_t) (300); // number of samples Music Notes messageParams [4] = sample; // duration seconds 2 seconds // Note: Division 16 seconds // Time = duration / 16 seconds messageParams [5] = 2; SendMessageToModule (2, CODE_H07R3_PLAY_SINE, 6); break; case 3: // Frequency messageParams [0] = (uint8_t) (500 >> 24); messageParams [1] = (uint8_t) (500 >> 16); messageParams [2] = (uint8_t) (500 >> 8); messageParams [3] = (uint8_t) (500); // number of samples Music Notes messageParams [4] = sample; // duration seconds 2 seconds messageParams [5] = 2; SendMessageToModule (2, CODE_H07R3_PLAY_SINE,6); break; case 4: // Frequency messageParams [0] = (uint8_t) (700 >> 24); messageParams [1] = (uint8_t) (700 >> 16); messageParams [2] = (uint8_t) (700 >> 8); messageParams [3] = (uint8_t) (700); Music Notes // sample messageParams [4] = sample; // duration seconds 2 seconds messageParams [5] = 2; SendMessageToModule (2, CODE_H07R3_PLAY_SINE, 6); break; case 5: // Frequency messageParams [0] = (uint8_t) (1000 >> 24); messageParams [1] = (uint8_t) (1000 >> 16); messageParams [2] = (uint8_t) (1000 >> 8); messageParams [3] = (uint8_t) (1000); Music Notes // sample messageParams [4] = sample; // duration seconds 2 seconds messageParams [5] = 2; SendMessageToModule (2, CODE_H07R3_PLAY_SINE, 6); break; case 6: // freq messageParams [0] = (uint8_t) (1500 >> 24); messageParams [1] = (uint8_t) (1500 >> 16); messageParams [2] = (uint8_t) (1500 >> 8); messageParams [3] = (uint8_t) (1500); Music Notes // sample messageParams [4] = sample; // duration seconds 2 seconds messageParams [5] = 2; SendMessageToModule (2, CODE_H07R3_PLAY_SINE, 6); break; case 7: // Frequency messageParams [0] = (uint8_t) (3000 >> 24); messageParams [1] = (uint8_t) (3000 >> 16); messageParams [2] = (uint8_t) (3000 >> 8); messageParams [3] = (uint8_t) (3000); Music Notes // sample messageParams [4] = sample; // duration seconds 2 seconds messageParams [5] = 2; SendMessageToModule (2, CODE_H07R3_PLAY_SINE, 6); break; defult: break; } } } uint8_t AbsDistanceToColor (float distance) { if (distance <15.0f) return 1; else if (distance <20.0f) return 2; else if (distance <25.0f) return 3; else if (distance <30.0f) return 4; else if (distance <35.0f) return 5; else if (distance <40.0f) return 6; else if (distance <45.0f) return 7; else return 8; } "

     

     

     

     

    List all Question

    Nickname

    Email

    Questions

    Our other product:

    Professional FM Radio Station Equipment Package

     



     

    Hotel IPTV Solution

     


      Enter email  to get a surprise

      fmuser.org

      es.fmuser.org
      it.fmuser.org
      fr.fmuser.org
      de.fmuser.org
      af.fmuser.org ->Afrikaans
      sq.fmuser.org ->Albanian
      ar.fmuser.org ->Arabic
      hy.fmuser.org ->Armenian
      az.fmuser.org ->Azerbaijani
      eu.fmuser.org ->Basque
      be.fmuser.org ->Belarusian
      bg.fmuser.org ->Bulgarian
      ca.fmuser.org ->Catalan
      zh-CN.fmuser.org ->Chinese (Simplified)
      zh-TW.fmuser.org ->Chinese (Traditional)
      hr.fmuser.org ->Croatian
      cs.fmuser.org ->Czech
      da.fmuser.org ->Danish
      nl.fmuser.org ->Dutch
      et.fmuser.org ->Estonian
      tl.fmuser.org ->Filipino
      fi.fmuser.org ->Finnish
      fr.fmuser.org ->French
      gl.fmuser.org ->Galician
      ka.fmuser.org ->Georgian
      de.fmuser.org ->German
      el.fmuser.org ->Greek
      ht.fmuser.org ->Haitian Creole
      iw.fmuser.org ->Hebrew
      hi.fmuser.org ->Hindi
      hu.fmuser.org ->Hungarian
      is.fmuser.org ->Icelandic
      id.fmuser.org ->Indonesian
      ga.fmuser.org ->Irish
      it.fmuser.org ->Italian
      ja.fmuser.org ->Japanese
      ko.fmuser.org ->Korean
      lv.fmuser.org ->Latvian
      lt.fmuser.org ->Lithuanian
      mk.fmuser.org ->Macedonian
      ms.fmuser.org ->Malay
      mt.fmuser.org ->Maltese
      no.fmuser.org ->Norwegian
      fa.fmuser.org ->Persian
      pl.fmuser.org ->Polish
      pt.fmuser.org ->Portuguese
      ro.fmuser.org ->Romanian
      ru.fmuser.org ->Russian
      sr.fmuser.org ->Serbian
      sk.fmuser.org ->Slovak
      sl.fmuser.org ->Slovenian
      es.fmuser.org ->Spanish
      sw.fmuser.org ->Swahili
      sv.fmuser.org ->Swedish
      th.fmuser.org ->Thai
      tr.fmuser.org ->Turkish
      uk.fmuser.org ->Ukrainian
      ur.fmuser.org ->Urdu
      vi.fmuser.org ->Vietnamese
      cy.fmuser.org ->Welsh
      yi.fmuser.org ->Yiddish

       
  •  

    FMUSER Wirless Transmit Video And Audio More Easier !

  • Contact

    Address:
    No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620

    E-mail:
    [email protected]

    Tel / WhatApps:
    +8618078869184

  • Categories

  • Newsletter

    FIRST OR FULL NAME

    E-mail

  • paypal solution  Western UnionBank OF China
    E-mail:[email protected]   WhatsApp:+8618078869184   Skype:sky198710021 Chat with me
    Copyright 2006-2020 Powered By www.fmuser.org

    Contact Us