91欧美超碰AV自拍|国产成年人性爱视频免费看|亚洲 日韩 欧美一厂二区入|人人看人人爽人人操aV|丝袜美腿视频一区二区在线看|人人操人人爽人人爱|婷婷五月天超碰|97色色欧美亚州A√|另类A√无码精品一级av|欧美特级日韩特级

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

怎樣使用RFID RC-522和Arduino創(chuàng)建一個簡單的超市應(yīng)用程序

454398 ? 來源:網(wǎng)絡(luò)整理 ? 作者:網(wǎng)絡(luò)整理 ? 2019-11-25 15:59 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

步驟1:設(shè)置ArduinoRFID RC-522(物理連接)

怎樣使用RFID RC-522和Arduino創(chuàng)建一個簡單的超市應(yīng)用程序

只需將arduino與RFID連接-RC522,如上圖所示。

警告:僅提供3.3V電壓,否則模塊將燒壞

為Uno/Nano和Mega插腳 strong》

RC522 MODULE Uno/Nano MEGA

SDA D10 D9

SCK D13 D52

MOSI D11 D51

MISO D12 D50

IRQ N/A N/A

GND GND GND

RST D9 D8

3.3V 3.3V 3.3V

第2步:Arduino代碼。

復(fù)制以下代碼,然后將其上傳到您的Arduino

/*

PINOUT:

RC522 MODULE Uno/Nano MEGA

SDA D10 D9

SCK D13 D52

MOSI D11 D51

MISO D12 D50

IRQ N/A N/A

GND GND GND

RST D9 D8

3.3V 3.3V 3.3V

*/

/* Include the standard Arduino SPI library */

#include

/* Include the RFID library */

#include

/* Define the DIO used for the SDA (SS) and RST (reset) pins. */

#define SDA_DIO 9

#define RESET_DIO 8

/* Create an instance of the RFID library */

RFID RC522(SDA_DIO, RESET_DIO);

int reader=0;

void setup()

{

Serial.begin(9600);

/* Enable the SPI interface */

SPI.begin();

/* Initialise the RFID reader */

RC522.init();

}

void loop()

{

/* Temporary loop counter */

byte i;

/* Has a card been detected? */

if (RC522.isCard())

{

/* If so then get its serial number */

RC522.readCardSerial();

/* Output the serial number to the UART */

for(i = 0; i 《= 2; i++)

{

Serial.print(RC522.serNum[i],DEC);

//Serial.print(RC522.serNum[i],HEX);

}

Serial.print(“,”);

Serial.print(reader++);

Serial.println();

}

delay(1000);

}

步驟3:設(shè)置MySQL

