Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Seeed_Relay_Shield_HelloWorld by
main.cpp@0:2728fc4ff217, 2014-02-12 (annotated)
- Committer:
- lawliet
- Date:
- Wed Feb 12 07:22:42 2014 +0000
- Revision:
- 0:2728fc4ff217
- Child:
- 1:fc812d711545
Initial verison of Seeed Relay Shield demo code
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| lawliet | 0:2728fc4ff217 | 1 | /* |
| lawliet | 0:2728fc4ff217 | 2 | main.cpp |
| lawliet | 0:2728fc4ff217 | 3 | 2014 Copyright (c) Seeed Technology Inc. All right reserved. |
| lawliet | 0:2728fc4ff217 | 4 | |
| lawliet | 0:2728fc4ff217 | 5 | Author:lawliet.zou@gmail.com |
| lawliet | 0:2728fc4ff217 | 6 | 2014-02-12 |
| lawliet | 0:2728fc4ff217 | 7 | |
| lawliet | 0:2728fc4ff217 | 8 | This library is free software; you can redistribute it and/or |
| lawliet | 0:2728fc4ff217 | 9 | modify it under the terms of the GNU Lesser General Public |
| lawliet | 0:2728fc4ff217 | 10 | License as published by the Free Software Foundation; either |
| lawliet | 0:2728fc4ff217 | 11 | version 2.1 of the License, or (at your option) any later version. |
| lawliet | 0:2728fc4ff217 | 12 | |
| lawliet | 0:2728fc4ff217 | 13 | This library is distributed in the hope that it will be useful, |
| lawliet | 0:2728fc4ff217 | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| lawliet | 0:2728fc4ff217 | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| lawliet | 0:2728fc4ff217 | 16 | Lesser General Public License for more details. |
| lawliet | 0:2728fc4ff217 | 17 | |
| lawliet | 0:2728fc4ff217 | 18 | You should have received a copy of the GNU Lesser General Public |
| lawliet | 0:2728fc4ff217 | 19 | License along with this library; if not, write to the Free Software |
| lawliet | 0:2728fc4ff217 | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| lawliet | 0:2728fc4ff217 | 21 | */ |
| lawliet | 0:2728fc4ff217 | 22 | |
| lawliet | 0:2728fc4ff217 | 23 | #include "mbed.h" |
| lawliet | 0:2728fc4ff217 | 24 | |
| lawliet | 0:2728fc4ff217 | 25 | //#define SEEEDUINO_ARCH |
| lawliet | 0:2728fc4ff217 | 26 | #define SEEEDUINO_ARCH_PRO |
| lawliet | 0:2728fc4ff217 | 27 | /******Pins definitions*************/ |
| lawliet | 0:2728fc4ff217 | 28 | #if defined(SEEEDUINO_ARCH) |
| lawliet | 0:2728fc4ff217 | 29 | #define RELAY_1 P1_5 |
| lawliet | 0:2728fc4ff217 | 30 | #define RELAY_2 P1_25 |
| lawliet | 0:2728fc4ff217 | 31 | #define RELAY_3 P1_24 |
| lawliet | 0:2728fc4ff217 | 32 | #define RELAY_4 P1_18 |
| lawliet | 0:2728fc4ff217 | 33 | #elif defined(SEEEDUINO_ARCH_PRO) |
| lawliet | 0:2728fc4ff217 | 34 | #define RELAY_1 P2_5 |
| lawliet | 0:2728fc4ff217 | 35 | #define RELAY_2 P2_4 |
| lawliet | 0:2728fc4ff217 | 36 | #define RELAY_3 P2_3 |
| lawliet | 0:2728fc4ff217 | 37 | #define RELAY_4 P2_2 |
| lawliet | 0:2728fc4ff217 | 38 | #else |
| lawliet | 0:2728fc4ff217 | 39 | #define RELAY_1 |
| lawliet | 0:2728fc4ff217 | 40 | #define RELAY_2 |
| lawliet | 0:2728fc4ff217 | 41 | #define RELAY_3 |
| lawliet | 0:2728fc4ff217 | 42 | #define RELAY_4 |
| lawliet | 0:2728fc4ff217 | 43 | #endif |
| lawliet | 0:2728fc4ff217 | 44 | |
| lawliet | 0:2728fc4ff217 | 45 | DigitalOut relayCtrl(RELAY_2); //we use Relay2 |
| lawliet | 0:2728fc4ff217 | 46 | |
| lawliet | 0:2728fc4ff217 | 47 | int main() { |
| lawliet | 0:2728fc4ff217 | 48 | while(1) { |
| lawliet | 0:2728fc4ff217 | 49 | relayCtrl = 1; |
| lawliet | 0:2728fc4ff217 | 50 | wait(2); |
| lawliet | 0:2728fc4ff217 | 51 | relayCtrl = 0; |
| lawliet | 0:2728fc4ff217 | 52 | wait(2); |
| lawliet | 0:2728fc4ff217 | 53 | } |
| lawliet | 0:2728fc4ff217 | 54 | } |
