A capacitive touch sensor using a analog input port.

Dependencies:   TouchSense mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* mbed Microcontroller Sample Program
00002  * Copyright (c) 2013 Shinichiro Nakamura
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #include "mbed.h"
00017 #include "TouchSense.h"
00018  
00019 TouchSense ts1(p15);
00020 TouchSense ts2(p16);
00021 TouchSense ts3(p17);
00022 TouchSense ts4(p18);
00023 TouchSense ts5(p19);
00024 TouchSense ts6(p20);
00025  
00026 int main() {
00027     ts1.calibration();
00028     ts2.calibration();
00029     ts3.calibration();
00030     ts4.calibration();
00031     ts5.calibration();
00032     ts6.calibration();
00033     while (true) {
00034         printf("[%c%c%c%c%c%c]\r\n",
00035             ts1.sense() ? 'o' : '.',
00036             ts2.sense() ? 'o' : '.',
00037             ts3.sense() ? 'o' : '.',
00038             ts4.sense() ? 'o' : '.',
00039             ts5.sense() ? 'o' : '.',
00040             ts6.sense() ? 'o' : '.');
00041         wait(0.050);
00042     }
00043 }