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 699 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…
Parents
  • 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
Reply
  • 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
Children
  • 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
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