為MySQL安裝Wamp服務(wù)器并將其配置為存儲數(shù)據(jù)(

運行wamp服務(wù)器打開MySQL控制臺

選擇數(shù)據(jù)庫

然后為您的數(shù)據(jù)創(chuàng)建表

create table rfid(ID int(8),token int(1),Name varchar(20),Amount int(4));

現(xiàn)在查看此鏈接以了解如何獲取您的RFID標簽值,然后使用以下代碼插入數(shù)據(jù)。不要忘記將ID值替換為您的RFID標簽值

insert into rfid values(3756178,1,‘Pencil’,20);

使用令牌值作為 1 ,以便在首次讀取標簽值后,它將自動更改為 2 讀取未插入數(shù)據(jù)庫的卡時,不要使用 0 作為令牌值,它將分配0,然后將其顯示為“未知卡”。

步驟4:設(shè)置處理IDE

下載并安裝處理IDE 2.2.1

將上述給定的ZIP提取到MyDocuments/Processing/Libraries

現(xiàn)在打開處理的IDE,并檢查庫是否正確安裝(如上圖所示)

然后復(fù)制以下代碼進行處理并自行命名

import de.bezier.data.sql.*;

import processing.serial.*;

//import java.math.BigInteger;

// created 2005-05-10 by fjenett

// updated fjenett 20080605

MySQL dbconnection;

String s=“ ”;

int Wheight=700;

int Wwidth=1200;

long ID;

int token;

int Amount;

int Total=0;

String[] a={“NULL”,“NULL”};

int end = 10; // the number 10 is ASCII for linefeed (end of serial.println), later we will look for this to break up individual messages

String serial; // declare a new string called ‘serial’ 。 A string is a sequence of characters (data type know as “char”)

Serial port;

String curr,prev,Name;

PFont f;

void setup()

{

//size( Wwidth,Wheight );

size(700,500);

f=createFont(“Arial”,24,true);

// this example assumes that you are running the

// mysql server locally (on “l(fā)ocalhost”)。

//

// replace --username--, --password-- with your mysql-account.

//

String user = “root”;

String pass = “”;

// name of the database to use

//

String database = “IOT_Database”;

// name of the table that will be created

String table = “”;

// connect to database of server “l(fā)ocalhost”

dbconnection = new MySQL( this, “l(fā)ocalhost”, database, user, pass );

port = new Serial(this, Serial.list()[0], 9600); // initializing the object by assigning a port and baud rate (must match that of Arduino)

port.clear(); // function from serial library that throws out the first reading, in case we started reading in the middle of a string from Arduino

serial = port.readStringUntil(end); // function that reads the string from serial port until a println and then assigns string to our string variable (called ‘serial’)

serial = null;

}

void draw()

{

background(255);

textFont(f,24);

fill(0);

text(“Total Amount Rs:”,400,400);

text(Total,585,400);

data();

while (port.available() 》 0)

{

//as long as there is data coming from serial port, read it and store it

serial = port.readStringUntil(end);

}

if (serial != null)

{

prev=curr;

curr=a[1];

a = split(serial, ‘,’); //a new array (called ‘a(chǎn)’) that stores values into separate cells (separated by commas specified in your Arduino program

if((curr).equals(prev))

{

//

}

else

{

//println(“curr”,curr);

//println(“Prev”,prev);

function();

}

}

}

void function()

{

if ( dbconnection.connect() )

{

// now read it back out

//

dbconnection.query( “SELECT * from rfid where ID=”+a[0]+“” );

while (dbconnection.next())

{

ID = dbconnection.getInt(“ID”);

token = dbconnection.getInt(“token”);

Amount = dbconnection.getInt(“Amount”);

}

if(token==0)

{

println(“Ok”);

textFont(f,54);

fill(255,0,0,160);

text(“Unknown Item Detected”,50,300);

delay(2000);

}

else if(token==1)

{

Total=Total+Amount;

dbconnection.query(“update rfid set token=2 where ID=”+a[0]+“” );

println(“Ok”);

textFont(f,24);

fill(255,0,0,160);

//text(“Item Added”,10,30);

delay(1000);

}

else if(token==2)

{

Total=Total-Amount;

dbconnection.query(“update rfid set token=1 where ID=”+a[0]+“” );

println(“Ok”);

textFont(f,24);

fill(255,0,0,160);

//text(“Item Removed”,10,30);

delay(1000);

}

else

{

}

dbconnection.close();

}

else

{

// connection failed !

}

}

void data()

{

int position=100;

if ( dbconnection.connect() )

{

dbconnection.query( “SELECT * from rfid where token=2”);

while (dbconnection.next())

{

Name = dbconnection.getString(“Name”);

Amount = dbconnection.getInt(“Amount”);

textFont(f,24);

fill(0,0,255,160);

text(Name,10,position);

fill(0,0,0,160);

text(Amount,215,position);

position=position+30;

}

}

dbconnection.close();

}

第5步:執(zhí)行程序

通過單擊運行按鈕運行程序,請關(guān)閉彈出窗口,關(guān)閉窗口將停止執(zhí)行,并在以下查詢中查看在MySQL中存儲的數(shù)據(jù)。..

責任編輯:wv

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • RFID
    +關(guān)注

    關(guān)注

    392

    文章

    6933

    瀏覽量

    248426
  • 應(yīng)用程序
    +關(guān)注

    關(guān)注

    38

    文章

    3344

    瀏覽量

    60314
  • Arduino
    +關(guān)注

    關(guān)注

    190

    文章

    6526

    瀏覽量

    197081
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關(guān)推薦
    熱點推薦

    極速入門:AirRC522_1000方案實現(xiàn)RFID讀卡功能的鍵集成

    的通信時序細節(jié),僅需調(diào)用簡單的API即可完成卡片的尋卡、防沖突、選卡及密鑰認證等全流程操作,真正實現(xiàn)RFID功能的“鍵集成”,將開發(fā)周期縮短至小時級別。門禁系統(tǒng)自動
    的頭像 發(fā)表于 02-28 17:30 ?444次閱讀
    極速入門:AirRC<b class='flag-5'>522</b>_1000方案實現(xiàn)<b class='flag-5'>RFID</b>讀卡功能的<b class='flag-5'>一</b>鍵集成

    恩智浦MFRC522與SI522的性能功耗對比

    功耗下降10mA,相比新增了自動尋卡和定時喚醒,自動尋卡功耗為4.5uA,業(yè)界最低。3.首創(chuàng)全新尋卡方式,讀卡模組不再死機。 SI522的概述 Si522高度集成的,工作在13
    發(fā)表于 02-28 16:43

    電動車NFC鍵啟動(儀表總成、電源鎖)_Ci522

    電動車NFC鍵啟動 NFC智能刷卡解鎖,為你解決四處尋找鑰匙的困擾,提升電動車智能化 Ci522種非接觸式讀寫芯片,工作頻率為13.56MHz。支持讀a卡(ci523支持讀a/b卡),可用
    發(fā)表于 02-28 15:11

    USBISP/USBasp編程器給Atmega32U4下載Arduino bootloader引導(dǎo)程序

    對于新出廠的ATmega32U4芯片內(nèi)部是沒有arduino引導(dǎo)程序的,需要用戶預(yù)先下載bootloader后才能用串口下載自己的應(yīng)用程序.在某些罕見情況下舊的bootloader會導(dǎo)致
    的頭像 發(fā)表于 01-31 14:38 ?738次閱讀
    USBISP/USBasp編程器給Atmega32U4下載<b class='flag-5'>Arduino</b> bootloader引導(dǎo)<b class='flag-5'>程序</b>

    讓AIoT創(chuàng)新像“逛超市簡單!移遠通信AlgoStore算法超市上線

    通信AlgoStore算法超市正式上線AI開放平臺。作為站式AIoT算法平臺,AlgoStore就像匯聚豐富前沿AI算法的“超級市場”,憑借強大的算法適配能力
    的頭像 發(fā)表于 01-07 19:12 ?372次閱讀
    讓AIoT創(chuàng)新像“逛<b class='flag-5'>超市</b>”<b class='flag-5'>一</b>樣<b class='flag-5'>簡單</b>!移遠通信AlgoStore算法<b class='flag-5'>超市</b>上線

    SI522與恩智浦 RC522 13.56MHZ的刷卡問題

    大家介紹款性價比極高、功耗極低、自動尋卡、定時喚醒的13.56mhz非接觸式讀卡芯片:SI522,希望給那些因為功耗下不來而煩惱的技術(shù)朋友們有所幫助! Si522
    發(fā)表于 12-01 10:16

    RFID電子標簽:讓生活和工作開掛的神奇科技

    出門過ETC不用停車、超市結(jié)賬不用挨個掃碼、酒店開門不用插鑰匙 —— 你有沒有發(fā)現(xiàn),這些讓生活變便捷的場景里,都藏著同一個 “幕后功臣”:RFID電子標簽。這個看似不起眼的小技術(shù),早已悄悄滲透到
    的頭像 發(fā)表于 11-13 10:06 ?678次閱讀

    學(xué)生適合使用的SOLIDWORKS 云應(yīng)用程序

    隨著科技的不斷發(fā)展,計算機輔助設(shè)計(CAD)技術(shù)已經(jīng)成為現(xiàn)代工程教育的重要組成部分。SOLIDWORKS作為款CAD軟件,其教育版云應(yīng)用程序為學(xué)生提供了強大而靈活的設(shè)計平臺。本文將探討
    的頭像 發(fā)表于 09-15 10:39 ?823次閱讀
    學(xué)生適合使用的SOLIDWORKS 云<b class='flag-5'>應(yīng)用程序</b>

    如何用Arduino Nano/UNO R3開發(fā)板給另一個Arduino IDE不能下載的Arduino Nano/UNO R3開發(fā)板重新燒錄引導(dǎo)程序bootlaoder

    本文介紹了如何用能夠Arduino IDE下載的Arduino Nano/UNO R3開發(fā)板給另一個Arduino IDE不能下載的Arduino
    的頭像 發(fā)表于 08-08 20:16 ?3671次閱讀
    如何用<b class='flag-5'>Arduino</b> Nano/UNO R3開發(fā)板給另<b class='flag-5'>一個</b><b class='flag-5'>Arduino</b> IDE不能下載的<b class='flag-5'>Arduino</b> Nano/UNO R3開發(fā)板重新燒錄引導(dǎo)<b class='flag-5'>程序</b>bootlaoder

    阿里展廳同款無人超市技術(shù)解析:RFID與AI視覺如何顛覆零售?

    在阿里展廳的未來零售場景中,由深圳市遠景達物聯(lián)網(wǎng)技術(shù)有限公司打造的無人超市正以顛覆性姿態(tài)重構(gòu)行業(yè)邏輯。這項融合RFID射頻識別與AI視覺技術(shù)的創(chuàng)新方案,通過物聯(lián)網(wǎng)、傳感器融合和深度學(xué)習(xí)算法的協(xié)同運作
    的頭像 發(fā)表于 07-03 13:50 ?1621次閱讀
    阿里展廳同款無人<b class='flag-5'>超市</b>技術(shù)解析:<b class='flag-5'>RFID</b>與AI視覺如何顛覆零售?

    單片機實例:RC522無線射頻項目資料

    單片機實例:RC522無線射頻項目資料,推薦下載!
    發(fā)表于 06-03 22:09

    ESP32驅(qū)動MFRC522 RFID模塊讀寫IC卡數(shù)據(jù)

    本文將介紹ESP32開發(fā)板驅(qū)動MFRC522 RFID模塊,讀取RFID卡原始數(shù)據(jù)、獲取RFID卡的UID,并將個人數(shù)據(jù)添加到RFID卡中。
    的頭像 發(fā)表于 05-28 15:52 ?1503次閱讀
    ESP32驅(qū)動MFRC<b class='flag-5'>522</b> <b class='flag-5'>RFID</b>模塊讀寫IC卡數(shù)據(jù)

    如何使用CYUSB3KIT-003使用GPIO訪問SRAM的應(yīng)用程序?

    你好。我是CYUSB3的初學(xué)者。 我想創(chuàng)建使用 CYUSB3KIT-003 使用 GPIO 訪問 SRAM 的應(yīng)用程序。 目前我已經(jīng)在我的電腦上安裝了SDK,但是有什么參考資料嗎?
    發(fā)表于 05-14 06:51

    《ESP32S3 Arduino開發(fā)指南》第二章 Arduino基礎(chǔ)知識

    Arduino生態(tài)的建設(shè)。2.2 Arduino的由來Arduino種基于開源硬件和軟件的電子原型平臺,它由
    發(fā)表于 05-13 09:28

    RFID卡通系統(tǒng)中的應(yīng)用

    RFID(射頻識別)技術(shù)在卡通系統(tǒng)中扮演著核心角色,通過無線通信實現(xiàn)身份識別、支付和數(shù)據(jù)交互。、RFID卡通中的核心功能身份識別與門
    的頭像 發(fā)表于 03-27 14:14 ?979次閱讀
    <b class='flag-5'>RFID</b>在<b class='flag-5'>一</b>卡通系統(tǒng)中的應(yīng)用