element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Please help us with our school project!
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 8 replies
  • Answers 1 answer
  • Subscribers 395 subscribers
  • Views 696 views
  • Users 0 members are here
  • school project
  • stem
  • arduino uno
  • servo
  • arduino
Related

Please help us with our school project!

Former Member
Former Member over 9 years ago

Soo, we have a school project called 'Explore new tech'. For not so tech people...

 

Task:

We'll make a box of Plexiglas that is linked to an android app. In the app, you can create your own to-do lists. When you checked off the chores listed in the app, the box will open, by means of a lock. In the box, you have already put something you would like to have (a reward).

This can be used by e.g. families - the kids have to clean the room before Saturday to get the candy in the box. When the children checked in the boxes in the list the parents have to approve. Then the box will open and they will get their reward.

 

Technology we use:

- An Arduino Uno

- 9v battery

- HC06 bluetooth

- Breadboard

- Servo motor "Futaba S3003"

- Android app

 

Problem:

- The problem is that we want to connect to Bluetooth - the lamp on the bluetooth is flashing but we can't get any communication between the bluetooth and the phone.

- We have obtained the motor to spin, by means of the code bellow. Then we want to have a button for "open" and one for "close" in our android app. So we have got the motor to spin, but we want to control it with open and close buttons. What code shall we use?!

 

We believe we need to put any "if" or "else" code?!

 

I might add that we spent almost a week to checking tutorials now!

 

Is there anyone here who has the skills to help us?
Thanks in advance!

 

// Sweep

// by BARRAGAN <http://barraganstudio.com>

// This example code is in the public domain.

 

 

#include <Servo.h>

 

Servo myservo; // create servo object to control a servo

// a maximum of eight servo objects can be created

 

int pos = 0; // variable to store the servo position

 

void setup()

{

myservo.attach(9); // attaches the servo on pin 9 to the servo object

}

 

 

void loop()

{

for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees

{ // in steps of 1 degree

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

 

 

}

for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees

{ 

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

}

}

  • Sign in to reply
  • Cancel

Top Replies

  • spannerspencer
    spannerspencer over 9 years ago +1
    Wow, great project idea! I don't have any particular advice myself, but let me promote this post around the Community and see if we can get the experts in to have a look
  • tonyboubady
    tonyboubady over 9 years ago +1
    Generally, projects needs hands-on approach, i can't help it without owning the HC-06 bluetooth module which is pre-programmed with serial port profile. If i own one i would have done the project and send…
  • Former Member
    0 Former Member over 9 years ago

    Would you please post what phone and what make (or at least distributor) the HC06 board is?

    Bluetooth Low Energy (BLE) is easier than BT3.0, but can still be confusing.  I do notice in your code sample there are no BLE connection parameters.  Are you assuming the devices are already linked?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • neilk
    0 neilk over 9 years ago

    hi sussiesjoqvist

     

    HC06 is probably the most widely available Bluetooth adapter; provided the Android App is working correctly, it shouldn't be too difficult to establish communications.

     

    The first thing you must do is PAIR the phone with the HC06 - if the phone needs it, the default pairing code is 1234.

     

    Only then can the App establish a connection to the HC06, and the light on the HC06 will stop flashing

     

    Hope this helps you to get started

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • gihu
    0 gihu over 9 years ago

    If you have issues with the BT, first check ifyour module HC06 is working.

    Suggest suppling the module, make a short-circuit between Tx and Rx.

    Use any app for making a SPP bluetooth connection and send data over serial, for exemple 'Bluechat'.

    Then connect the app with the module over bluetooth (it is clasical bt, not ble).

    If everything works, any char you send with the app, will be sent and get it back over BT.

    Then it will be time to connect it to the arduino uart, and try a simple program, i.e. open the box when receive 'A', and close when receive 'B'. And check if it works with bluechat, before build your own app.

     

    The described option is with classical bluetooth, with the SPP (serial port profile), you can do it also with BLE, but it works different, and has no spp.

     

    I did an app using bluetooth (spp), I used it with RN42 instead of HC06, but I shoul work equal.

    MODBUS master in my cell phone

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • spannerspencer
    0 spannerspencer over 9 years ago

    Wow, great project idea! I don't have any particular advice myself, but let me promote this post around the Community and see if we can get the experts in to have a look image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • jack.chaney56
    0 jack.chaney56 over 9 years ago

    Hi, Just saw the posting, and I am always happy to jump into the mix for education.

     

    The described requirements talk of two elements being used. An Arduino to handle the lock on the box, and an Android (or similar) app to enter information.

    The classic mistake at this point is to want both ends to do all the work. Creating the object model of the problem, the lock doesn't need to know all the questions, only if it is open or closed.  The lock can also keep track of stages (completion of a task), like tumblers in a lock. The control of the tumblers can then be provided access by a secured link, like the key of a lock.

     

    By separating the application in question, which would very likely be the Android application and treating the box with a lock it disconnects the components to workable sizes.  The app would keep track of information, and change the questions that need to be solved to gain access. It would also be possible to have multiple inputs for each person in the worker set, for a team effort (everybody needs to complete their task before the box opens).

     

    Need to add some additional comments...

    For the locking mechanism, using a solenoid, actuated latch would probably work better than a servo motor, unless the project lessons specifically cover use of servo motors. The gratifying buzz of the electromagnet opening the lock is very exciting.  Also, a visual confirmation from the box would probably be helpful, red / green LEDs for each of the "tumblers" so progress toward goal is acknowledged.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • tonyboubady
    0 tonyboubady over 9 years ago

    Generally, projects needs hands-on approach, i can't help it without owning the HC-06 bluetooth module which is pre-programmed with serial port profile. If i own one i would have done the project and send you the code by now...hope someone will help you who owns the module.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • phoenixcomm
    0 phoenixcomm over 9 years ago in reply to neilk

    Ok I'm going to toss in my 2 cents worth..

    First a locked box is a no brainer. but you will need something more than a 9v battery.

    1. Get your self an electric lock, a wall wart (power), and relay.  12-VDC-POWER-DOOR-LOCK-PUSH-PULL-SOLENOID

    and your done..

    Caveats:

    • The relay board shown below is each relay needs a separate input. Make sure that the board is optocoupled!! So If you had 8 boxes you need 8 outputs..
    • You could use an I/O decoder 4x16 (CD54HC4514) might need level shifter
    • OR use a I2C expander ie. no level shifter required. Easy Peasy!!
    • Make sure the wart, 12vdc @ 1000w or 1Anp or greater, that can handle the current of your solenoid.

     

    Thanks for listening.

    Cris H. image

    Here are some part that i have some images for you but IF you are going to do easy then this (prototype) is what you really need.image

    we need a function called lock and it needs to be passed a value of the box's solenoid.image

     

    int lock( int box ){

    int status = 0;

      switch box:{

         case 1{

             // send I2C command to box open

            break};

         case 2{

            break;};

         case 3{

            break;};

        default {

            status = 1;

           // error -- do something }}}

    return( status;) }

    now you could and will call the Ic2 library to do the deed.

    food for thought:

    use a array to hold your I2c stuff   i2c[0][i2c command string][name] or use a struct: but   im getting ahead of you most likely.

    struct I2c_s {but

    char name[50];  // this is for the name this must be NULL terminated.  ie \n

    char command[100]; // remember \n

    }

    struct i2c_s i2c[10]; this gives you ten boxes.

     

    you might want to make the function a int that why you can pass back info fail, why who, etc.

    int status = (lock( n))

    if( status != 0 ) then do something..

    or just

    if((status = lock(n)) != 0 )  then do something..

     

     

    Ops afterthought....

    the I2c bus is designed for very short cable lengths So if you want longer cables then you can use CAN bus (stuff in your card shield cost about 2 bucks.)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 9 years ago

    Wow. Nice to see people making such nice projects at school level.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube